From d91286542e1a6a3d3ef0b37e0fc4d70ae146f6dd Mon Sep 17 00:00:00 2001 From: jojo Date: Tue, 29 Dec 2020 21:53:07 +0100 Subject: [PATCH] Remove PlayerHider --- src/de/steamwar/lobby/LobbySystem.java | 1 - .../lobby/inventories/LobbyInventory.java | 11 +-- .../lobby/listener/PlayerHiderListener.java | 96 ------------------- src/de/steamwar/lobby/utils/LobbyPlayer.java | 38 -------- 4 files changed, 2 insertions(+), 144 deletions(-) delete mode 100644 src/de/steamwar/lobby/listener/PlayerHiderListener.java diff --git a/src/de/steamwar/lobby/LobbySystem.java b/src/de/steamwar/lobby/LobbySystem.java index f171e66..197b62e 100644 --- a/src/de/steamwar/lobby/LobbySystem.java +++ b/src/de/steamwar/lobby/LobbySystem.java @@ -40,7 +40,6 @@ public class LobbySystem extends JavaPlugin { pm.registerEvents(new PlayerWorldInteractionListener(), instance); pm.registerEvents(new DoubleJumpListener(), instance); pm.registerEvents(new ParticleListener(), instance); - pm.registerEvents(new PlayerHiderListener(), instance); pm.registerEvents(new EnderPearlListener(), instance); } diff --git a/src/de/steamwar/lobby/inventories/LobbyInventory.java b/src/de/steamwar/lobby/inventories/LobbyInventory.java index 7b43226..2bd9d60 100644 --- a/src/de/steamwar/lobby/inventories/LobbyInventory.java +++ b/src/de/steamwar/lobby/inventories/LobbyInventory.java @@ -28,7 +28,6 @@ public class LobbyInventory { private LobbyInventory() {} - public static Material PLAYER_HIDER = Material.BLAZE_ROD; public static Material PARTICLE = Material.NAME_TAG; public static Material ENDERPEARL_USED = Material.FIREWORK_STAR; public static Material ENDERPEARL_READY = Material.ENDER_PEARL; @@ -37,19 +36,13 @@ public class LobbyInventory { public static void givePlayerLobbyItems(Player player) { LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); - player.getInventory().setItem(2, new ItemBuilder(PLAYER_HIDER) - .setDisplayName(lobbyPlayer.getHiderState().getName()) - .setUnbreakable(true) - .removeAllAtributs() - .build()); - - player.getInventory().setItem(4, new ItemBuilder(lobbyPlayer.isEnderPearlUsed() ? ENDERPEARL_USED : ENDERPEARL_READY) + player.getInventory().setItem(3, new ItemBuilder(lobbyPlayer.isEnderPearlUsed() ? ENDERPEARL_USED : ENDERPEARL_READY) .setDisplayName("§5Enderperle") .setUnbreakable(true) .removeAllAtributs() .build()); - player.getInventory().setItem(6, new ItemBuilder(PARTICLE) + player.getInventory().setItem(5, new ItemBuilder(PARTICLE) .setDisplayName("§6Partikel") .setUnbreakable(true) .removeAllAtributs() diff --git a/src/de/steamwar/lobby/listener/PlayerHiderListener.java b/src/de/steamwar/lobby/listener/PlayerHiderListener.java deleted file mode 100644 index 431a3a8..0000000 --- a/src/de/steamwar/lobby/listener/PlayerHiderListener.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.lobby.listener; - -import de.steamwar.lobby.inventories.LobbyInventory; -import de.steamwar.lobby.utils.LobbyPlayer; -import de.steamwar.sql.SteamwarUser; -import de.steamwar.sql.UserGroup; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerJoinEvent; - -public class PlayerHiderListener implements Listener { - - @EventHandler(priority = EventPriority.NORMAL) - public void handlePlayerInteract(PlayerInteractEvent event) { - Material material = event.getMaterial(); - if(material != LobbyInventory.PLAYER_HIDER) - return; - - Player player = event.getPlayer(); - LobbyPlayer.getLobbyPlayer(player.getUniqueId()).nexthHiderState(); - updateHider(player); - LobbyInventory.givePlayerLobbyItems(event.getPlayer()); - } - - @EventHandler - public void handlePlayerJoin(PlayerJoinEvent event) { - updateHider(event.getPlayer()); - } - - private void updateHider(Player player) { - LobbyPlayer.PlayerHiderState hiderState = LobbyPlayer.getLobbyPlayer(player.getUniqueId()).getHiderState(); - - Bukkit.getServer().getOnlinePlayers().forEach(currentPlayer -> { - if(currentPlayer.getUniqueId().equals(player.getUniqueId())) return; - - switch (hiderState) { - case SHOW_ALL: - player.showPlayer(currentPlayer); - break; - case SHOW_TEAM: - UserGroup userGroup = SteamwarUser.get(currentPlayer.getUniqueId()).getUserGroup(); - if(userGroup == UserGroup.Member) - player.hidePlayer(currentPlayer); - else - player.showPlayer(currentPlayer); - break; - case SHOW_NOBODY: - player.hidePlayer(currentPlayer); - break; - } - - LobbyPlayer.PlayerHiderState cpHiderState = LobbyPlayer.getLobbyPlayer(currentPlayer.getUniqueId()).getHiderState(); - switch (cpHiderState) { - case SHOW_ALL: - currentPlayer.showPlayer(player); - break; - case SHOW_TEAM: - UserGroup userGroup = SteamwarUser.get(player.getUniqueId()).getUserGroup(); - if(userGroup == UserGroup.Member) - currentPlayer.hidePlayer(player); - else - currentPlayer.showPlayer(player); - break; - case SHOW_NOBODY: - currentPlayer.hidePlayer(player); - break; - } - }); - } - - -} diff --git a/src/de/steamwar/lobby/utils/LobbyPlayer.java b/src/de/steamwar/lobby/utils/LobbyPlayer.java index 68857eb..96a0292 100644 --- a/src/de/steamwar/lobby/utils/LobbyPlayer.java +++ b/src/de/steamwar/lobby/utils/LobbyPlayer.java @@ -29,8 +29,6 @@ public class LobbyPlayer { private static Map cache = new HashMap<>(); - private PlayerHiderState hiderState; - private Particle particle; private boolean customVelocity = false; private float particle_vx = 0; @@ -41,18 +39,9 @@ public class LobbyPlayer { private boolean enderPearlUsed; private LobbyPlayer(UUID uuid) { - this.hiderState = PlayerHiderState.SHOW_ALL; cache.put(uuid, this); } - public PlayerHiderState getHiderState() { - return hiderState; - } - - public void setHiderState(PlayerHiderState hiderState) { - this.hiderState = hiderState; - } - public Particle getParticle() { return particle; } @@ -104,33 +93,6 @@ public class LobbyPlayer { this.enderPearlUsed = enderPearlUsed; } - public void nexthHiderState() { - if(this.hiderState == PlayerHiderState.SHOW_ALL) { - this.hiderState = PlayerHiderState.SHOW_TEAM; - } - else if(this.hiderState == PlayerHiderState.SHOW_TEAM) { - this.hiderState = PlayerHiderState.SHOW_NOBODY; - } - else - this.hiderState = PlayerHiderState.SHOW_ALL; - } - - public enum PlayerHiderState { - SHOW_ALL("§aAlle Spieler"), - SHOW_TEAM("§6Nur Teammitglieder"), - SHOW_NOBODY("§cKeine Spieler"); - - private String name; - - private PlayerHiderState(String name) { - this.name = name; - } - - public String getName() { - return name; - } - } - public static LobbyPlayer getLobbyPlayer(UUID uuid) { LobbyPlayer lobbyPlayer = cache.get(uuid); return lobbyPlayer == null ? new LobbyPlayer(uuid) : lobbyPlayer; -- 2.39.5