Mostly some Metrics related changes.

This commit is contained in:
NeatMonster 2012-08-24 22:02:38 +02:00
parent f662f98369
commit c94bd978a8
36 changed files with 54 additions and 303 deletions

View File

@ -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 {

View File

@ -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())

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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) {

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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.

View File

@ -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);

View File

@ -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<CheckType, Integer> checksFailed = new HashMap<CheckType, Integer>();
/**
* 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<CheckType, Integer> checksFailed = new HashMap<CheckType, Integer>();
/** The events checked. */
private static final Map<CheckType, Integer> eventsChecked = new HashMap<CheckType, Integer>();
/** The server ticks. */
private static final Map<Integer, Integer> serverTicks = new HashMap<Integer, Integer>();
/** The violation levels. */
private static final Map<CheckType, Double> violationLevels = new HashMap<CheckType, Double>();
/** The map containing the number of seconds per number of ticks this seconds contain. */
private static final Map<Integer, Integer> ticksNumbers = new HashMap<Integer, Integer>();
/**
* 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);
}
}

View File

@ -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.");