diff --git a/src/fr/neatmonster/nocheatplus/NoCheatPlus.java b/src/fr/neatmonster/nocheatplus/NoCheatPlus.java index 42f228e1..a6e61aa8 100644 --- a/src/fr/neatmonster/nocheatplus/NoCheatPlus.java +++ b/src/fr/neatmonster/nocheatplus/NoCheatPlus.java @@ -34,7 +34,6 @@ import fr.neatmonster.nocheatplus.metrics.Metrics; import fr.neatmonster.nocheatplus.metrics.Metrics.Graph; import fr.neatmonster.nocheatplus.metrics.Metrics.Plotter; import fr.neatmonster.nocheatplus.metrics.MetricsData; -import fr.neatmonster.nocheatplus.metrics.MetricsData.TicksPlotter; import fr.neatmonster.nocheatplus.players.Permissions; import fr.neatmonster.nocheatplus.utilities.LagMeasureTask; @@ -125,47 +124,34 @@ public class NoCheatPlus extends JavaPlugin implements Listener { getCommand("nocheatplus").setExecutor(new CommandHandler(this)); // Setup the graphs, plotters and start Metrics. - if (ConfigManager.getConfigFile().getBoolean(ConfPaths.MISCELLANEOUS_REPORTTOMETRICS)) + if (ConfigManager.getConfigFile().getBoolean(ConfPaths.MISCELLANEOUS_REPORTTOMETRICS)) { + MetricsData.initialize(); try { final Metrics metrics = new Metrics(this); - final Graph eventsChecked = metrics.createGraph("Events Checked"); final Graph checksFailed = metrics.createGraph("Checks Failed"); - final Graph violationLevels = metrics.createGraph("Violation Levels"); for (final CheckType type : CheckType.values()) - if (type.getParent() != null) { - eventsChecked.addPlotter(new Plotter(type.name()) { - - @Override - public int getValue() { - final int checked = MetricsData.getChecked(type); - MetricsData.resetChecked(type); - return checked; - } - }); + if (type.getParent() != null) checksFailed.addPlotter(new Plotter(type.name()) { @Override public int getValue() { - final int failed = MetricsData.getFailed(type); - MetricsData.resetFailed(type); - return failed; + return MetricsData.getFailed(type); } }); - violationLevels.addPlotter(new Plotter(type.name()) { - - @Override - public int getValue() { - final int violationLevel = (int) MetricsData.getViolationLevel(type); - MetricsData.resetViolationLevel(type); - return violationLevel; - } - }); - } final Graph serverTicks = metrics.createGraph("Server Ticks"); - for (int ticks = 0; ticks < 21; ticks++) - serverTicks.addPlotter(new TicksPlotter(ticks)); + final int[] ticksArray = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, + 19, 20}; + for (final int ticks : ticksArray) + serverTicks.addPlotter(new Plotter(ticks + " tick(s)") { + + @Override + public int getValue() { + return MetricsData.getTicks(ticks); + } + }); metrics.start(); } catch (final Exception e) {} + } // Is a new update available? try { diff --git a/src/fr/neatmonster/nocheatplus/checks/Check.java b/src/fr/neatmonster/nocheatplus/checks/Check.java index 52c43406..892661dc 100644 --- a/src/fr/neatmonster/nocheatplus/checks/Check.java +++ b/src/fr/neatmonster/nocheatplus/checks/Check.java @@ -82,7 +82,6 @@ public abstract class Check { * @return true, if the event should be cancelled */ protected boolean executeActions(final ViolationData violationData) { - MetricsData.addViolation(violationData); ViolationHistory.getHistory(violationData.player).log(getClass().getName(), violationData.addedVL); try { // Check a bypass permission. @@ -95,6 +94,9 @@ public abstract class Check { // One of the hooks has decided to cancel the VL processing, return false. return false; + // Add this failed check to the Metrics data. + MetricsData.addFailed(type); + final long time = System.currentTimeMillis() / 1000L; boolean cancel = false; for (final Action action : violationData.getActions()) diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/Direction.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/Direction.java index 28a80e3e..7f255401 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockbreak/Direction.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/Direction.java @@ -6,7 +6,6 @@ import org.bukkit.util.Vector; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.metrics.MetricsData; import fr.neatmonster.nocheatplus.utilities.CheckUtils; /* @@ -40,9 +39,6 @@ public class Direction extends Check { * @return true, if successful */ public boolean check(final Player player, final Location location) { - // Metrics data. - MetricsData.addChecked(type); - final BlockBreakData data = BlockBreakData.getData(player); boolean cancel = false; diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java index 1d4f1813..bb8f37cf 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java @@ -7,7 +7,6 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.metrics.MetricsData; /* * MM""""""""`M dP M#"""""""'M dP @@ -47,9 +46,6 @@ public class FastBreak extends Check { * @return true, if successful */ public boolean check(final Player player, final Block block) { - // Metrics data. - MetricsData.addChecked(type); - final BlockBreakConfig cc = BlockBreakConfig.getConfig(player); final BlockBreakData data = BlockBreakData.getData(player); diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/NoSwing.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/NoSwing.java index e5fb6eee..1fea9778 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockbreak/NoSwing.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/NoSwing.java @@ -4,7 +4,6 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.metrics.MetricsData; /* * M"""""""`YM MP""""""`MM oo @@ -36,9 +35,6 @@ public class NoSwing extends Check { * @return true, if successful */ public boolean check(final Player player) { - // Metrics data. - MetricsData.addChecked(type); - final BlockBreakData data = BlockBreakData.getData(player); boolean cancel = false; diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/Reach.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/Reach.java index 5a7de397..beb4de99 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockbreak/Reach.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/Reach.java @@ -8,7 +8,6 @@ import fr.neatmonster.nocheatplus.actions.ParameterName; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.checks.ViolationData; -import fr.neatmonster.nocheatplus.metrics.MetricsData; import fr.neatmonster.nocheatplus.utilities.CheckUtils; /* @@ -48,9 +47,6 @@ public class Reach extends Check { * @return true, if successful */ public boolean check(final Player player, final Location location) { - // Metrics data. - MetricsData.addChecked(type); - final BlockBreakData data = BlockBreakData.getData(player); boolean cancel = false; diff --git a/src/fr/neatmonster/nocheatplus/checks/blockinteract/Direction.java b/src/fr/neatmonster/nocheatplus/checks/blockinteract/Direction.java index a1478a42..896fa788 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockinteract/Direction.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockinteract/Direction.java @@ -6,7 +6,6 @@ import org.bukkit.util.Vector; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.metrics.MetricsData; import fr.neatmonster.nocheatplus.utilities.CheckUtils; /* @@ -40,9 +39,6 @@ public class Direction extends Check { * @return true, if successful */ public boolean check(final Player player, final Location location) { - // Metrics data. - MetricsData.addChecked(type); - final BlockInteractData data = BlockInteractData.getData(player); boolean cancel = false; diff --git a/src/fr/neatmonster/nocheatplus/checks/blockinteract/Reach.java b/src/fr/neatmonster/nocheatplus/checks/blockinteract/Reach.java index e0ac24f6..c9fd73c3 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockinteract/Reach.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockinteract/Reach.java @@ -8,7 +8,6 @@ import fr.neatmonster.nocheatplus.actions.ParameterName; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.checks.ViolationData; -import fr.neatmonster.nocheatplus.metrics.MetricsData; import fr.neatmonster.nocheatplus.utilities.CheckUtils; /* @@ -48,9 +47,6 @@ public class Reach extends Check { * @return true, if successful */ public boolean check(final Player player, final Location location) { - // Metrics data. - MetricsData.addChecked(type); - final BlockInteractData data = BlockInteractData.getData(player); boolean cancel = false; diff --git a/src/fr/neatmonster/nocheatplus/checks/blockplace/Direction.java b/src/fr/neatmonster/nocheatplus/checks/blockplace/Direction.java index 7fc4643b..b51a64d2 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockplace/Direction.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockplace/Direction.java @@ -6,7 +6,6 @@ import org.bukkit.util.Vector; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.metrics.MetricsData; import fr.neatmonster.nocheatplus.utilities.CheckUtils; /* @@ -40,9 +39,6 @@ public class Direction extends Check { * @return true, if successful */ public boolean check(final Player player, final Location placed, final Location against) { - // Metrics data. - MetricsData.addChecked(type); - final BlockPlaceData data = BlockPlaceData.getData(player); boolean cancel = false; diff --git a/src/fr/neatmonster/nocheatplus/checks/blockplace/FastPlace.java b/src/fr/neatmonster/nocheatplus/checks/blockplace/FastPlace.java index 89315522..8458b72c 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockplace/FastPlace.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockplace/FastPlace.java @@ -5,7 +5,6 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.metrics.MetricsData; import fr.neatmonster.nocheatplus.utilities.LagMeasureTask; /* @@ -39,9 +38,6 @@ public class FastPlace extends Check { * @return true, if successful */ public boolean check(final Player player, final Block block) { - // Metrics data. - MetricsData.addChecked(type); - final BlockPlaceConfig cc = BlockPlaceConfig.getConfig(player); final BlockPlaceData data = BlockPlaceData.getData(player); diff --git a/src/fr/neatmonster/nocheatplus/checks/blockplace/NoSwing.java b/src/fr/neatmonster/nocheatplus/checks/blockplace/NoSwing.java index f7803565..11cd7226 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockplace/NoSwing.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockplace/NoSwing.java @@ -4,7 +4,6 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.metrics.MetricsData; /* * M"""""""`YM MP""""""`MM oo @@ -36,9 +35,6 @@ public class NoSwing extends Check { * @return true, if successful */ public boolean check(final Player player) { - // Metrics data. - MetricsData.addChecked(type); - final BlockPlaceData data = BlockPlaceData.getData(player); boolean cancel = false; diff --git a/src/fr/neatmonster/nocheatplus/checks/blockplace/Reach.java b/src/fr/neatmonster/nocheatplus/checks/blockplace/Reach.java index 5dd5fc00..230f22b5 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockplace/Reach.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockplace/Reach.java @@ -8,7 +8,6 @@ import fr.neatmonster.nocheatplus.actions.ParameterName; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.checks.ViolationData; -import fr.neatmonster.nocheatplus.metrics.MetricsData; import fr.neatmonster.nocheatplus.utilities.CheckUtils; /* @@ -48,9 +47,6 @@ public class Reach extends Check { * @return true, if successful */ public boolean check(final Player player, final Location location) { - // Metrics data. - MetricsData.addChecked(type); - final BlockPlaceData data = BlockPlaceData.getData(player); boolean cancel = false; diff --git a/src/fr/neatmonster/nocheatplus/checks/blockplace/Speed.java b/src/fr/neatmonster/nocheatplus/checks/blockplace/Speed.java index 2a36fa39..1d5a8947 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockplace/Speed.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockplace/Speed.java @@ -4,7 +4,6 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.metrics.MetricsData; /* * MP""""""`MM dP @@ -36,9 +35,6 @@ public class Speed extends Check { * @return true, if successful */ public boolean check(final Player player) { - // Metrics data. - MetricsData.addChecked(type); - final BlockPlaceConfig cc = BlockPlaceConfig.getConfig(player); final BlockPlaceData data = BlockPlaceData.getData(player); diff --git a/src/fr/neatmonster/nocheatplus/checks/chat/Color.java b/src/fr/neatmonster/nocheatplus/checks/chat/Color.java index 376d5353..42b1d3e6 100644 --- a/src/fr/neatmonster/nocheatplus/checks/chat/Color.java +++ b/src/fr/neatmonster/nocheatplus/checks/chat/Color.java @@ -5,7 +5,6 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.actions.types.ActionList; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.metrics.MetricsData; /* * MM'""""'YMM dP @@ -48,9 +47,6 @@ public class Color extends Check { // Leave out the permission check. return message; - // Metrics data. - MetricsData.addChecked(type); - final ChatData data = ChatData.getData(player); // Keep related to ChatData/NoPwnage/Color used lock. synchronized (data) { diff --git a/src/fr/neatmonster/nocheatplus/checks/chat/NoPwnage.java b/src/fr/neatmonster/nocheatplus/checks/chat/NoPwnage.java index 1e0ad04c..df91b0c8 100644 --- a/src/fr/neatmonster/nocheatplus/checks/chat/NoPwnage.java +++ b/src/fr/neatmonster/nocheatplus/checks/chat/NoPwnage.java @@ -13,7 +13,6 @@ import fr.neatmonster.nocheatplus.actions.types.ActionList; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.checks.ViolationData; -import fr.neatmonster.nocheatplus.metrics.MetricsData; import fr.neatmonster.nocheatplus.utilities.CheckUtils; /* @@ -74,9 +73,6 @@ public class NoPwnage extends Check { if (!isMainThread && !cc.isEnabled(type)) return false; - // Metrics data. - MetricsData.addChecked(type); - // Keep related to ChatData/NoPwnage/Color used lock. synchronized (data) { return unsafeCheck(player, event, isMainThread, cc, data); diff --git a/src/fr/neatmonster/nocheatplus/checks/fight/Angle.java b/src/fr/neatmonster/nocheatplus/checks/fight/Angle.java index 9855d11a..ebe3ef4b 100644 --- a/src/fr/neatmonster/nocheatplus/checks/fight/Angle.java +++ b/src/fr/neatmonster/nocheatplus/checks/fight/Angle.java @@ -7,7 +7,6 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.metrics.MetricsData; import fr.neatmonster.nocheatplus.utilities.LagMeasureTask; /* @@ -42,9 +41,6 @@ public class Angle extends Check { * @return true, if successful */ public boolean check(final Player player) { - // Metrics data. - MetricsData.addChecked(type); - final FightConfig cc = FightConfig.getConfig(player); final FightData data = FightData.getData(player); diff --git a/src/fr/neatmonster/nocheatplus/checks/fight/Critical.java b/src/fr/neatmonster/nocheatplus/checks/fight/Critical.java index b442643c..442386a6 100644 --- a/src/fr/neatmonster/nocheatplus/checks/fight/Critical.java +++ b/src/fr/neatmonster/nocheatplus/checks/fight/Critical.java @@ -5,7 +5,6 @@ import org.bukkit.potion.PotionEffectType; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.metrics.MetricsData; import fr.neatmonster.nocheatplus.utilities.LagMeasureTask; import fr.neatmonster.nocheatplus.utilities.PlayerLocation; @@ -38,9 +37,6 @@ public class Critical extends Check { * @return true, if successful */ public boolean check(final Player player) { - // Metrics data. - MetricsData.addChecked(type); - final FightConfig cc = FightConfig.getConfig(player); final FightData data = FightData.getData(player); diff --git a/src/fr/neatmonster/nocheatplus/checks/fight/Direction.java b/src/fr/neatmonster/nocheatplus/checks/fight/Direction.java index 00f960ca..b77f83ab 100644 --- a/src/fr/neatmonster/nocheatplus/checks/fight/Direction.java +++ b/src/fr/neatmonster/nocheatplus/checks/fight/Direction.java @@ -10,7 +10,6 @@ import org.bukkit.util.Vector; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.metrics.MetricsData; import fr.neatmonster.nocheatplus.utilities.CheckUtils; /* @@ -44,9 +43,6 @@ public class Direction extends Check { * @return true, if successful */ public boolean check(final Player player, final Entity damaged) { - // Metrics data. - MetricsData.addChecked(type); - final FightConfig cc = FightConfig.getConfig(player); final FightData data = FightData.getData(player); diff --git a/src/fr/neatmonster/nocheatplus/checks/fight/GodMode.java b/src/fr/neatmonster/nocheatplus/checks/fight/GodMode.java index 44a75457..f14022aa 100644 --- a/src/fr/neatmonster/nocheatplus/checks/fight/GodMode.java +++ b/src/fr/neatmonster/nocheatplus/checks/fight/GodMode.java @@ -9,7 +9,6 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.NoCheatPlus; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.metrics.MetricsData; /* * MM'"""""`MM dP M"""""`'"""`YM dP @@ -40,9 +39,6 @@ public class GodMode extends Check { * @return true, if successful */ public boolean check(final Player player) { - // Metrics data. - MetricsData.addChecked(type); - final FightData data = FightData.getData(player); boolean cancel = false; diff --git a/src/fr/neatmonster/nocheatplus/checks/fight/InstantHeal.java b/src/fr/neatmonster/nocheatplus/checks/fight/InstantHeal.java index e7ee9505..dadb0af3 100644 --- a/src/fr/neatmonster/nocheatplus/checks/fight/InstantHeal.java +++ b/src/fr/neatmonster/nocheatplus/checks/fight/InstantHeal.java @@ -4,7 +4,6 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.metrics.MetricsData; /* * M""M dP dP M""MMMMM""MM dP @@ -36,9 +35,6 @@ public class InstantHeal extends Check { * @return true, if successful */ public boolean check(final Player player) { - // Metrics data. - MetricsData.addChecked(type); - final FightData data = FightData.getData(player); boolean cancel = false; diff --git a/src/fr/neatmonster/nocheatplus/checks/fight/Knockback.java b/src/fr/neatmonster/nocheatplus/checks/fight/Knockback.java index 2422e9ac..fd1ff13b 100644 --- a/src/fr/neatmonster/nocheatplus/checks/fight/Knockback.java +++ b/src/fr/neatmonster/nocheatplus/checks/fight/Knockback.java @@ -5,7 +5,6 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.metrics.MetricsData; import fr.neatmonster.nocheatplus.utilities.LagMeasureTask; /* @@ -37,9 +36,6 @@ public class Knockback extends Check { * @return true, if successful */ public boolean check(final Player player) { - // Metrics data. - MetricsData.addChecked(type); - final FightConfig cc = FightConfig.getConfig(player); final FightData data = FightData.getData(player); diff --git a/src/fr/neatmonster/nocheatplus/checks/fight/NoSwing.java b/src/fr/neatmonster/nocheatplus/checks/fight/NoSwing.java index b699c64e..35c9053f 100644 --- a/src/fr/neatmonster/nocheatplus/checks/fight/NoSwing.java +++ b/src/fr/neatmonster/nocheatplus/checks/fight/NoSwing.java @@ -4,7 +4,6 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.metrics.MetricsData; /* * M"""""""`YM MP""""""`MM oo @@ -36,9 +35,6 @@ public class NoSwing extends Check { * @return true, if successful */ public boolean check(final Player player) { - // Metrics data. - MetricsData.addChecked(type); - final FightData data = FightData.getData(player); boolean cancel = false; diff --git a/src/fr/neatmonster/nocheatplus/checks/fight/Reach.java b/src/fr/neatmonster/nocheatplus/checks/fight/Reach.java index fb2fe918..2a8cb39b 100644 --- a/src/fr/neatmonster/nocheatplus/checks/fight/Reach.java +++ b/src/fr/neatmonster/nocheatplus/checks/fight/Reach.java @@ -8,7 +8,6 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.metrics.MetricsData; import fr.neatmonster.nocheatplus.utilities.CheckUtils; import fr.neatmonster.nocheatplus.utilities.LagMeasureTask; @@ -49,9 +48,6 @@ public class Reach extends Check { * @return true, if successful */ public boolean check(final Player player, final Entity damaged) { - // Metrics data. - MetricsData.addChecked(type); - final FightConfig cc = FightConfig.getConfig(player); final FightData data = FightData.getData(player); diff --git a/src/fr/neatmonster/nocheatplus/checks/fight/Speed.java b/src/fr/neatmonster/nocheatplus/checks/fight/Speed.java index 1cf1c8a2..cd8dcc9a 100644 --- a/src/fr/neatmonster/nocheatplus/checks/fight/Speed.java +++ b/src/fr/neatmonster/nocheatplus/checks/fight/Speed.java @@ -6,7 +6,6 @@ import fr.neatmonster.nocheatplus.actions.ParameterName; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.checks.ViolationData; -import fr.neatmonster.nocheatplus.metrics.MetricsData; import fr.neatmonster.nocheatplus.utilities.LagMeasureTask; /* @@ -39,9 +38,6 @@ public class Speed extends Check { * @return true, if successful */ public boolean check(final Player player) { - // Metrics data. - MetricsData.addChecked(type); - final FightConfig cc = FightConfig.getConfig(player); final FightData data = FightData.getData(player); diff --git a/src/fr/neatmonster/nocheatplus/checks/inventory/Drop.java b/src/fr/neatmonster/nocheatplus/checks/inventory/Drop.java index 3edf7274..953d3565 100644 --- a/src/fr/neatmonster/nocheatplus/checks/inventory/Drop.java +++ b/src/fr/neatmonster/nocheatplus/checks/inventory/Drop.java @@ -4,7 +4,6 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.metrics.MetricsData; /* * M""""""'YMM @@ -36,9 +35,6 @@ public class Drop extends Check { * @return true, if successful */ public boolean check(final Player player) { - // Metrics data. - MetricsData.addChecked(type); - final InventoryConfig cc = InventoryConfig.getConfig(player); final InventoryData data = InventoryData.getData(player); diff --git a/src/fr/neatmonster/nocheatplus/checks/inventory/FastClick.java b/src/fr/neatmonster/nocheatplus/checks/inventory/FastClick.java index e2511296..823e39d5 100644 --- a/src/fr/neatmonster/nocheatplus/checks/inventory/FastClick.java +++ b/src/fr/neatmonster/nocheatplus/checks/inventory/FastClick.java @@ -4,7 +4,6 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.metrics.MetricsData; /* * MM""""""""`M dP MM'""""'YMM dP oo dP @@ -35,9 +34,6 @@ public class FastClick extends Check { * @return true, if successful */ public boolean check(final Player player) { - // Metrics data. - MetricsData.addChecked(type); - final InventoryData data = InventoryData.getData(player); boolean cancel = false; diff --git a/src/fr/neatmonster/nocheatplus/checks/inventory/InstantBow.java b/src/fr/neatmonster/nocheatplus/checks/inventory/InstantBow.java index ed578f5b..1e730218 100644 --- a/src/fr/neatmonster/nocheatplus/checks/inventory/InstantBow.java +++ b/src/fr/neatmonster/nocheatplus/checks/inventory/InstantBow.java @@ -4,7 +4,6 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.metrics.MetricsData; /* * M""M dP dP M#"""""""'M @@ -37,9 +36,6 @@ public class InstantBow extends Check { * @return true, if successful */ public boolean check(final Player player, final float force) { - // Metrics data. - MetricsData.addChecked(type); - final InventoryData data = InventoryData.getData(player); boolean cancel = false; diff --git a/src/fr/neatmonster/nocheatplus/checks/inventory/InstantEat.java b/src/fr/neatmonster/nocheatplus/checks/inventory/InstantEat.java index 90b9c4eb..3e8ff629 100644 --- a/src/fr/neatmonster/nocheatplus/checks/inventory/InstantEat.java +++ b/src/fr/neatmonster/nocheatplus/checks/inventory/InstantEat.java @@ -6,7 +6,6 @@ import fr.neatmonster.nocheatplus.actions.ParameterName; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.checks.ViolationData; -import fr.neatmonster.nocheatplus.metrics.MetricsData; /* * M""M dP dP MM""""""""`M dP @@ -39,9 +38,6 @@ public class InstantEat extends Check { * @return true, if successful */ public boolean check(final Player player, final int level) { - // Metrics data. - MetricsData.addChecked(type); - final InventoryData data = InventoryData.getData(player); boolean cancel = false; diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/CreativeFly.java b/src/fr/neatmonster/nocheatplus/checks/moving/CreativeFly.java index 2a9695f0..cf9f4080 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/CreativeFly.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/CreativeFly.java @@ -13,7 +13,6 @@ import fr.neatmonster.nocheatplus.actions.ParameterName; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.checks.ViolationData; -import fr.neatmonster.nocheatplus.metrics.MetricsData; import fr.neatmonster.nocheatplus.utilities.PlayerLocation; /* @@ -57,9 +56,6 @@ public class CreativeFly extends Check { * @return the location */ public Location check(final Player player, final PlayerLocation from, final PlayerLocation to) { - // Metrics data. - MetricsData.addChecked(type); - final MovingConfig cc = MovingConfig.getConfig(player); final MovingData data = MovingData.getData(player); diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/MorePackets.java b/src/fr/neatmonster/nocheatplus/checks/moving/MorePackets.java index 66dd64b6..141e0306 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/MorePackets.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/MorePackets.java @@ -7,7 +7,6 @@ import fr.neatmonster.nocheatplus.actions.ParameterName; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.checks.ViolationData; -import fr.neatmonster.nocheatplus.metrics.MetricsData; import fr.neatmonster.nocheatplus.utilities.PlayerLocation; /* @@ -60,9 +59,6 @@ public class MorePackets extends Check { * @return the location */ public Location check(final Player player, final PlayerLocation from, final PlayerLocation to) { - // Metrics data. - MetricsData.addChecked(type); - final MovingData data = MovingData.getData(player); Location newTo = null; diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/MorePacketsVehicle.java b/src/fr/neatmonster/nocheatplus/checks/moving/MorePacketsVehicle.java index 7ceebe25..22d82fdb 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/MorePacketsVehicle.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/MorePacketsVehicle.java @@ -7,7 +7,6 @@ import fr.neatmonster.nocheatplus.actions.ParameterName; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.checks.ViolationData; -import fr.neatmonster.nocheatplus.metrics.MetricsData; /* * M"""""`'"""`YM MM"""""""`YM dP dP @@ -59,9 +58,6 @@ public class MorePacketsVehicle extends Check { * @return the location */ public Location check(final Player player, final Location from, final Location to) { - // Metrics data. - MetricsData.addChecked(type); - final MovingData data = MovingData.getData(player); Location newTo = null; diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/NoFall.java b/src/fr/neatmonster/nocheatplus/checks/moving/NoFall.java index 77b2810e..9f2c349b 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/NoFall.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/NoFall.java @@ -11,7 +11,6 @@ import fr.neatmonster.nocheatplus.actions.ParameterName; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.checks.ViolationData; -import fr.neatmonster.nocheatplus.metrics.MetricsData; import fr.neatmonster.nocheatplus.utilities.PlayerLocation; /* @@ -46,9 +45,6 @@ public class NoFall extends Check { * the to */ public void check(final Player player, final PlayerLocation from, final PlayerLocation to) { - // Metrics data. - MetricsData.addChecked(type); - final MovingConfig cc = MovingConfig.getConfig(player); final MovingData data = MovingData.getData(player); diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java b/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java index eef80164..ac00e771 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java @@ -13,7 +13,6 @@ import fr.neatmonster.nocheatplus.actions.ParameterName; import fr.neatmonster.nocheatplus.checks.Check; import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.checks.ViolationData; -import fr.neatmonster.nocheatplus.metrics.MetricsData; import fr.neatmonster.nocheatplus.players.Permissions; import fr.neatmonster.nocheatplus.utilities.PlayerLocation; @@ -49,9 +48,6 @@ public class SurvivalFly extends Check { * @return true, if successful */ public boolean check(final Player player) { - // Metrics data. - MetricsData.addChecked(type); - final MovingData data = MovingData.getData(player); // Check if the player has entered the bed he is trying to leave. diff --git a/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java b/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java index 78d85183..3737531e 100644 --- a/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java +++ b/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java @@ -243,7 +243,7 @@ public class DefaultConfig extends ConfigFile { set(ConfPaths.INVENTORY_DROP_ACTIONS, "log:drop:0:1:cif cmd:kick"); set(ConfPaths.INVENTORY_FASTCLICK_CHECK, true); - set(ConfPaths.INVENTORY_FASTCLICK_ACTIONS, "cancel"); // TODO + set(ConfPaths.INVENTORY_FASTCLICK_ACTIONS, "cancel vl>50 log:fastclick:3:5:cif cancel"); set(ConfPaths.INVENTORY_INSTANTBOW_CHECK, true); set(ConfPaths.INVENTORY_INSTANTBOW_ACTIONS, "log:instantbow:2:5:if cancel"); @@ -309,6 +309,7 @@ public class DefaultConfig extends ConfigFile { set(ConfPaths.STRINGS + ".critical", start + "tried to do a critical hit but wasn't technically jumping" + end); set(ConfPaths.STRINGS + ".drop", start + "tried to drop more items than allowed" + end); set(ConfPaths.STRINGS + ".fastbreak", start + "tried to break too many blocks" + end); + set(ConfPaths.STRINGS + ".fastclick", start + "tried to move items in his inventory too quickly" + end); set(ConfPaths.STRINGS + ".fastplace", start + "tried to place too many blocks" + end); set(ConfPaths.STRINGS + ".fdirection", start + "tried to hit an entity out of line of sight" + end); set(ConfPaths.STRINGS + ".flyshort", start + "tried to move unexpectedly" + end); diff --git a/src/fr/neatmonster/nocheatplus/metrics/MetricsData.java b/src/fr/neatmonster/nocheatplus/metrics/MetricsData.java index b25adabc..3b93c856 100644 --- a/src/fr/neatmonster/nocheatplus/metrics/MetricsData.java +++ b/src/fr/neatmonster/nocheatplus/metrics/MetricsData.java @@ -4,10 +4,6 @@ import java.util.HashMap; import java.util.Map; import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.checks.ViolationData; -import fr.neatmonster.nocheatplus.config.ConfPaths; -import fr.neatmonster.nocheatplus.config.ConfigManager; -import fr.neatmonster.nocheatplus.metrics.Metrics.Plotter; /* * M"""""`'"""`YM dP oo M""""""'YMM dP @@ -19,187 +15,76 @@ import fr.neatmonster.nocheatplus.metrics.Metrics.Plotter; * MMMMMMMMMMMMMM MMMMMMMMMMM */ /** - * The Metrics data. + * This class is used to store the data that will be sent to Metrics later. */ public class MetricsData { - /** - * The ticks plotter. - */ - public static class TicksPlotter extends Plotter { + /** Is data collecting enabled? */ + private static boolean enabled = false; - /** The ticks. */ - private final int ticks; + /** The map containing the number of fails per check. */ + private static final Map checksFailed = new HashMap(); - /** - * Instantiates a new ticks plotter. - * - * @param ticks - * the ticks - */ - public TicksPlotter(final int ticks) { - super(ticks + " tick(s)"); - this.ticks = ticks; - } - - /* (non-Javadoc) - * @see fr.neatmonster.nocheatplus.metrics.Metrics.Plotter#getValue() - */ - @Override - public int getValue() { - final int ticks = MetricsData.getServerTicks(this.ticks); - MetricsData.resetServerTicks(this.ticks); - return ticks; - } - } - - /** Is Metrics enabled? */ - private static boolean enabled; - - /** The checks failed. */ - private static final Map checksFailed = new HashMap(); - - /** The events checked. */ - private static final Map eventsChecked = new HashMap(); - - /** The server ticks. */ - private static final Map serverTicks = new HashMap(); - - /** The violation levels. */ - private static final Map violationLevels = new HashMap(); + /** The map containing the number of seconds per number of ticks this seconds contain. */ + private static final Map ticksNumbers = new HashMap(); /** - * Adds the checked. + * Adds a failed check to the specified check type. * * @param type - * the type + * the check type */ - public static void addChecked(final CheckType type) { + public static void addFailed(final CheckType type) { if (enabled && type.getParent() != null) - eventsChecked.put(type, getChecked(type) + 1); + checksFailed.put(type, checksFailed.get(type) + 1); } /** - * Adds the ticks. + * Adds a seconds to the number of ticks it has contained. * * @param ticks - * the ticks + * the ticks number */ public static void addTicks(final int ticks) { if (enabled) - serverTicks.put(ticks, serverTicks.get(ticks) + 1); + ticksNumbers.put(ticks, ticksNumbers.get(ticks) + 1); } /** - * Adds the violation. - * - * @param violationData - * the violation data - */ - public static void addViolation(final ViolationData violationData) { - final CheckType type = violationData.check.getType(); - if (enabled && type.getParent() != null) { - checksFailed.put(type, getFailed(type) + 1); - violationLevels.put(type, getViolationLevel(type) + violationData.addedVL); - } - } - - /** - * Gets the checked. + * Gets the number of failed checks for the specified check type. * * @param type - * the type - * @return the checked - */ - public static int getChecked(final CheckType type) { - if (!eventsChecked.containsKey(type)) - resetChecked(type); - return eventsChecked.get(type); - } - - /** - * Gets the failed. - * - * @param type - * the type + * the check type * @return the failed */ public static int getFailed(final CheckType type) { - if (!checksFailed.containsKey(type)) - resetFailed(type); - return checksFailed.get(type); + final int failed = checksFailed.get(type); + checksFailed.put(type, 0); + return failed; } /** - * Gets the server ticks. + * Gets the number of seconds which have contained the specified number of ticks. * * @param ticks - * the ticks - * @return the server ticks + * the ticks number + * @return the ticks */ - public static int getServerTicks(final int ticks) { - if (!serverTicks.containsKey(ticks)) - resetServerTicks(ticks); - return serverTicks.get(ticks); - } - - /** - * Gets the violation level. - * - * @param type - * the type - * @return the violation level - */ - public static double getViolationLevel(final CheckType type) { - if (!violationLevels.containsKey(type)) - resetViolationLevel(type); - return violationLevels.get(type); + public static int getTicks(final int ticks) { + final int number = ticksNumbers.get(ticks); + ticksNumbers.put(ticks, 0); + return number; } /** * Initialize the class. */ public static void initialize() { - enabled = ConfigManager.getConfigFile().getBoolean(ConfPaths.MISCELLANEOUS_REPORTTOMETRICS); - } - - /** - * Reset checked. - * - * @param type - * the type - */ - public static void resetChecked(final CheckType type) { - eventsChecked.put(type, 0); - } - - /** - * Reset failed. - * - * @param type - * the type - */ - public static void resetFailed(final CheckType type) { - checksFailed.put(type, 0); - } - - /** - * Reset server ticks. - * - * @param ticks - * the ticks - */ - public static void resetServerTicks(final int ticks) { - serverTicks.put(ticks, 0); - } - - /** - * Reset violation level. - * - * @param type - * the type - */ - public static void resetViolationLevel(final CheckType type) { - violationLevels.put(type, 0D); + enabled = true; + for (final CheckType type : CheckType.values()) + if (type.getParent() != null) + checksFailed.put(type, 0); + for (int ticks = 0; ticks < 21; ticks++) + ticksNumbers.put(ticks, 0); } } diff --git a/src/fr/neatmonster/nocheatplus/utilities/LagMeasureTask.java b/src/fr/neatmonster/nocheatplus/utilities/LagMeasureTask.java index e1ad7460..3d853d56 100644 --- a/src/fr/neatmonster/nocheatplus/utilities/LagMeasureTask.java +++ b/src/fr/neatmonster/nocheatplus/utilities/LagMeasureTask.java @@ -89,12 +89,13 @@ public class LagMeasureTask implements Runnable { // If the previous second took to long, skip checks during this second. skipCheck = lastInGameSecondDuration > 2000; - // Metrics data. + // Add the number of ticks the last second have contained to the Metrics data. int ticks = (int) Math.round(20000D / lastInGameSecondDuration); if (ticks > 20) ticks = 20; MetricsData.addTicks(ticks); + // Show the debug messages. if (ConfigManager.getConfigFile().getBoolean(ConfPaths.LOGGING_DEBUG)) if (oldStatus != skipCheck && skipCheck) System.out.println("[NoCheatPlus] Detected server lag, some checks will not work.");