Makes some GUI changes

Makes the current state of the player toggle visible.
Makes it possible to toggle player visibility outside arenas.
This commit is contained in:
2023-05-10 16:33:01 +02:00
parent 7848a0a028
commit d6fb9ab0b9
9 changed files with 102 additions and 21 deletions

View File

@ -4,6 +4,7 @@ import net.knarcraft.minigames.MiniGames;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashSet;
import java.util.Set;
@ -34,6 +35,16 @@ public class PlayerVisibilityManager {
}
/**
* Gets whether the given player is currently hiding other players
*
* @param player <p>The player to check</p>
* @return <p>True if currently hiding other players</p>
*/
public boolean isHidingPlayers(Player player) {
return this.hidingEnabledFor.contains(player.getUniqueId());
}
/**
* Updates which players are seen as hidden
*
@ -77,7 +88,10 @@ public class PlayerVisibilityManager {
* @param player <p>The player to change the visibility for</p>
* @param hide <p>Whether to hide the players or show the players</p>
*/
private void changeVisibilityFor(@NotNull ArenaPlayerRegistry<?> playerRegistry, @NotNull Player player, boolean hide) {
private void changeVisibilityFor(@Nullable ArenaPlayerRegistry<?> playerRegistry, @NotNull Player player, boolean hide) {
if (playerRegistry == null) {
return;
}
for (UUID playerId : playerRegistry.getPlayingPlayers()) {
Player otherPlayer = Bukkit.getPlayer(playerId);
if (otherPlayer == null) {