diff --git a/src/de/steamwar/lobby/LobbySystem.java b/src/de/steamwar/lobby/LobbySystem.java
index f3a301a..243d307 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);
getCommand("fly").setExecutor(new FlyCommand());
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/listener/PlayerMoveListener.java b/src/de/steamwar/lobby/listener/PlayerMoveListener.java
index e5daf07..ebe2e92 100644
--- a/src/de/steamwar/lobby/listener/PlayerMoveListener.java
+++ b/src/de/steamwar/lobby/listener/PlayerMoveListener.java
@@ -20,7 +20,6 @@
package de.steamwar.lobby.listener;
import de.steamwar.lobby.utils.Config;
-import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -29,37 +28,15 @@ import org.bukkit.util.Vector;
public class PlayerMoveListener implements Listener {
+ private static final Vector borderMinVector = new Vector(Config.BorderMinX, Config.BorderMinY, Config.BorderMinZ);
+ private static final Vector borderMaxVector = new Vector(Config.BorderMaxX, Config.BorderMaxY, Config.BorderMaxZ);
+
@EventHandler
public void handleWorldBorder(PlayerMoveEvent event) {
Location to = event.getTo();
- if(!isInRegion(
- new Vector(Config.BorderMinX, Config.BorderMinY, Config.BorderMinZ),
- new Vector(Config.BorderMaxX, Config.BorderMaxY, Config.BorderMaxZ),
- to.toVector()))
- event.getPlayer().teleport(new Location(
- Bukkit.getWorlds().get(0),
- Config.SpawnX,
- Config.SpawnY,
- Config.SpawnZ,
- Config.Yaw,
- Config.Pitch));
+ if (!to.toVector().isInAABB(borderMinVector, borderMaxVector)) {
+ event.getPlayer().teleport(event.getFrom());
+ }
}
- private boolean isInRegion(Vector minPoint, Vector maxPoint, Vector location) {
- int x = location.getBlockX();
- int y = location.getBlockY();
- int z = location.getBlockZ();
-
- if(x >= minPoint.getBlockX()
- && x <= maxPoint.getBlockX()
- && y >= minPoint.getBlockY()
- && y <= maxPoint.getBlockY()
- && z >= minPoint.getBlockZ()
- && z <= maxPoint.getBlockZ()) {
- return true;
- } else
- return false;
- }
-
-
-}
+}
\ No newline at end of file
diff --git a/src/de/steamwar/lobby/utils/LobbyPlayer.java b/src/de/steamwar/lobby/utils/LobbyPlayer.java
index aabd3b5..1cce12b 100644
--- a/src/de/steamwar/lobby/utils/LobbyPlayer.java
+++ b/src/de/steamwar/lobby/utils/LobbyPlayer.java
@@ -30,8 +30,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;
@@ -43,7 +41,6 @@ public class LobbyPlayer {
private boolean fly;
private LobbyPlayer(UUID uuid) {
- this.hiderState = PlayerHiderState.SHOW_ALL;
cache.put(uuid, this);
}
@@ -55,14 +52,6 @@ public class LobbyPlayer {
this.fly = fly;
}
- public PlayerHiderState getHiderState() {
- return hiderState;
- }
-
- public void setHiderState(PlayerHiderState hiderState) {
- this.hiderState = hiderState;
- }
-
public Particle getParticle() {
return particle;
}
@@ -114,33 +103,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;