From 5df7af20b35d091220352e3d7fcf2ceeae158d88 Mon Sep 17 00:00:00 2001 From: Evenprime Date: Wed, 9 Mar 2011 18:32:42 +0100 Subject: [PATCH] Final changes to moving-check + version bump --- plugin.yml | 2 +- .../bukkit/nocheat/checks/MovingCheck.java | 26 ++++++++++++------- .../listeners/NoCheatEntityListener.java | 6 ++--- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/plugin.yml b/plugin.yml index a2dbf84b..fbeb15ec 100644 --- a/plugin.yml +++ b/plugin.yml @@ -3,7 +3,7 @@ name: NoCheatPlugin author: Evenprime main: cc.co.evenprime.bukkit.nocheat.NoCheatPlugin -version: 0.6.4c +version: 0.6.5 commands: nocheat: diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java index 02d6e855..64388fe7 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java @@ -169,7 +169,7 @@ public class MovingCheck { // the array each contains [lowerX, higherX, Y, lowerZ, higherZ] int fromValues[] = {lowerBorder(from.getX()), upperBorder(from.getX()), from.getBlockY(), lowerBorder(from.getZ()),upperBorder(from.getZ()) }; int toValues[] = {lowerBorder(to.getX()), upperBorder(to.getX()), to.getBlockY(), lowerBorder(to.getZ()), upperBorder(to.getZ()) }; - + // compare locations to the world to guess if the player is standing on the ground, a half-block or next to a ladder boolean onGroundFrom = playerIsOnGround(from.getWorld(), fromValues, from); boolean onGroundTo = playerIsOnGround(from.getWorld(), toValues, to); @@ -453,19 +453,27 @@ public class MovingCheck { return d > (double)i ? i : i - 1; } - public static int lowerBorder(double d1) { + public static int lowerBorder(double d1) { double floor = Math.floor(d1); - double d4 = (d1 - floor) - magic; - //System.out.println(d4); - return (int) (floor + d4); + double d4 = floor + magic; + + if(d4 <= d1) + d4 = 0; + else + d4 = 1; + + return (int) (floor - d4); } public static int upperBorder(double d1) { double floor = Math.floor(d1); - double d4 = (d1 - floor) - magic2; - //System.out.println(d4); - int tmp = (int) (floor - d4); + double d4 = floor + magic2; - return tmp < floor ? tmp + 2 : (int)floor ; + if(d4 < d1) + d4 = -1; + else + d4 = 0; + + return (int) (floor - d4); } } diff --git a/src/cc/co/evenprime/bukkit/nocheat/listeners/NoCheatEntityListener.java b/src/cc/co/evenprime/bukkit/nocheat/listeners/NoCheatEntityListener.java index 45d2acda..7d318636 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/listeners/NoCheatEntityListener.java +++ b/src/cc/co/evenprime/bukkit/nocheat/listeners/NoCheatEntityListener.java @@ -11,11 +11,9 @@ import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin; public class NoCheatEntityListener extends EntityListener { @Override - public void onEntityDamage(EntityDamageEvent event) { + public void onEntityDamage(EntityDamageEvent event) { - - if(event.getEntity() instanceof Player) { - + if(event.getEntity() instanceof Player) { Player p = (Player)event.getEntity(); NoCheatPlugin.getPlayerData(p).movingJumpPhase = 0;