From 6929a60c0f67d04fb402005c4e2021dce9c1e5b9 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 20 Jan 2022 20:24:40 +0100 Subject: [PATCH] Update WarpListener Signed-off-by: yoyosource --- .../bausystem/features/warp/WarpListener.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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()); });