From 7900eb691f444a3d95d2f736513059cede6e9d9b Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Wed, 10 May 2023 16:44:30 +0200 Subject: [PATCH] Makes hiding players default to true --- .../arena/PlayerVisibilityManager.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/knarcraft/minigames/arena/PlayerVisibilityManager.java b/src/main/java/net/knarcraft/minigames/arena/PlayerVisibilityManager.java index fbd18c9..9e2e342 100644 --- a/src/main/java/net/knarcraft/minigames/arena/PlayerVisibilityManager.java +++ b/src/main/java/net/knarcraft/minigames/arena/PlayerVisibilityManager.java @@ -15,7 +15,7 @@ import java.util.UUID; */ public class PlayerVisibilityManager { - private final Set hidingEnabledFor = new HashSet<>(); + private final Set displayingEnabledFor = new HashSet<>(); /** * Toggles whether players should be hidden for the player with the given id @@ -23,14 +23,14 @@ public class PlayerVisibilityManager { * @param player

The the player to update

*/ public void toggleHidePlayers(@NotNull ArenaPlayerRegistry playerRegistry, @NotNull Player player) { - if (hidingEnabledFor.contains(player.getUniqueId())) { - hidingEnabledFor.remove(player.getUniqueId()); - // Make all other players visible again - changeVisibilityFor(playerRegistry, player, false); - } else { - hidingEnabledFor.add(player.getUniqueId()); + if (displayingEnabledFor.contains(player.getUniqueId())) { + displayingEnabledFor.remove(player.getUniqueId()); // Make all other players hidden changeVisibilityFor(playerRegistry, player, true); + } else { + displayingEnabledFor.add(player.getUniqueId()); + // Make all other players visible again + changeVisibilityFor(playerRegistry, player, false); } } @@ -42,7 +42,7 @@ public class PlayerVisibilityManager { * @return

True if currently hiding other players

*/ public boolean isHidingPlayers(Player player) { - return this.hidingEnabledFor.contains(player.getUniqueId()); + return !this.displayingEnabledFor.contains(player.getUniqueId()); } /** @@ -52,7 +52,7 @@ public class PlayerVisibilityManager { * @param player

The player that joined the arena

*/ public void updateHiddenPlayers(@NotNull ArenaPlayerRegistry playerRegistry, @NotNull Player player) { - boolean hideForPlayer = hidingEnabledFor.contains(player.getUniqueId()); + boolean hideForPlayer = !displayingEnabledFor.contains(player.getUniqueId()); for (UUID playerId : playerRegistry.getPlayingPlayers()) { Player otherPlayer = Bukkit.getPlayer(playerId); if (otherPlayer == null) { @@ -63,7 +63,7 @@ public class PlayerVisibilityManager { player.hidePlayer(MiniGames.getInstance(), otherPlayer); } // Hide the newly joined player from this player - if (hidingEnabledFor.contains(playerId)) { + if (!displayingEnabledFor.contains(playerId)) { otherPlayer.hidePlayer(MiniGames.getInstance(), player); } }