From 938a176a9fbea61a7e862a9c3cd90e22a8e0608c Mon Sep 17 00:00:00 2001 From: DieGurke Date: Sun, 15 Nov 2020 22:39:41 +0100 Subject: [PATCH] Reworked glide tiggering mechanic to be more usable --- src/main/java/dev/kske/spawnfly/SpawnListener.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/java/dev/kske/spawnfly/SpawnListener.java b/src/main/java/dev/kske/spawnfly/SpawnListener.java index 37a36c1..5f11d6d 100644 --- a/src/main/java/dev/kske/spawnfly/SpawnListener.java +++ b/src/main/java/dev/kske/spawnfly/SpawnListener.java @@ -10,36 +10,32 @@ import org.bukkit.event.player.*; public class SpawnListener implements Listener { - Map activePlayers = new HashMap<>(); Map canceledEvents = new HashMap<>(); + @SuppressWarnings("deprecation") @EventHandler public void onMove(PlayerMoveEvent e) { Player player = e.getPlayer(); Location location = player.getLocation(); - if(isInSpawn(location)) activePlayers.put(player.getName(), true); - else if(activePlayers.get(player.getName()) && player.getVelocity().getY() < 0) { + if(isInSpawn(location) && player.getVelocity().getY() < 0 && !player.isOnGround() && !canceledEvents.get(player.getName()) && player.getFallDistance() > 1) { player.setGliding(true); canceledEvents.put(player.getName(), true); - activePlayers.put(player.getName(), false); } } @EventHandler public void onPlayerJoin(PlayerJoinEvent e) { - activePlayers.put(e.getPlayer().getName(), isInSpawn(e.getPlayer().getLocation())); canceledEvents.put(e.getPlayer().getName(), false); } @EventHandler public void onPlayerQuit(PlayerQuitEvent e) { - activePlayers.remove(e.getPlayer().getName()); canceledEvents.remove(e.getPlayer().getName()); } private boolean isInSpawn(Location location) { - return (location.getX() <= -277 && location.getX() >= -302) - && (location.getZ() <= -172 && location.getZ() >= -191); + return (location.getX() <= -277 + 3 && location.getX() >= -302 - 3) + && (location.getZ() <= -172 + 3 && location.getZ() >= -191 - 3); } @EventHandler