Remove PlayerHider #19
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -29,8 +29,6 @@ public class LobbyPlayer {
|
||||
|
||||
private static Map<UUID, LobbyPlayer> 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;
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren