diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..fd88ec96 --- /dev/null +++ b/.gitignore @@ -0,0 +1,31 @@ +# Eclipse stuff +/.classpath +/.project +/.settings + +# netbeans +/nbproject + +# we use maven! +/build.xml + +# maven +/target + +# vim +.*.sw[a-p] + +# various other potential build files +/build +/bin +/dist +/manifest.mf + +# Mac filesystem dust +/.DS_Store + +# intellij +*.iml +*.ipr +*.iws +.idea/ \ No newline at end of file diff --git a/plugin.yml b/plugin.yml index c70c49f2..97dd78b7 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,9 +1,12 @@ name: NoCheat +version: ${project.version} +description: ${project.description} author: Evenprime +website: ${project.url} main: cc.co.evenprime.bukkit.nocheat.NoCheat -version: 2.16c + commands: nocheat: diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..5be243e5 --- /dev/null +++ b/pom.xml @@ -0,0 +1,84 @@ + + 4.0.0 + NoCheat + NoCheat + 2.16c + jar + NoCheat + + UTF-8 + + + + bukkit-plugins + http://repo.bukkit.org/artifactory/plugins-release + + + + + org.bukkit + craftbukkit + 1.8.1-R5-SNAPSHOT + + + + + bukkit-repo + + true + + + true + + http://repo.bukkit.org/artifactory/repo + + + Detect and Fight the exploitation of various Flaws/Bugs in Minecraft. + http://dev.bukkit.org/server-mods/nocheat + + scm:git:https://github.com/Evenprime/NoCheat.git + scm:git:https://github.com/Evenprime/NoCheat.git + https://github.com/Evenprime/NoCheat + + + ${basedir}/src + + + . + true + . + + plugin.yml + README.txt + LICENSE.txt + + + + clean install + + + + org.apache.maven.plugins + maven-jar-plugin + 2.1 + + + false + + NoCheat + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + 1.6 + 1.6 + + + + + + \ No newline at end of file diff --git a/src/cc/co/evenprime/bukkit/nocheat/NoCheatPlayer.java b/src/cc/co/evenprime/bukkit/nocheat/NoCheatPlayer.java index 0e72e0dd..5c75e072 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/NoCheatPlayer.java +++ b/src/cc/co/evenprime/bukkit/nocheat/NoCheatPlayer.java @@ -8,7 +8,7 @@ import cc.co.evenprime.bukkit.nocheat.data.BaseData; public interface NoCheatPlayer { public boolean hasPermission(String permission); - + public String getName(); public Player getPlayer(); @@ -16,11 +16,11 @@ public interface NoCheatPlayer { public BaseData getData(); public boolean isSprinting(); - + public int getTicksLived(); - + public void increaseAge(int ticks); - + public ConfigurationCache getConfiguration(); public float getSpeedAmplifier(); diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/ChatCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/ChatCheck.java index 6d07ee96..39428692 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/ChatCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/ChatCheck.java @@ -1,6 +1,5 @@ package cc.co.evenprime.bukkit.nocheat.checks; - import cc.co.evenprime.bukkit.nocheat.NoCheat; import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer; import cc.co.evenprime.bukkit.nocheat.actions.types.ActionWithParameters.WildCard; diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/DirectionCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/DirectionCheck.java index 4627f35c..7423206d 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/DirectionCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/DirectionCheck.java @@ -82,7 +82,7 @@ public class DirectionCheck extends BlockBreakCheck { switch (wildcard) { case VIOLATIONS: - return String.format(Locale.US, "%d", (int)player.getData().blockbreak.directionVL); + return String.format(Locale.US, "%d", (int) player.getData().blockbreak.directionVL); default: return super.getParameter(wildcard, player); diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/NoswingCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/NoswingCheck.java index a12a2bb3..63e43210 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/NoswingCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/NoswingCheck.java @@ -36,13 +36,13 @@ public class NoswingCheck extends BlockBreakCheck { public boolean isEnabled(CCBlockBreak cc) { return cc.noswingCheck; } - + public String getParameter(WildCard wildcard, NoCheatPlayer player) { switch (wildcard) { case VIOLATIONS: - return String.format(Locale.US, "%d", (int)player.getData().blockbreak.noswingVL); + return String.format(Locale.US, "%d", (int) player.getData().blockbreak.noswingVL); default: return super.getParameter(wildcard, player); diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/ReachCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/ReachCheck.java index 5817d6f2..22e725a2 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/ReachCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/ReachCheck.java @@ -55,7 +55,7 @@ public class ReachCheck extends BlockBreakCheck { switch (wildcard) { case VIOLATIONS: - return String.format(Locale.US, "%d", (int)player.getData().blockbreak.reachVL); + return String.format(Locale.US, "%d", (int) player.getData().blockbreak.reachVL); case REACHDISTANCE: return String.format(Locale.US, "%.2f", player.getData().blockbreak.reachDistance); diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/DirectionCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/DirectionCheck.java index 76b0c09f..e98eed8f 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/DirectionCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/DirectionCheck.java @@ -96,7 +96,7 @@ public class DirectionCheck extends BlockPlaceCheck { switch (wildcard) { case VIOLATIONS: - return String.format(Locale.US, "%d", (int)player.getData().blockplace.directionVL); + return String.format(Locale.US, "%d", (int) player.getData().blockplace.directionVL); default: return super.getParameter(wildcard, player); diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/ReachCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/ReachCheck.java index 730a8ce0..514db6cb 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/ReachCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/ReachCheck.java @@ -56,7 +56,7 @@ public class ReachCheck extends BlockPlaceCheck { switch (wildcard) { case VIOLATIONS: - return String.format(Locale.US, "%d", (int)player.getData().blockplace.reachVL); + return String.format(Locale.US, "%d", (int) player.getData().blockplace.reachVL); case REACHDISTANCE: return String.format(Locale.US, "%.2f", player.getData().blockplace.reachdistance); diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/fight/DirectionCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/fight/DirectionCheck.java index 8b0dcffd..7e300c77 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/fight/DirectionCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/fight/DirectionCheck.java @@ -77,7 +77,7 @@ public class DirectionCheck extends FightCheck { switch (wildcard) { case VIOLATIONS: - return String.format(Locale.US, "%d", (int)player.getData().fight.directionVL); + return String.format(Locale.US, "%d", (int) player.getData().fight.directionVL); default: return super.getParameter(wildcard, player); } diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/fight/NoswingCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/fight/NoswingCheck.java index 4c272f73..f3d27f91 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/fight/NoswingCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/fight/NoswingCheck.java @@ -19,7 +19,7 @@ public class NoswingCheck extends FightCheck { public boolean check(NoCheatPlayer player, FightData data, CCFight cc) { boolean cancel = false; - + // did he swing his arm before? if(data.armswung) { data.armswung = false; @@ -37,13 +37,13 @@ public class NoswingCheck extends FightCheck { public boolean isEnabled(CCFight cc) { return cc.noswingCheck; } - + public String getParameter(WildCard wildcard, NoCheatPlayer player) { switch (wildcard) { case VIOLATIONS: - return String.format(Locale.US, "%d", (int)player.getData().fight.noswingVL); + return String.format(Locale.US, "%d", (int) player.getData().fight.noswingVL); default: return super.getParameter(wildcard, player); } diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/fight/SelfhitCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/fight/SelfhitCheck.java index 8c289045..f2b1bc7e 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/fight/SelfhitCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/fight/SelfhitCheck.java @@ -42,7 +42,7 @@ public class SelfhitCheck extends FightCheck { switch (wildcard) { case VIOLATIONS: - return String.format(Locale.US, "%d", (int)player.getData().fight.selfhitVL); + return String.format(Locale.US, "%d", (int) player.getData().fight.selfhitVL); default: return super.getParameter(wildcard, player); } diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/FlyingCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/FlyingCheck.java index a548bd59..a268ee48 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/FlyingCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/FlyingCheck.java @@ -47,10 +47,9 @@ public class FlyingCheck extends MovingCheck { // In case of creative gamemode, give at least 0.60 speed limit // horizontal double speedLimitHorizontal = player.isCreative() ? Math.max(creativeSpeed, ccmoving.flyingSpeedLimitHorizontal) : ccmoving.flyingSpeedLimitHorizontal; - speedLimitHorizontal *= player.getSpeedAmplifier(); - + result += Math.max(0.0D, horizontalDistance - moving.horizFreedom - speedLimitHorizontal); boolean sprinting = player.isSprinting(); @@ -99,13 +98,13 @@ public class FlyingCheck extends MovingCheck { public boolean isEnabled(CCMoving moving) { return moving.allowFlying && moving.runflyCheck; } - + public String getParameter(WildCard wildcard, NoCheatPlayer player) { switch (wildcard) { case VIOLATIONS: - return String.format(Locale.US, "%d", (int)player.getData().moving.runflyVL); + return String.format(Locale.US, "%d", (int) player.getData().moving.runflyVL); default: return super.getParameter(wildcard, player); } diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/MorePacketsCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/MorePacketsCheck.java index 5781c514..e7f34e82 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/MorePacketsCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/MorePacketsCheck.java @@ -74,7 +74,7 @@ public class MorePacketsCheck extends MovingCheck { // went over the limit if(!plugin.skipCheck() && packetsAboveLimit > 0) { data.morePacketsVL += packetsAboveLimit; - + data.packets = packetsAboveLimit; final boolean cancel = executeActions(player, cc.morePacketsActions.getActions(data.morePacketsVL)); @@ -103,13 +103,13 @@ public class MorePacketsCheck extends MovingCheck { public boolean isEnabled(CCMoving moving) { return moving.morePacketsCheck; } - + @Override public String getParameter(WildCard wildcard, NoCheatPlayer player) { switch (wildcard) { case VIOLATIONS: - return String.format(Locale.US, "%d", (int)player.getData().moving.morePacketsVL); + return String.format(Locale.US, "%d", (int) player.getData().moving.morePacketsVL); case PACKETS: return String.valueOf(player.getData().moving.packets); default: diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/NoFallCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/NoFallCheck.java index 12e052eb..8e23a67b 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/NoFallCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/NoFallCheck.java @@ -106,7 +106,7 @@ public class NoFallCheck extends MovingCheck { switch (wildcard) { case VIOLATIONS: - return String.format(Locale.US, "%d", (int)player.getData().moving.nofallVL); + return String.format(Locale.US, "%d", (int) player.getData().moving.nofallVL); case FALLDISTANCE: return String.format(Locale.US, "%.2f", player.getData().moving.fallDistance); default: diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/timed/GodmodeCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/timed/GodmodeCheck.java index b176564c..a0bef5d2 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/timed/GodmodeCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/timed/GodmodeCheck.java @@ -37,7 +37,7 @@ public class GodmodeCheck extends TimedCheck { boolean cancel = false; // How far behind is the player with his ticks - int behind = Math.min(10, (data.ticksLived + cc.tickTime) - ticksLived); + int behind = Math.min(10, (data.ticksLived + cc.tickTime) - ticksLived); // difference should be >= tickTime for perfect synchronization if(behind <= 1) { // player as fast as expected, give him credit for that @@ -45,7 +45,7 @@ public class GodmodeCheck extends TimedCheck { // Reduce violation level over time data.godmodeVL -= cc.tickTime / 2.0; - } else if(behind <= (cc.tickTime / 2)+1) { + } else if(behind <= (cc.tickTime / 2) + 1) { // close enough, let it pass data.ticksBehind -= cc.tickTime / 4; // Reduce violation level over time @@ -63,16 +63,14 @@ public class GodmodeCheck extends TimedCheck { cancel = executeActions(player, cc.godmodeActions.getActions(data.godmodeVL)); - if(cancel) { // Catch up for at least some of the ticks try { player.increaseAge(cc.tickTime); - } - catch(Exception e) { + } catch(Exception e) { e.printStackTrace(); } - + // Reduce the time the player is behind accordingly data.ticksBehind -= cc.tickTime; } @@ -82,7 +80,7 @@ public class GodmodeCheck extends TimedCheck { if(data.ticksBehind < 0) { data.ticksBehind = 0; } - + if(data.godmodeVL < 0) { data.godmodeVL = 0; } @@ -104,7 +102,7 @@ public class GodmodeCheck extends TimedCheck { switch (wildcard) { case VIOLATIONS: - return String.format(Locale.US, "%d", (int)player.getData().timed.godmodeVL); + return String.format(Locale.US, "%d", (int) player.getData().timed.godmodeVL); default: return super.getParameter(wildcard, player); } diff --git a/src/cc/co/evenprime/bukkit/nocheat/config/Configuration.java b/src/cc/co/evenprime/bukkit/nocheat/config/Configuration.java index 170adc4e..269beb66 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/config/Configuration.java +++ b/src/cc/co/evenprime/bukkit/nocheat/config/Configuration.java @@ -31,7 +31,7 @@ public abstract class Configuration { private final static OptionNode DEBUG = new OptionNode("debug", ROOT, DataType.PARENT); public final static OptionNode DEBUG_SHOWACTIVECHECKS = new OptionNode("showactivechecks", DEBUG, DataType.BOOLEAN); public static final OptionNode DEBUG_COMPATIBILITY = new OptionNode("compatibility", DEBUG, DataType.BOOLEAN); - + private final static OptionNode MOVING = new OptionNode("moving", ROOT, DataType.PARENT); public final static OptionNode MOVING_CHECK = new OptionNode("check", MOVING, DataType.BOOLEAN); public final static OptionNode MOVING_IDENTIFYCREATIVEMODE = new OptionNode("identifycreativemode", MOVING, DataType.BOOLEAN); diff --git a/src/cc/co/evenprime/bukkit/nocheat/config/FlatFileAction.java b/src/cc/co/evenprime/bukkit/nocheat/config/FlatFileAction.java index 9c7b8dc3..1982572f 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/config/FlatFileAction.java +++ b/src/cc/co/evenprime/bukkit/nocheat/config/FlatFileAction.java @@ -48,7 +48,7 @@ public class FlatFileAction { } catch(IOException e) { e.printStackTrace(); } - + for(Action a : actions) { mapper.addAction(a); } @@ -62,50 +62,45 @@ public class FlatFileAction { // four pieces is the minimum we need, no matter what it is if(parts.length < 4) { - throw new IllegalArgumentException("The line "+line+" of the file "+file.getName()+" is malformed. It has not enough parts."); + throw new IllegalArgumentException("The line " + line + " of the file " + file.getName() + " is malformed. It has not enough parts."); } - + String type = parts[0]; String name = parts[1]; int delay = 0; try { delay = Integer.parseInt(parts[2]); + } catch(Exception e) { + throw new IllegalArgumentException("Couldn't parse third parameter of action " + name + " from file " + file.getName() + ". It is " + parts[2] + " but should be a number."); } - catch(Exception e) { - throw new IllegalArgumentException("Couldn't parse third parameter of action "+name+" from file "+file.getName()+". It is "+parts[2]+" but should be a number."); - } - + int repeat = 0; try { repeat = Integer.parseInt(parts[3]); + } catch(Exception e) { + throw new IllegalArgumentException("Couldn't parse fourth parameter of action " + name + " from file " + file.getName() + ". It is " + parts[2] + " but should be a number."); } - catch(Exception e) { - throw new IllegalArgumentException("Couldn't parse fourth parameter of action "+name+" from file "+file.getName()+". It is "+parts[2]+" but should be a number."); - } - + if(type.equalsIgnoreCase("log")) { // A log action, it seems if(parts.length < 5) { - throw new IllegalArgumentException("Missing fifth parameter of action "+name+" from file "+file.getName()+"."); + throw new IllegalArgumentException("Missing fifth parameter of action " + name + " from file " + file.getName() + "."); } - + return readLogAction(name, delay, repeat, parts[4]); - } - else if(type.equalsIgnoreCase("consolecommand")) { + } else if(type.equalsIgnoreCase("consolecommand")) { // A consolecommand action, it seems if(parts.length < 5) { - throw new IllegalArgumentException("Missing fifth parameter of action "+name+" from file "+file.getName()+"."); + throw new IllegalArgumentException("Missing fifth parameter of action " + name + " from file " + file.getName() + "."); } - + return new ConsolecommandAction(name, delay, repeat, parts[4]); - } - else if(type.equalsIgnoreCase("special")) { + } else if(type.equalsIgnoreCase("special")) { // A "special" actions, it seems return new SpecialAction(name, delay, repeat); - } - else { - throw new IllegalArgumentException("Unknown action type "+type+ " of action with name "+name+"."); + } else { + throw new IllegalArgumentException("Unknown action type " + type + " of action with name " + name + "."); } } @@ -113,19 +108,18 @@ public class FlatFileAction { private Action readLogAction(String name, int delay, int repeat, String lastPart) { String[] rest = lastPart.split("\\s+", 2); - + if(rest.length < 2) { - throw new IllegalArgumentException("Missing sixth parameter of action "+name+" from file "+file.getName()+"."); + throw new IllegalArgumentException("Missing sixth parameter of action " + name + " from file " + file.getName() + "."); } - + LogLevel level; try { level = LogLevel.getLogLevelFromString(rest[0]); + } catch(IllegalArgumentException e) { + throw new IllegalArgumentException("Illegal fifth parameter of action " + name + ". " + e.getMessage()); } - catch(IllegalArgumentException e) { - throw new IllegalArgumentException("Illegal fifth parameter of action "+name+". "+e.getMessage()); - } - + return new LogAction(name, delay, repeat, level, rest[1]); } diff --git a/src/cc/co/evenprime/bukkit/nocheat/config/cache/CCDebug.java b/src/cc/co/evenprime/bukkit/nocheat/config/cache/CCDebug.java index a2e4063f..469cf1f3 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/config/cache/CCDebug.java +++ b/src/cc/co/evenprime/bukkit/nocheat/config/cache/CCDebug.java @@ -6,7 +6,6 @@ public class CCDebug { public final boolean showchecks; public final boolean overrideIdiocy; - public CCDebug(Configuration data) { diff --git a/src/cc/co/evenprime/bukkit/nocheat/config/cache/CCMoving.java b/src/cc/co/evenprime/bukkit/nocheat/config/cache/CCMoving.java index c5fff1a1..0f80dc28 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/config/cache/CCMoving.java +++ b/src/cc/co/evenprime/bukkit/nocheat/config/cache/CCMoving.java @@ -38,12 +38,12 @@ public class CCMoving { check = data.getBoolean(Configuration.MOVING_CHECK); identifyCreativeMode = data.getBoolean(Configuration.MOVING_IDENTIFYCREATIVEMODE); - + runflyCheck = data.getBoolean(Configuration.MOVING_RUNFLY_CHECK); walkingSpeedLimit = ((double) data.getInteger(Configuration.MOVING_RUNFLY_WALKINGSPEEDLIMIT)) / 100D; sprintingSpeedLimit = ((double) data.getInteger(Configuration.MOVING_RUNFLY_SPRINTINGSPEEDLIMIT)) / 100D; jumpheight = ((double) data.getInteger(Configuration.MOVING_RUNFLY_JUMPHEIGHT)) / 100D; - actions = data.getActionList(Configuration.MOVING_RUNFLY_ACTIONS); + actions = data.getActionList(Configuration.MOVING_RUNFLY_ACTIONS); swimmingCheck = data.getBoolean(Configuration.MOVING_RUNFLY_CHECKSWIMMING); swimmingSpeedLimit = ((double) data.getInteger(Configuration.MOVING_RUNFLY_SWIMMINGSPEEDLIMIT)) / 100D; diff --git a/src/cc/co/evenprime/bukkit/nocheat/data/BlockBreakData.java b/src/cc/co/evenprime/bukkit/nocheat/data/BlockBreakData.java index 31abcd0e..4b379eae 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/data/BlockBreakData.java +++ b/src/cc/co/evenprime/bukkit/nocheat/data/BlockBreakData.java @@ -17,7 +17,7 @@ public class BlockBreakData extends Data { public double noswingVL = 0.0D; public double reachDistance; public boolean armswung = true; - + @Override public void clearCriticalData() { instaBrokenBlockLocation.reset(); diff --git a/src/cc/co/evenprime/bukkit/nocheat/data/PlayerManager.java b/src/cc/co/evenprime/bukkit/nocheat/data/PlayerManager.java index 02c8cad3..256cf58c 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/data/PlayerManager.java +++ b/src/cc/co/evenprime/bukkit/nocheat/data/PlayerManager.java @@ -68,7 +68,7 @@ public class PlayerManager { public void cleanDataMap() { long time = System.currentTimeMillis(); List removals = new ArrayList(5); - + for(Entry e : this.players.entrySet()) { if(e.getValue().shouldBeRemoved(time)) { removals.add(e.getKey()); diff --git a/src/cc/co/evenprime/bukkit/nocheat/data/PreciseLocation.java b/src/cc/co/evenprime/bukkit/nocheat/data/PreciseLocation.java index 3d49b89b..8caec4e9 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/data/PreciseLocation.java +++ b/src/cc/co/evenprime/bukkit/nocheat/data/PreciseLocation.java @@ -3,9 +3,10 @@ package cc.co.evenprime.bukkit.nocheat.data; import org.bukkit.Location; /** - * A class to store x,y,z triple data, instead of using bukkits Location objects, + * A class to store x,y,z triple data, instead of using bukkits Location + * objects, * which can't be easily recycled - * + * */ public final class PreciseLocation { @@ -32,6 +33,7 @@ public final class PreciseLocation { public final boolean isSet() { return x != Double.MAX_VALUE; } + public final void reset() { x = Double.MAX_VALUE; y = Double.MAX_VALUE; diff --git a/src/cc/co/evenprime/bukkit/nocheat/debug/ActiveCheckPrinter.java b/src/cc/co/evenprime/bukkit/nocheat/debug/ActiveCheckPrinter.java index b4719198..1292fa8b 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/debug/ActiveCheckPrinter.java +++ b/src/cc/co/evenprime/bukkit/nocheat/debug/ActiveCheckPrinter.java @@ -9,11 +9,10 @@ import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache; import cc.co.evenprime.bukkit.nocheat.events.EventManager; import cc.co.evenprime.bukkit.nocheat.log.LogLevel; - public class ActiveCheckPrinter { public static void printActiveChecks(NoCheat plugin, List eventManagers) { - + boolean introPrinted = false; String intro = "[NoCheat] Active Checks: "; diff --git a/src/cc/co/evenprime/bukkit/nocheat/debug/Performance.java b/src/cc/co/evenprime/bukkit/nocheat/debug/Performance.java index 360fae5f..13ae34b5 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/debug/Performance.java +++ b/src/cc/co/evenprime/bukkit/nocheat/debug/Performance.java @@ -1,46 +1,43 @@ package cc.co.evenprime.bukkit.nocheat.debug; - public class Performance { - private long totalTime = 0; - private long counter = 1; // start with 1 to avoid DIV/0 errors - private final boolean enabled; - - private static final long NANO = 1; - private static final long MICRO = NANO * 1000; - private static final long MILLI = MICRO * 1000; - private static final long SECOND = MILLI * 1000; - private static final long MINUTE = SECOND * 60; - - + private long totalTime = 0; + private long counter = 1; // start with 1 to avoid + // DIV/0 errors + private final boolean enabled; + + private static final long NANO = 1; + private static final long MICRO = NANO * 1000; + private static final long MILLI = MICRO * 1000; + private static final long SECOND = MILLI * 1000; + private static final long MINUTE = SECOND * 60; + public Performance(boolean enabled) { this.enabled = enabled; } - + public void addTime(long nanoTime) { counter++; this.totalTime += nanoTime; } - + public long getTotalTime() { return this.totalTime; } - + public long getRelativeTime() { return this.totalTime / this.counter; } - - + public long getCounter() { return this.counter; } - - + public boolean isEnabled() { return enabled; } - + private static String getAppropriateUnit(long timeInNanoseconds) { // more than 10 minutes @@ -83,7 +80,7 @@ public class Performance { return timeInNanoseconds / NANO; } } - + public static String toString(long timeInNanoseconds) { return convertToAppropriateUnit(timeInNanoseconds) + " " + getAppropriateUnit(timeInNanoseconds); } diff --git a/src/cc/co/evenprime/bukkit/nocheat/debug/PerformanceManager.java b/src/cc/co/evenprime/bukkit/nocheat/debug/PerformanceManager.java index 19d4d6a2..b587b3a7 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/debug/PerformanceManager.java +++ b/src/cc/co/evenprime/bukkit/nocheat/debug/PerformanceManager.java @@ -9,8 +9,6 @@ public class PerformanceManager { BLOCKBREAK, BLOCKDAMAGE, BLOCKPLACE, CHAT, MOVING, VELOCITY, FIGHT, TIMED } - - private final Map map; public PerformanceManager() { diff --git a/src/cc/co/evenprime/bukkit/nocheat/events/BlockBreakEventManager.java b/src/cc/co/evenprime/bukkit/nocheat/events/BlockBreakEventManager.java index 7186fdbf..e55edc3c 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/events/BlockBreakEventManager.java +++ b/src/cc/co/evenprime/bukkit/nocheat/events/BlockBreakEventManager.java @@ -87,7 +87,7 @@ public class BlockBreakEventManager extends EventManager { // direction check that are insta-breaks data.instaBrokenBlockLocation.set(event.getBlock()); } - + @Override protected void handlePlayerAnimationEvent(final PlayerAnimationEvent event, final Priority priority) { plugin.getPlayer(event.getPlayer()).getData().blockbreak.armswung = true; diff --git a/src/cc/co/evenprime/bukkit/nocheat/events/ChatEventManager.java b/src/cc/co/evenprime/bukkit/nocheat/events/ChatEventManager.java index c78e5f08..24a5230e 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/events/ChatEventManager.java +++ b/src/cc/co/evenprime/bukkit/nocheat/events/ChatEventManager.java @@ -46,7 +46,7 @@ public class ChatEventManager extends EventManager { final NoCheatPlayer player = plugin.getPlayer(event.getPlayer()); final CCChat cc = player.getConfiguration().chat; - + if(!cc.check || player.hasPermission(Permissions.CHAT)) { return; } diff --git a/src/cc/co/evenprime/bukkit/nocheat/events/EventManager.java b/src/cc/co/evenprime/bukkit/nocheat/events/EventManager.java index 083f7251..1b4a3152 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/events/EventManager.java +++ b/src/cc/co/evenprime/bukkit/nocheat/events/EventManager.java @@ -225,7 +225,7 @@ public abstract class EventManager { m.handlePlayerAnimationEvent(event, priority); } } - + @Override public void onPlayerToggleSprint(final PlayerToggleSprintEvent event) { if(ignoreCancelledEvents && event.isCancelled()) diff --git a/src/cc/co/evenprime/bukkit/nocheat/events/FightEventManager.java b/src/cc/co/evenprime/bukkit/nocheat/events/FightEventManager.java index 91adfb53..9f54aa5e 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/events/FightEventManager.java +++ b/src/cc/co/evenprime/bukkit/nocheat/events/FightEventManager.java @@ -70,7 +70,7 @@ public class FightEventManager extends EventManager { if(cancelled) event.setCancelled(cancelled); } - + @Override protected void handlePlayerAnimationEvent(final PlayerAnimationEvent event, final Priority priority) { plugin.getPlayer(event.getPlayer()).getData().fight.armswung = true; diff --git a/src/cc/co/evenprime/bukkit/nocheat/events/MovingEventManager.java b/src/cc/co/evenprime/bukkit/nocheat/events/MovingEventManager.java index 81ec00ea..fb86ae0f 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/events/MovingEventManager.java +++ b/src/cc/co/evenprime/bukkit/nocheat/events/MovingEventManager.java @@ -89,7 +89,7 @@ public class MovingEventManager extends EventManager { if(event.getPlayer().isInsideVehicle()) { return; } - + // Get the world-specific configuration that applies here final NoCheatPlayer player = plugin.getPlayer(event.getPlayer()); final CCMoving cc = player.getConfiguration().moving; diff --git a/src/cc/co/evenprime/bukkit/nocheat/events/TimedEventManager.java b/src/cc/co/evenprime/bukkit/nocheat/events/TimedEventManager.java index dedc658c..13483fe0 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/events/TimedEventManager.java +++ b/src/cc/co/evenprime/bukkit/nocheat/events/TimedEventManager.java @@ -80,7 +80,7 @@ public class TimedEventManager extends EventManager { if(performanceCheck) nanoTimeStart = System.nanoTime(); - handleEvent(plugin.getPlayer((Player)p.getBukkitEntity())); + handleEvent(plugin.getPlayer((Player) p.getBukkitEntity())); // store performance time if(performanceCheck) diff --git a/src/cc/co/evenprime/bukkit/nocheat/log/Colors.java b/src/cc/co/evenprime/bukkit/nocheat/log/Colors.java index 2967eda9..bb342bdc 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/log/Colors.java +++ b/src/cc/co/evenprime/bukkit/nocheat/log/Colors.java @@ -4,16 +4,16 @@ import org.bukkit.ChatColor; /** * Somehow manage color codes in NoCheat - * + * */ public class Colors { public static String replaceColors(String text) { - + for(ChatColor c : ChatColor.values()) { text = text.replace("&" + Integer.toHexString(c.getCode()), c.toString()); } - + return text; } }