diff --git a/plugin.yml b/plugin.yml index 671d6518..a9bcd92b 100644 --- a/plugin.yml +++ b/plugin.yml @@ -3,7 +3,7 @@ name: NoCheat author: Evenprime main: cc.co.evenprime.bukkit.nocheat.NoCheat -version: 1.04b +version: 1.04c softdepend: [ Permissions, CraftIRC ] diff --git a/src/cc/co/evenprime/bukkit/nocheat/NoCheat.java b/src/cc/co/evenprime/bukkit/nocheat/NoCheat.java index 49a06c5e..31c1e3df 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/NoCheat.java +++ b/src/cc/co/evenprime/bukkit/nocheat/NoCheat.java @@ -50,7 +50,7 @@ public class NoCheat extends JavaPlugin implements CommandSender { private NoCheatConfiguration config; - private boolean exceptionWithPermissions = false; + private long exceptionWithPermissions = 0; private int cleanUpTaskId = -1; private int serverLagMeasureTaskSetup = -1; @@ -188,7 +188,7 @@ public class NoCheat extends JavaPlugin implements CommandSender { if(serverLagMeasureTaskSetup != -1) return; - Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable() { + serverLagMeasureTaskSetup = Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable() { @Override public void run() { @@ -201,7 +201,7 @@ public class NoCheat extends JavaPlugin implements CommandSender { } private void teardownServerLagMeasureTask() { - if(serverLagMeasureTaskSetup == -1) + if(serverLagMeasureTaskSetup != -1) Bukkit.getServer().getScheduler().cancelTask(serverLagMeasureTaskSetup); } @@ -298,11 +298,11 @@ public class NoCheat extends JavaPlugin implements CommandSender { } } catch(Throwable e) { - if(!this.exceptionWithPermissions) { + if(this.exceptionWithPermissions + 60000 < System.currentTimeMillis()) { // Prevent spam and recursion by definitely doing this only once - this.exceptionWithPermissions = true; + this.exceptionWithPermissions = System.currentTimeMillis(); - String logtext = "Asking Permissions-Plugin if "+player.getName()+" has permission "+PermissionData.permissionNames[permission]+" caused an Exception "+ e.getMessage() + ". Please review your permissions config file. This message is only displayed once, the player is considered to not have that permission from now on. The full stack trace is written into the nocheat logfile."; + String logtext = "Asking Permissions-Plugin if "+player.getName()+" has permission "+PermissionData.permissionNames[permission]+" caused an Exception "+ e.getMessage() + ". Please review your permissions config file. This message is displayed at most once every 60 seconds."; log(Level.SEVERE, logtext); for(StackTraceElement s : e.getStackTrace()) { config.logger.log(Level.SEVERE, s.toString()); diff --git a/src/cc/co/evenprime/bukkit/nocheat/NoCheatData.java b/src/cc/co/evenprime/bukkit/nocheat/NoCheatData.java index 387aa6e2..b3759619 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/NoCheatData.java +++ b/src/cc/co/evenprime/bukkit/nocheat/NoCheatData.java @@ -84,8 +84,9 @@ public class NoCheatData { int id; id = pairs.getValue().airbuild != null ? pairs.getValue().airbuild.summaryTask : -1; - if(id != -1) + if(id != -1) { Bukkit.getServer().getScheduler().cancelTask(id); + } id = pairs.getValue().moving != null ? pairs.getValue().moving.summaryTask : -1; diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java index af751b5f..f6dff22b 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java @@ -1,5 +1,6 @@ package cc.co.evenprime.bukkit.nocheat.checks; +import java.util.Locale; import java.util.logging.Level; import org.bukkit.Bukkit; @@ -507,7 +508,7 @@ public class MovingCheck extends Check { if(a.firstAfter == violations || a.repeat) { if(a instanceof LogAction) { // prepare log message if necessary - String log = String.format(logMessage, player.getName(), from.getWorld().getName(), to.getWorld().getName(), from.getX(), from.getY(), from.getZ(), to.getX(), to.getY(), to.getZ()); + String log = String.format(Locale.US, logMessage, player.getName(), from.getWorld().getName(), to.getWorld().getName(), from.getX(), from.getY(), from.getZ(), to.getX(), to.getY(), to.getZ(), Math.abs(from.getX()-to.getX()),to.getY()-from.getY(), Math.abs(from.getZ()-to.getZ())); plugin.log(((LogAction)a).level, log); diff --git a/src/cc/co/evenprime/bukkit/nocheat/config/NoCheatConfiguration.java b/src/cc/co/evenprime/bukkit/nocheat/config/NoCheatConfiguration.java index 489e9dce..286f738f 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/config/NoCheatConfiguration.java +++ b/src/cc/co/evenprime/bukkit/nocheat/config/NoCheatConfiguration.java @@ -149,11 +149,16 @@ public class NoCheatConfiguration { root.add(movingNode); movingNode.add(new LongStringOption("logmessage", - SimpleYaml.getString("moving.logmessage", "Moving violation: [player] from [world] [from] to [to]", yamlContent). - replace("[player]", "%1$s").replace("[world]", "%2$s").replace("[from]", "(%4$.1f, %5$.1f, %6$.1f)").replace("[to]", "(%7$.1f, %8$.1f, %9$.1f)"))); + SimpleYaml.getString("moving.logmessage", "Moving violation: [player] from [world] [from] to [to] distance [distance]", yamlContent). + replace("[player]", "%1$s").replace("[world]", "%2$s"). + replace("[from]", "(%4$.1f, %5$.1f, %6$.1f)"). + replace("[to]", "(%7$.1f, %8$.1f, %9$.1f)"). + replace("[distance]", "(%10$.1f, %11$.1f, %12$.1f)"))); + movingNode.add(new LongStringOption("summarymessage", SimpleYaml.getString("moving.summarymessage", "Moving summary of last ~[timeframe] seconds: [player] total Violations: [violations]", yamlContent). - replace("[timeframe]", "%2$d").replace("[player]", "%1$s").replace("[violations]", "(%3$d,%4$d,%5$d)"))); + replace("[timeframe]", "%2$d").replace("[player]", "%1$s"). + replace("[violations]", "(%3$d,%4$d,%5$d)"))); movingNode.add(new BooleanOption("allowflying", SimpleYaml.getBoolean("moving.allowflying", false, yamlContent))); movingNode.add(new BooleanOption("allowfakesneak",