From 66d801b1f8c63ec42cecc183a6021d8d9f332f37 Mon Sep 17 00:00:00 2001 From: Evenprime Date: Fri, 25 Feb 2011 17:48:28 +0100 Subject: [PATCH] Configurable unpunished minor moves for movingCheck --- src/cc/co/evenprime/bukkit/nocheat/MovingCheck.java | 13 +++++-------- .../bukkit/nocheat/NoCheatConfiguration.java | 4 ++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/cc/co/evenprime/bukkit/nocheat/MovingCheck.java b/src/cc/co/evenprime/bukkit/nocheat/MovingCheck.java index 5253a26d..475a3d60 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/MovingCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/MovingCheck.java @@ -23,10 +23,7 @@ public class MovingCheck { private static final int NORMAL = 2; private static final int MINOR = 1; private static final int NONE = 0; - - // Every player gets freebee moves to prevent them from getting stuck to easy - private static final int freeIllegalMoves = 1; - + // Block types that may be treated specially private enum BlockType { SOLID, NONSOLID, LADDER, LIQUID, UNKNOWN; @@ -271,7 +268,7 @@ public class MovingCheck { } // Start logging only after the freebee illegal moves have all been used - if(data.movingMinorViolationsInARow == freeIllegalMoves + 1) { + if(data.movingMinorViolationsInARow == NoCheatConfiguration.movingFreeMoves + 1) { NoCheatPlugin.logMinor("NoCheatPlugin: Moving violation: "+event.getPlayer().getName()+" from " + String.format("(%.5f, %.5f, %.5f) to (%.5f, %.5f, %.5f)", event.getFrom().getX(), event.getFrom().getY(), event.getFrom().getZ(), event.getTo().getX(), event.getTo().getY(), event.getTo().getZ())); } @@ -279,11 +276,11 @@ public class MovingCheck { data.movingMinorViolationsInARow++; // 16 minor violations in a row count as one normal violation - if(data.movingMinorViolationsInARow % 16 == 0) { + if(data.movingMinorViolationsInARow % (NoCheatConfiguration.movingFreeMoves+10) == 0) { normalViolation(data, event); } // Each time the freebee moves are all used up, we may reset the player to his old location - else if(data.movingMinorViolationsInARow % (freeIllegalMoves + 1) == 0) { + else if(data.movingMinorViolationsInARow % (NoCheatConfiguration.movingFreeMoves + 1) == 0) { resetPlayer(data, event); } } @@ -319,7 +316,7 @@ public class MovingCheck { NoCheatPlugin.logNormal("NoCheatPlugin: Moving violation stopped: "+event.getPlayer().getName()+ " total Events: "+ data.movingNormalViolationsInARow); data.movingNormalViolationsInARow = 0; } - else if(data.movingMinorViolationsInARow > freeIllegalMoves) { + else if(data.movingMinorViolationsInARow > NoCheatConfiguration.movingFreeMoves) { NoCheatPlugin.logMinor("NoCheatPlugin: Moving violation stopped: "+event.getPlayer().getName()+ " total Events: "+ data.movingMinorViolationsInARow); data.movingMinorViolationsInARow = 0; } diff --git a/src/cc/co/evenprime/bukkit/nocheat/NoCheatConfiguration.java b/src/cc/co/evenprime/bukkit/nocheat/NoCheatConfiguration.java index be7689e6..f4ab9733 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/NoCheatConfiguration.java +++ b/src/cc/co/evenprime/bukkit/nocheat/NoCheatConfiguration.java @@ -39,6 +39,8 @@ public class NoCheatConfiguration { public static double movingDistanceMed = 1.0D; public static double movingDistanceHigh = 5.0D; + public static int movingFreeMoves = 2; + // Should moving violations be punished? public static boolean movingLogOnly = false; @@ -101,6 +103,7 @@ public class NoCheatConfiguration { speedhackHigh = c.getInt("speedhack.limits.high", 120); movingLogOnly = c.getBoolean("moving.logonly", false); + movingFreeMoves = c.getInt("moving.freemoves", 2); } /** @@ -150,6 +153,7 @@ public class NoCheatConfiguration { w.write(" high: 120"); w.newLine(); w.write("moving:"); w.newLine(); w.write(" logonly: false"); w.newLine(); + w.write(" freemoves: 2"); w.newLine(); w.flush(); w.close(); } catch (IOException e) { // TODO Auto-generated catch block