diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MorePackets.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MorePackets.java index f3f84e7d..38cbb92b 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MorePackets.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MorePackets.java @@ -69,7 +69,7 @@ public class MorePackets extends Check { if (data.morePacketsSetback == null){ // TODO: Check if other set-back is appropriate or if to set on other events. - if (data.setBack != null) data.morePacketsSetback = data.setBack.clone(); + if (data.setBack != null) data.morePacketsSetback = data.getSetBack(to); else data.morePacketsSetback = from.getLocation(); } diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.java index e995f951..9a905e14 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.java @@ -237,7 +237,9 @@ public class MovingData extends ACheckData { * @param loc */ public void setSetBack(final PlayerLocation loc){ - if (setBack == null) setBack = loc.getLocation(); + if (setBack == null){ + setBack = loc.getLocation(); + } else{ setBack.setWorld(loc.getWorld()); setBack.setX(loc.getX()); @@ -253,7 +255,9 @@ public class MovingData extends ACheckData { * @param loc */ public void setSetBack(final Location loc){ - if (setBack == null) setBack = loc.clone(); + if (setBack == null){ + setBack = new Location(loc.getWorld(), loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); + } else{ setBack.setWorld(loc.getWorld()); setBack.setX(loc.getX()); @@ -270,12 +274,11 @@ public class MovingData extends ACheckData { * @return */ public Location getSetBack(final Location ref){ - if (setBack == null) return ref.clone(); + if (setBack == null){ + return new Location(ref.getWorld(), ref.getX(), ref.getY(), ref.getZ(), ref.getYaw(), ref.getPitch()); + } else{ - final Location loc = setBack.clone(); - loc.setYaw(ref.getYaw()); - loc.setPitch(ref.getPitch()); - return loc; + return new Location(setBack.getWorld(), setBack.getX(), setBack.getY(), setBack.getZ(), ref.getYaw(), ref.getPitch()); } } @@ -287,10 +290,7 @@ public class MovingData extends ACheckData { public Location getSetBack(final PlayerLocation ref) { if (setBack == null) return ref.getLocation(); else{ - final Location loc = setBack.clone(); - loc.setYaw(ref.getYaw()); - loc.setPitch(ref.getPitch()); - return loc; + return new Location(setBack.getWorld(), setBack.getX(), setBack.getY(), setBack.getZ(), ref.getYaw(), ref.getPitch()); } } } diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java index d9c9cc17..57eb0810 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java @@ -256,7 +256,7 @@ public class MovingListener extends CheckListener{ noFall.checkDamage(player, data, y); } // Teleport. - data.teleported = target.clone(); + data.teleported = new Location(target.getWorld(), target.getX(), target.getY(), target.getZ(), target.getYaw(), target.getPitch()); player.teleport(target, TeleportCause.PLUGIN);// TODO: schedule / other measures ? } } @@ -561,7 +561,7 @@ public class MovingListener extends CheckListener{ // Fix a common mistake that other developers make (cancelling move events is crazy, rather set the target // location to the from location). event.setCancelled(false); - event.setTo(event.getFrom().clone()); + event.setTo(event.getFrom()); // TODO: revise this (old!) strategy, cancelled events just teleport to from, basically. } /** @@ -570,6 +570,7 @@ public class MovingListener extends CheckListener{ */ @EventHandler(priority=EventPriority.MONITOR, ignoreCancelled = false) public final void onPlayerMoveMonitor(final PlayerMoveEvent event){ + // TODO: revise: cancelled events. final long now = System.currentTimeMillis(); final Player player = event.getPlayer(); if (player.isDead()) return; diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/Passable.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/Passable.java index b2a27abf..610f5471 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/Passable.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/Passable.java @@ -61,7 +61,7 @@ public class Passable extends Check { } // Prefer the set-back location from the data. - if (data.setBack != null && BlockProperties.isPassable(from.getBlockCache(), data.setBack)) loc = data.setBack.clone(); + if (data.setBack != null && BlockProperties.isPassable(from.getBlockCache(), data.setBack)) loc = data.getSetBack(to); // TODO: set data.set-back ? or something: still some aji here.