diff options
author | ementalo <ementalodev@gmx.co.uk> | 2012-07-17 12:26:55 +0100 |
---|---|---|
committer | ementalo <ementalodev@gmx.co.uk> | 2012-07-17 14:21:03 +0100 |
commit | a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3 (patch) | |
tree | 2aa10b6300f6c8d3cb2b298c124180fade74857a /EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/debug | |
parent | 3c385e69271dfe8530fadc3f67e13ee495e4b0e1 (diff) | |
parent | 9f05e43ecf8e6e1a8fcaef757678e762f0d82573 (diff) | |
download | Essentials-a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3.tar Essentials-a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3.tar.gz Essentials-a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3.tar.lz Essentials-a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3.tar.xz Essentials-a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3.zip |
Merge of server-layer branch
Diffstat (limited to 'EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/debug')
-rw-r--r-- | EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/debug/ActiveCheckPrinter.java | 66 | ||||
-rw-r--r-- | EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/debug/LagMeasureTask.java | 99 |
2 files changed, 0 insertions, 165 deletions
diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/debug/ActiveCheckPrinter.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/debug/ActiveCheckPrinter.java deleted file mode 100644 index 295acb9ef..000000000 --- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/debug/ActiveCheckPrinter.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.earth2me.essentials.anticheat.debug; - -import com.earth2me.essentials.anticheat.EventManager; -import com.earth2me.essentials.anticheat.NoCheat; -import com.earth2me.essentials.anticheat.config.ConfigurationCacheStore; -import java.util.List; -import org.bukkit.World; - - -/** - * Prints the list of active checks per world on startup, if requested - * - */ -public class ActiveCheckPrinter -{ - public static void printActiveChecks(NoCheat plugin, List<EventManager> eventManagers) - { - - boolean introPrinted = false; - - // Print active checks for NoCheat, if needed. - for (World world : plugin.getServer().getWorlds()) - { - - StringBuilder line = new StringBuilder(" ").append(world.getName()).append(": "); - - int length = line.length(); - - ConfigurationCacheStore cc = plugin.getConfig(world); - - if (!cc.logging.showactivechecks) - { - continue; - } - - for (EventManager em : eventManagers) - { - if (em.getActiveChecks(cc).isEmpty()) - { - continue; - } - - for (String active : em.getActiveChecks(cc)) - { - line.append(active).append(' '); - } - - if (!introPrinted) - { - plugin.getLogger().info("Active Checks: "); - introPrinted = true; - } - - plugin.getServer().getLogger().info(line.toString()); - - line = new StringBuilder(length); - - for (int i = 0; i < length; i++) - { - line.append(' '); - } - } - - } - } -} diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/debug/LagMeasureTask.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/debug/LagMeasureTask.java deleted file mode 100644 index 4acb5a5f2..000000000 --- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/debug/LagMeasureTask.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.earth2me.essentials.anticheat.debug; - -import com.earth2me.essentials.anticheat.NoCheat; -import org.bukkit.World; - - -/** - * A task running in the background that measures tick time vs. real time - * - */ -public class LagMeasureTask implements Runnable -{ - private int ingameseconds = 1; - private long lastIngamesecondTime = System.currentTimeMillis(); - private long lastIngamesecondDuration = 2000L; - private boolean skipCheck = false; - private int lagMeasureTaskId = -1; - private final NoCheat plugin; - - public LagMeasureTask(NoCheat plugin) - { - this.plugin = plugin; - } - - public void start() - { - // start measuring with a delay of 10 seconds - lagMeasureTaskId = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, this, 20, 20); - } - - public void run() - { - try - { - boolean oldStatus = skipCheck; - // If the previous second took to long, skip checks during - // this second - skipCheck = lastIngamesecondDuration > 2000; - - if (plugin.getConfig((World)null).logging.debugmessages) - { - if (oldStatus != skipCheck && skipCheck) - { - plugin.getLogger().warning("detected server lag, some checks will not work."); - } - else if (oldStatus != skipCheck && !skipCheck) - { - plugin.getLogger().info("server lag seems to have stopped, reenabling checks."); - } - } - - long time = System.currentTimeMillis(); - lastIngamesecondDuration = time - lastIngamesecondTime; - if (lastIngamesecondDuration < 1000) - { - lastIngamesecondDuration = 1000; - } - else if (lastIngamesecondDuration > 3600000) - { - lastIngamesecondDuration = 3600000; // top limit of 1 - // hour per "second" - } - lastIngamesecondTime = time; - ingameseconds++; - - // Check if some data is outdated now and let it be removed - if (ingameseconds % 62 == 0) - { - plugin.cleanDataMap(); - } - } - catch (Exception e) - { - // Just prevent this thread from dying for whatever reason - } - - } - - public void cancel() - { - if (lagMeasureTaskId != -1) - { - try - { - plugin.getServer().getScheduler().cancelTask(lagMeasureTaskId); - } - catch (Exception e) - { - plugin.getLogger().warning("Couldn't cancel LagMeasureTask: " + e.getMessage()); - } - lagMeasureTaskId = -1; - } - } - - public boolean skipCheck() - { - return skipCheck; - } -} |