Skip to content

Commit

Permalink
Jank Fix for GeyserMC#444
Browse files Browse the repository at this point in the history
  • Loading branch information
HideyBoi committed Sep 27, 2023
1 parent 26c11bd commit 22d2c17
Showing 1 changed file with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,17 @@

package org.geysermc.floodgate.util;

import static org.bukkit.Bukkit.getServer;

import com.mojang.authlib.GameProfile;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.geysermc.floodgate.FloodgatePlatform;
import org.geysermc.floodgate.SpigotPlugin;
import org.geysermc.floodgate.api.FloodgateApi;



@SuppressWarnings("ConstantConditions")
public final class WhitelistUtils {
Expand All @@ -45,12 +52,19 @@ public static boolean addPlayer(UUID uuid, String username) {

OfflinePlayer player = ReflectionUtils.newInstance(
ClassNames.CRAFT_OFFLINE_PLAYER_CONSTRUCTOR,
Bukkit.getServer(), profile
getServer(), profile
);
if (player.isWhitelisted()) {
return false;
}
player.setWhitelisted(true);

Bukkit.getScheduler().runTask(getServer().getPluginManager().getPlugin("floodgate"),
new Runnable() {
@Override
public void run() {
player.setWhitelisted(true);
}
});
return true;
}

Expand All @@ -67,12 +81,20 @@ public static boolean removePlayer(UUID uuid, String username) {

OfflinePlayer player = ReflectionUtils.newInstance(
ClassNames.CRAFT_OFFLINE_PLAYER_CONSTRUCTOR,
Bukkit.getServer(), profile
getServer(), profile
);
if (!player.isWhitelisted()) {
return false;
}
player.setWhitelisted(false);

Bukkit.getScheduler().runTask(getServer().getPluginManager().getPlugin("floodgate"),
new Runnable() {
@Override
public void run() {
player.setWhitelisted(false);
}
});

return true;
}
}

0 comments on commit 22d2c17

Please sign in to comment.