From 6f93951028c404fbaef1e4a249a25c75923435c1 Mon Sep 17 00:00:00 2001 From: Evenprime Date: Fri, 3 Feb 2012 16:49:03 +0100 Subject: [PATCH] Make lag warnings toggleable --- Instructions.txt | 3 +++ pom.xml | 2 +- .../evenprime/bukkit/nocheat/config/ConfPaths.java | 1 + .../nocheat/config/DefaultConfiguration.java | 1 + .../bukkit/nocheat/config/LoggingConfig.java | 2 ++ .../bukkit/nocheat/debug/LagMeasureTask.java | 14 ++++++++------ 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Instructions.txt b/Instructions.txt index 025cb84d..41c610fa 100644 --- a/Instructions.txt +++ b/Instructions.txt @@ -104,6 +104,9 @@ logging: showactivechecks: Should NoCheat display lists of checks that are enabled for each world. Set to true if you are unsure if you setup your configuration correctly. + debugmessages: + Should some additional messages be displayed in the server console, e.g. about + NoCheat encountering lag. checks: Anything that has to do with the checks that NoCheat executes diff --git a/pom.xml b/pom.xml index 80da8aed..26a4c0b6 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 cc.co.evenprime.bukkit NoCheat - 3.0.1 + 3.0.2 jar NoCheat diff --git a/src/cc/co/evenprime/bukkit/nocheat/config/ConfPaths.java b/src/cc/co/evenprime/bukkit/nocheat/config/ConfPaths.java index 8e88db31..1103c7f8 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/config/ConfPaths.java +++ b/src/cc/co/evenprime/bukkit/nocheat/config/ConfPaths.java @@ -14,6 +14,7 @@ public abstract class ConfPaths { public final static String LOGGING_LOGTOCONSOLE = LOGGING + "console"; public final static String LOGGING_LOGTOINGAMECHAT = LOGGING + "ingamechat"; public final static String LOGGING_SHOWACTIVECHECKS = LOGGING + "showactivechecks"; + public final static String LOGGING_DEBUGMESSAGES = LOGGING + "debugmessages"; private final static String CHECKS = "checks."; private final static String INVENTORY_DROP = CHECKS + "inventory.drop."; diff --git a/src/cc/co/evenprime/bukkit/nocheat/config/DefaultConfiguration.java b/src/cc/co/evenprime/bukkit/nocheat/config/DefaultConfiguration.java index 542b6ca4..2d4a946d 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/config/DefaultConfiguration.java +++ b/src/cc/co/evenprime/bukkit/nocheat/config/DefaultConfiguration.java @@ -17,6 +17,7 @@ public class DefaultConfiguration extends NoCheatConfiguration { /** LOGGING **/ set(ConfPaths.LOGGING_ACTIVE, true); set(ConfPaths.LOGGING_SHOWACTIVECHECKS, false); + set(ConfPaths.LOGGING_DEBUGMESSAGES, false); set(ConfPaths.LOGGING_PREFIX, "&4NC&f: "); set(ConfPaths.LOGGING_FILENAME, "nocheat.log"); set(ConfPaths.LOGGING_LOGTOFILE, true); diff --git a/src/cc/co/evenprime/bukkit/nocheat/config/LoggingConfig.java b/src/cc/co/evenprime/bukkit/nocheat/config/LoggingConfig.java index 4d8ac417..c932d7db 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/config/LoggingConfig.java +++ b/src/cc/co/evenprime/bukkit/nocheat/config/LoggingConfig.java @@ -12,11 +12,13 @@ public class LoggingConfig { public final boolean toConsole; public final boolean toChat; public final String prefix; + public final boolean debugmessages; public LoggingConfig(NoCheatConfiguration data) { active = data.getBoolean(ConfPaths.LOGGING_ACTIVE); showactivechecks = data.getBoolean(ConfPaths.LOGGING_SHOWACTIVECHECKS); + debugmessages = data.getBoolean(ConfPaths.LOGGING_DEBUGMESSAGES); prefix = data.getString(ConfPaths.LOGGING_PREFIX); toFile = data.getBoolean(ConfPaths.LOGGING_LOGTOFILE); toConsole = data.getBoolean(ConfPaths.LOGGING_LOGTOCONSOLE); diff --git a/src/cc/co/evenprime/bukkit/nocheat/debug/LagMeasureTask.java b/src/cc/co/evenprime/bukkit/nocheat/debug/LagMeasureTask.java index 353e17c8..4d17b313 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/debug/LagMeasureTask.java +++ b/src/cc/co/evenprime/bukkit/nocheat/debug/LagMeasureTask.java @@ -1,5 +1,6 @@ package cc.co.evenprime.bukkit.nocheat.debug; +import org.bukkit.World; import cc.co.evenprime.bukkit.nocheat.NoCheat; public class LagMeasureTask implements Runnable { @@ -28,12 +29,13 @@ public class LagMeasureTask implements Runnable { // If the previous second took to long, skip checks during // this second skipCheck = lastIngamesecondDuration > 1500; - - if(oldStatus != skipCheck && skipCheck) { - System.out.println("[NoCheat] detected server lag, some checks will not work."); - } - else if(oldStatus != skipCheck && !skipCheck) { - System.out.println("[NoCheat] server lag seems to have stopped, reenabling checks."); + + if(plugin.getConfig((World) null).logging.debugmessages) { + if(oldStatus != skipCheck && skipCheck) { + System.out.println("[NoCheat] detected server lag, some checks will not work."); + } else if(oldStatus != skipCheck && !skipCheck) { + System.out.println("[NoCheat] server lag seems to have stopped, reenabling checks."); + } } long time = System.currentTimeMillis();