diff --git a/spigot/src/main/java/org/geysermc/floodgate/util/SpigotCommandUtil.java b/spigot/src/main/java/org/geysermc/floodgate/util/SpigotCommandUtil.java index 4950309d..d6028abe 100644 --- a/spigot/src/main/java/org/geysermc/floodgate/util/SpigotCommandUtil.java +++ b/spigot/src/main/java/org/geysermc/floodgate/util/SpigotCommandUtil.java @@ -27,6 +27,7 @@ package org.geysermc.floodgate.util; import java.util.Collection; import java.util.UUID; +import org.bukkit.OfflinePlayer; import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -122,11 +123,11 @@ public final class SpigotCommandUtil extends CommandUtil { @Override public boolean whitelistPlayer(UUID uuid, String username) { - return WhitelistUtils.addPlayer(uuid, username); + return WhitelistUtils.addPlayer(uuid, username, versionSpecificMethods); } @Override public boolean removePlayerFromWhitelist(UUID uuid, String username) { - return WhitelistUtils.removePlayer(uuid, username); + return WhitelistUtils.removePlayer(uuid, username, versionSpecificMethods); } } diff --git a/spigot/src/main/java/org/geysermc/floodgate/util/WhitelistUtils.java b/spigot/src/main/java/org/geysermc/floodgate/util/WhitelistUtils.java index 6747c28c..d5779565 100644 --- a/spigot/src/main/java/org/geysermc/floodgate/util/WhitelistUtils.java +++ b/spigot/src/main/java/org/geysermc/floodgate/util/WhitelistUtils.java @@ -36,11 +36,12 @@ public final class WhitelistUtils { /** * Whitelist the given Bedrock player. * - * @param uuid the UUID of the Bedrock player to be whitelisted - * @param username the username of the Bedrock player to be whitelisted - * @return true if the player has been whitelisted, false if the player is already whitelisted + * @param uuid the UUID of the Bedrock player to be removed + * @param username the username of the Bedrock player to be removed + * @param versionSpecificMethods a reference to the SpigotVersionSpecificMethods used in SpigotCommandUtil + * @return true if the player has been removed from the whitelist, false if the player wasn't */ - public static boolean addPlayer(UUID uuid, String username) { + public static boolean addPlayer(UUID uuid, String username, SpigotVersionSpecificMethods versionSpecificMethods) { GameProfile profile = new GameProfile(uuid, username); OfflinePlayer player = ReflectionUtils.newInstance( @@ -50,7 +51,7 @@ public final class WhitelistUtils { if (player.isWhitelisted()) { return false; } - player.setWhitelisted(true); + setWhitelist(player, true, versionSpecificMethods); return true; } @@ -59,10 +60,11 @@ public final class WhitelistUtils { * * @param uuid the UUID of the Bedrock player to be removed * @param username the username of the Bedrock player to be removed + * @param versionSpecificMethods a reference to the SpigotVersionSpecificMethods used in SpigotCommandUtil * @return true if the player has been removed from the whitelist, false if the player wasn't * whitelisted */ - public static boolean removePlayer(UUID uuid, String username) { + public static boolean removePlayer(UUID uuid, String username, SpigotVersionSpecificMethods versionSpecificMethods) { GameProfile profile = new GameProfile(uuid, username); OfflinePlayer player = ReflectionUtils.newInstance( @@ -72,7 +74,11 @@ public final class WhitelistUtils { if (!player.isWhitelisted()) { return false; } - player.setWhitelisted(false); + setWhitelist(player, false, versionSpecificMethods); return true; } + + static void setWhitelist(OfflinePlayer player, boolean whitelist, SpigotVersionSpecificMethods versionSpecificMethods) { + versionSpecificMethods.maybeSchedule(() -> player.setWhitelisted(whitelist)); + } }