From 40b56867bea61d3bdfd6d651db1e11fe5b708b67 Mon Sep 17 00:00:00 2001 From: Boy Date: Tue, 8 Nov 2022 10:56:10 +0100 Subject: [PATCH] make checks only run when entities position changes --- .../com/mineinabyss/deeperworld/listeners/MovementListener.kt | 2 ++ .../com/mineinabyss/deeperworld/listeners/PlayerListener.kt | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/mineinabyss/deeperworld/listeners/MovementListener.kt b/src/main/kotlin/com/mineinabyss/deeperworld/listeners/MovementListener.kt index f84fd44..480aa8a 100644 --- a/src/main/kotlin/com/mineinabyss/deeperworld/listeners/MovementListener.kt +++ b/src/main/kotlin/com/mineinabyss/deeperworld/listeners/MovementListener.kt @@ -18,6 +18,7 @@ object MovementListener : Listener { @EventHandler(ignoreCancelled = true, priority = EventPriority.LOW) fun PlayerMoveEvent.move() { + if (!hasExplicitlyChangedPosition()) return if (player.hasPermission(Permissions.ADMIN_PERMISSION) && player.canMoveSections) { MovementHandler.handleMovement(player, from, to) } @@ -34,6 +35,7 @@ object MovementListener : Listener { @EventHandler fun EntityMoveEvent.entityMove() { + if (!hasExplicitlyChangedPosition()) return if (entity.getPassengersRecursive().isEmpty()) return entity.getPassengersRecursive().filterIsInstance() .filter { rider -> rider.hasPermission(Permissions.ADMIN_PERMISSION) && rider.canMoveSections } diff --git a/src/main/kotlin/com/mineinabyss/deeperworld/listeners/PlayerListener.kt b/src/main/kotlin/com/mineinabyss/deeperworld/listeners/PlayerListener.kt index 5ea7ceb..d8e5a90 100644 --- a/src/main/kotlin/com/mineinabyss/deeperworld/listeners/PlayerListener.kt +++ b/src/main/kotlin/com/mineinabyss/deeperworld/listeners/PlayerListener.kt @@ -14,9 +14,8 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.ENDER_PEARL object PlayerListener : Listener { @EventHandler fun PlayerTeleportEvent.onPlayerTeleport() { - if (player.gameMode == CREATIVE) return + if (player.gameMode == CREATIVE || !player.canMoveSections) return if (cause != ENDER_PEARL && cause != CHORUS_FRUIT) return - if (!player.canMoveSections) return if ( to.section == null ||