Skip to content

Commit

Permalink
make checks only run when entities position changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Nov 8, 2022
1 parent a5794c9 commit 40b5686
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -34,6 +35,7 @@ object MovementListener : Listener {

@EventHandler
fun EntityMoveEvent.entityMove() {
if (!hasExplicitlyChangedPosition()) return
if (entity.getPassengersRecursive().isEmpty()) return
entity.getPassengersRecursive().filterIsInstance<Player>()
.filter { rider -> rider.hasPermission(Permissions.ADMIN_PERMISSION) && rider.canMoveSections }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down

0 comments on commit 40b5686

Please sign in to comment.