diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java index ab4924de..4e6690ef 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java @@ -28,9 +28,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.*; import org.bukkit.util.Vector; import java.util.ArrayList; @@ -46,6 +44,15 @@ public class WarpListener implements Listener { @EventHandler public void onPlayerMove(PlayerMoveEvent event) { + createStuff(event, event.getPlayer().isSneaking()); + } + + @EventHandler + public void onPlayerToggleSneak(PlayerToggleSneakEvent event) { + createStuff(event, event.isSneaking()); + } + + private void createStuff(PlayerEvent event, boolean sneaking) { if (warpsShown.containsKey(event.getPlayer())) { warpsShown.get(event.getPlayer()).forEach(warp -> { warp.hide(event.getPlayer()); @@ -62,7 +69,7 @@ public class WarpListener implements Listener { current.setY(event.getPlayer().getLocation().getY() - 1); Map locations = new HashMap<>(); - if (event.getPlayer().isSneaking()) { + if (sneaking) { Bukkit.getOnlinePlayers().forEach(player -> { locations.put(player.getName(), player.getLocation()); });