diff --git a/src/fr/neatmonster/nocheatplus/NoCheatPlus.java b/src/fr/neatmonster/nocheatplus/NoCheatPlus.java index e2594ecb..9abaa3a8 100644 --- a/src/fr/neatmonster/nocheatplus/NoCheatPlus.java +++ b/src/fr/neatmonster/nocheatplus/NoCheatPlus.java @@ -312,7 +312,7 @@ public class NoCheatPlus extends JavaPlugin implements Listener { // Debug information about unknown blocks. // (Probably removed later.) - BlockProperties.dumpBlocks(config.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_DEBUG, false)); + BlockProperties.dumpBlocks(config.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_DEBUG, false) || config.getBoolean(ConfPaths.BLOCKBREAK, false)); // Tell the server administrator that we finished loading NoCheatPlus now. CheckUtils.logInfo("[NoCheatPlus] Version " + getDescription().getVersion() + " is enabled."); diff --git a/src/fr/neatmonster/nocheatplus/checks/access/ACheckConfig.java b/src/fr/neatmonster/nocheatplus/checks/access/ACheckConfig.java index e18f132e..41d5ee1d 100644 --- a/src/fr/neatmonster/nocheatplus/checks/access/ACheckConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/access/ACheckConfig.java @@ -1,5 +1,7 @@ package fr.neatmonster.nocheatplus.checks.access; +import fr.neatmonster.nocheatplus.config.ConfigFile; + /** * Minimal implementation, doing nothing. @@ -8,11 +10,33 @@ package fr.neatmonster.nocheatplus.checks.access; */ public abstract class ACheckConfig implements ICheckConfig { + /** For on the fly debug setting. */ + public boolean debug = false; + + /** + * + * @param config + * @param pathPrefix Path prefix for the check section (example for use: prefix+"debug"). + */ + public ACheckConfig(final ConfigFile config, final String pathPrefix){ + debug = config.getBoolean(pathPrefix + "debug", false); + } + @Override public String[] getCachePermissions() { return null; } + @Override + public boolean getDebug() { + return debug; + } + @Override + public void setDebug(final boolean debug) { + this.debug = debug; + } + + } diff --git a/src/fr/neatmonster/nocheatplus/checks/access/AsyncCheckConfig.java b/src/fr/neatmonster/nocheatplus/checks/access/AsyncCheckConfig.java index f3fc355e..ed281f18 100644 --- a/src/fr/neatmonster/nocheatplus/checks/access/AsyncCheckConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/access/AsyncCheckConfig.java @@ -1,5 +1,7 @@ package fr.neatmonster.nocheatplus.checks.access; +import fr.neatmonster.nocheatplus.config.ConfigFile; + /** * CheckConfig for async checks such as chat, adding permissions to cache. * @author mc_dev @@ -12,9 +14,12 @@ public abstract class AsyncCheckConfig extends ACheckConfig { /** * - * @param cachePermissions Permissions to hold in player data cache. + * @param config + * @param pathPrefix Path prefix for the check section (example for use: prefix+"debug"). + * @param cachePermissions cachePermissions Permissions to hold in player data cache. */ - public AsyncCheckConfig(String[] cachePermissions){ + public AsyncCheckConfig(final ConfigFile config, final String pathPrefix, final String[] cachePermissions){ + super(config, pathPrefix); this.cachePermissions = cachePermissions; } diff --git a/src/fr/neatmonster/nocheatplus/checks/access/ICheckConfig.java b/src/fr/neatmonster/nocheatplus/checks/access/ICheckConfig.java index 6035a289..0faaf539 100644 --- a/src/fr/neatmonster/nocheatplus/checks/access/ICheckConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/access/ICheckConfig.java @@ -28,6 +28,12 @@ public interface ICheckConfig { */ public boolean isEnabled(CheckType checkType); + /** On the fly debug flags, to be set by commands and similar. */ + public boolean getDebug(); + + /** On the fly debug flags, to be set by commands and similar. */ + public void setDebug(boolean debug); + /** * Retrieve the permissions that have to be updated for this check. * @return An array of permissions, may be null. diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakConfig.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakConfig.java index 5a9731a4..33d0c793 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakConfig.java @@ -116,6 +116,7 @@ public class BlockBreakConfig extends ACheckConfig { * the data */ public BlockBreakConfig(final ConfigFile data) { + super(data, ConfPaths.BLOCKBREAK); directionCheck = data.getBoolean(ConfPaths.BLOCKBREAK_DIRECTION_CHECK); directionActions = data.getActionList(ConfPaths.BLOCKBREAK_DIRECTION_ACTIONS, Permissions.BLOCKBREAK_DIRECTION); diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java index 97dd4837..37ff2e6a 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java @@ -88,7 +88,7 @@ public class FastBreak extends Check { data.fastBreakVL *= 0.9D; } - if (cc.fastBreakDebug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){ + if ((cc.fastBreakDebug || cc.debug) && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){ // General stats: if (data.stats != null){ data.stats.addStats(data.stats.getId(Integer.toString(block.getTypeId())+"u", true), elapsedTime); diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/WrongBlock.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/WrongBlock.java index f5311a54..2efdf364 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockbreak/WrongBlock.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/WrongBlock.java @@ -54,7 +54,7 @@ public class WrongBlock extends Check { if (wrongBlock){ // Manhattan distance. - if (cc.fastBreakDebug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){ + if ((cc.fastBreakDebug || cc.debug) && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){ player.sendMessage("WrongBlock failure with dist: " + dist); } data.wrongBlockVL.add(now, (float) (dist + 1) / 2f); diff --git a/src/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractConfig.java b/src/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractConfig.java index b7651f32..3561cdd6 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractConfig.java @@ -84,6 +84,7 @@ public class BlockInteractConfig extends ACheckConfig { * the data */ public BlockInteractConfig(final ConfigFile data) { + super(data, ConfPaths.BLOCKINTERACT); directionCheck = data.getBoolean(ConfPaths.BLOCKINTERACT_DIRECTION_CHECK); directionActions = data.getActionList(ConfPaths.BLOCKINTERACT_DIRECTION_ACTIONS, Permissions.BLOCKINTERACT_DIRECTION); diff --git a/src/fr/neatmonster/nocheatplus/checks/blockplace/BlockPlaceConfig.java b/src/fr/neatmonster/nocheatplus/checks/blockplace/BlockPlaceConfig.java index 0ea60cff..0264abda 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockplace/BlockPlaceConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockplace/BlockPlaceConfig.java @@ -96,6 +96,7 @@ public class BlockPlaceConfig extends ACheckConfig { * the data */ public BlockPlaceConfig(final ConfigFile data) { + super(data, ConfPaths.BLOCKPLACE); directionCheck = data.getBoolean(ConfPaths.BLOCKPLACE_DIRECTION_CHECK); directionActions = data.getActionList(ConfPaths.BLOCKPLACE_DIRECTION_ACTIONS, Permissions.BLOCKPLACE_DIRECTION); diff --git a/src/fr/neatmonster/nocheatplus/checks/chat/ChatConfig.java b/src/fr/neatmonster/nocheatplus/checks/chat/ChatConfig.java index 7433e49a..92dafb7a 100644 --- a/src/fr/neatmonster/nocheatplus/checks/chat/ChatConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/chat/ChatConfig.java @@ -149,7 +149,7 @@ public class ChatConfig extends AsyncCheckConfig { * the data */ public ChatConfig(final ConfigFile config) { - super(new String[]{ + super(config, ConfPaths.CHAT, new String[]{ // Only the permissions needed for async. checking. Permissions.CHAT_COLOR, Permissions.CHAT_TEXT, diff --git a/src/fr/neatmonster/nocheatplus/checks/chat/Text.java b/src/fr/neatmonster/nocheatplus/checks/chat/Text.java index 92f276f7..b63b1e0c 100644 --- a/src/fr/neatmonster/nocheatplus/checks/chat/Text.java +++ b/src/fr/neatmonster/nocheatplus/checks/chat/Text.java @@ -101,7 +101,7 @@ public class Text extends AsyncCheck implements INotifyReload{ boolean cancel = false; - boolean debug = cc.textDebug; + boolean debug = cc.textDebug || cc.debug; final List debugParts; if (debug){ diff --git a/src/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java b/src/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java index 114e34e2..0808f51f 100644 --- a/src/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java @@ -64,6 +64,7 @@ public class CombinedConfig extends ACheckConfig { public final int yawRatePenaltyMin; public CombinedConfig(final ConfigFile config) { + super(config, ConfPaths.COMBINED); improbableCheck = config.getBoolean(ConfPaths.COMBINED_IMPROBABLE_CHECK, false); improbableLevel = (float) config.getDouble(ConfPaths.COMBINED_IMPROBABLE_LEVEL, 300); improbableActions = config.getActionList(ConfPaths.COMBINED_IMPROBABLE_ACTIONS, Permissions.COMBINED_IMPROBABLE); diff --git a/src/fr/neatmonster/nocheatplus/checks/fight/FightConfig.java b/src/fr/neatmonster/nocheatplus/checks/fight/FightConfig.java index 8c2c6a2c..d6e9adc4 100644 --- a/src/fr/neatmonster/nocheatplus/checks/fight/FightConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/fight/FightConfig.java @@ -116,6 +116,7 @@ public class FightConfig extends ACheckConfig { * the data */ public FightConfig(final ConfigFile data) { + super(data, ConfPaths.FIGHT); angleCheck = data.getBoolean(ConfPaths.FIGHT_ANGLE_CHECK); angleThreshold = data.getInt(ConfPaths.FIGHT_ANGLE_THRESHOLD); angleActions = data.getActionList(ConfPaths.FIGHT_ANGLE_ACTIONS, Permissions.FIGHT_ANGLE); diff --git a/src/fr/neatmonster/nocheatplus/checks/inventory/InventoryConfig.java b/src/fr/neatmonster/nocheatplus/checks/inventory/InventoryConfig.java index 91b98816..0fffd1e7 100644 --- a/src/fr/neatmonster/nocheatplus/checks/inventory/InventoryConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/inventory/InventoryConfig.java @@ -94,6 +94,7 @@ public class InventoryConfig extends ACheckConfig { * the data */ public InventoryConfig(final ConfigFile data) { + super(data, ConfPaths.INVENTORY); dropCheck = data.getBoolean(ConfPaths.INVENTORY_DROP_CHECK); dropLimit = data.getInt(ConfPaths.INVENTORY_DROP_LIMIT); dropTimeFrame = data.getLong(ConfPaths.INVENTORY_DROP_TIMEFRAME); diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java b/src/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java index 3482bf1b..0737d1f7 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java @@ -106,6 +106,7 @@ public class MovingConfig extends ACheckConfig { * the data */ public MovingConfig(final ConfigFile data) { + super(data, ConfPaths.MOVING); ignoreCreative = data.getBoolean(ConfPaths.MOVING_CREATIVEFLY_IGNORECREATIVE); ignoreAllowFlight = data.getBoolean(ConfPaths.MOVING_CREATIVEFLY_IGNOREALLOWFLIGHT); diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/MovingData.java b/src/fr/neatmonster/nocheatplus/checks/moving/MovingData.java index 658dc6e6..b224f503 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/MovingData.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/MovingData.java @@ -115,6 +115,12 @@ public class MovingData extends ACheckData { public boolean survivalFlyWasInBed; public long survivalFlyCobwebTime; public double survivalFlyCobwebVL; + + // Accounting info. + // TODO: optimize later. +// public final ActionFrequency hDistSum = new ActionFrequency(3, 333); +// public final ActionFrequency vDistSum = new ActionFrequency(3, 333); +// public final ActionFrequency hvDistCount = new ActionFrequency(3, 333); // Locations shared between all checks. public final PlayerLocation from = new PlayerLocation(); @@ -131,6 +137,10 @@ public class MovingData extends ACheckData { noFallFallDistance = 0D; survivalFlyJumpPhase = 0; setBack = null; +// final long now = System.currentTimeMillis(); +// hDistSum.clear(now); +// vDistSum.clear(now); +// hvDistCount.clear(now); clearNoFallData(); } diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java b/src/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java index 288e75f7..2b153bdf 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java @@ -470,10 +470,14 @@ public class MovingListener implements Listener { * |_| |_|\__,_|\__, |\___|_| \_/ \___|_|\___/ \___|_|\__|\__, | * |___/ |___/ */ - final MovingData data = MovingData.getData(event.getPlayer()); - + final Player player = event.getPlayer(); + final MovingData data = MovingData.getData(player); + final MovingConfig cc = MovingConfig.getConfig(player); + final Vector velocity = event.getVelocity(); - + + if (cc.debug) System.out.println(event.getPlayer().getName() + " new velocity: " + velocity); + double newVal = velocity.getY(); if (newVal >= 0D) { data.verticalVelocity += newVal; diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java b/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java index 7d491b62..c6d6aea5 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java @@ -89,6 +89,7 @@ public class SurvivalFly extends Check { * @return the location */ public Location check(final Player player, final MovingData data, final MovingConfig cc) { + final long now = System.currentTimeMillis(); final PlayerLocation from = data.from; final PlayerLocation to = data.to; @@ -227,7 +228,6 @@ public class SurvivalFly extends Check { data.jumpAmplifier = 0; vDistanceAboveLimit = to.getY() - from.getY(); if (cc.survivalFlyCobwebHack && vDistanceAboveLimit > 0 && hDistanceAboveLimit <= 0){ - final long now = System.currentTimeMillis(); if (now - data.survivalFlyCobwebTime > 3000){ data.survivalFlyCobwebTime = now; data.survivalFlyCobwebVL = vDistanceAboveLimit * 100D; @@ -267,10 +267,19 @@ public class SurvivalFly extends Check { // Slowly reduce the level with each event. data.survivalFlyVL *= 0.95D; -// System.out.println("vertical freedom: " + data.verticalFreedom + " ("+data.verticalVelocity+"/"+data.verticalVelocityCounter+")"); - // Did the player move in unexpected ways? -// System.out.println("hDist: " + hDistance + " / " + hAllowedDistance + " , vDist: " + (to.getY() - from.getY()) + " ("+player.getVelocity().getY()+")" + " / " + vAllowedDistance + " / from passable: " + BlockProperties.isPassable(from)); -// System.out.println(from.getY() +"(" + player.getLocation().getY() + ") -> " + to.getY()) ; + +// data.hDistSum.add(now, (float) hDistance); +// data.vDistSum.add(now, (float) (to.getY() - from.getY())); +// data.hvDistCount.add(now, 1f); + + if (cc.debug){ + System.out.println(player.getName() + " vertical freedom: " + data.verticalFreedom + " ("+data.verticalVelocity+"/"+data.verticalVelocityCounter+")"); + System.out.println(player.getName() + " hDist: " + hDistance + " / " + hAllowedDistance + " , vDist: " + (to.getY() - from.getY()) + " ("+player.getVelocity().getY()+")" + " / " + vAllowedDistance + " / from passable: " + BlockProperties.isPassable(from)); + System.out.println(player.getName() + " y: " + from.getY() +"(" + player.getLocation().getY() + ") -> " + to.getY()) ; +// System.out.println(player.getName() + " h=" + data.hDistSum.getScore(1f)+"/" + data.hDistSum.getScore(1) + " , v=" + data.vDistSum.getScore(1f)+"/"+data.vDistSum.getScore(1) ); + } + + // Did the player move in unexpected ways?// Did the player move in unexpected ways? if (result > 0D) { // System.out.println(BlockProperties.isStairs(from.getTypeIdBelow()) + " / " + BlockProperties.isStairs(to.getTypeIdBelow())); // Increment violation counter. diff --git a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java index 438583de..ec6cd083 100644 --- a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java +++ b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java @@ -70,7 +70,7 @@ public abstract class ConfPaths { * 888 88b, 888 Y888 888P Y888 , 888 b 888 88b, 888 888 , ,ee 888 888 b * 888 88P' 888 "88 88" "88,e8' 888 8b 888 88P' 888 "YeeP" "88 888 888 8b */ - private static final String BLOCKBREAK = CHECKS + "blockbreak."; + public static final String BLOCKBREAK = CHECKS + "blockbreak."; private static final String BLOCKBREAK_DIRECTION = BLOCKBREAK + "direction."; public static final String BLOCKBREAK_DIRECTION_CHECK = BLOCKBREAK_DIRECTION + "active"; @@ -126,7 +126,7 @@ public abstract class ConfPaths { * 888 88b, 888 Y888 888P Y888 , 888 b 888 888 888 888 888 , 888 ,ee 888 Y888 , 888 * 888 88P' 888 "88 88" "88,e8' 888 8b 888 888 888 888 "YeeP" 888 "88 888 "88,e8' 888 */ - private static final String BLOCKINTERACT = CHECKS + "blockinteract."; + public static final String BLOCKINTERACT = CHECKS + "blockinteract."; private static final String BLOCKINTERACT_DIRECTION = BLOCKINTERACT + "direction."; public static final String BLOCKINTERACT_DIRECTION_CHECK = BLOCKINTERACT_DIRECTION + "active"; @@ -143,7 +143,7 @@ public abstract class ConfPaths { * 888 88b, 888 Y888 888P Y888 , 888 b 888 888 ,ee 888 Y888 , 888 , * 888 88P' 888 "88 88" "88,e8' 888 8b 888 888 "88 888 "88,e8' "YeeP" */ - private static final String BLOCKPLACE = CHECKS + "blockplace."; + public static final String BLOCKPLACE = CHECKS + "blockplace."; private static final String BLOCKPLACE_DIRECTION = BLOCKPLACE + "direction."; public static final String BLOCKPLACE_DIRECTION_CHECK = BLOCKPLACE_DIRECTION + "active"; @@ -175,7 +175,7 @@ public abstract class ConfPaths { * Y888 ,d 888 888 ,ee 888 888 * "88,d88 888 888 "88 888 888 */ - private static final String CHAT = CHECKS + "chat."; + public static final String CHAT = CHECKS + "chat."; private static final String CHAT_CAPTCHA = CHAT + "captcha."; public static final String CHAT_CAPTCHA_CHECK = CHAT_CAPTCHA + "active"; @@ -293,7 +293,7 @@ public abstract class ConfPaths { /* * Combined ! */ - private static final String COMBINED = CHECKS + "combined."; + public static final String COMBINED = CHECKS + "combined."; private static final String COMBINED_IMPROBABLE = COMBINED + "improbable."; public static final String COMBINED_IMPROBABLE_CHECK = COMBINED_IMPROBABLE + "active"; @@ -331,7 +331,7 @@ public abstract class ConfPaths { * , 88P * "8",P" */ - private static final String FIGHT = CHECKS + "fight."; + public static final String FIGHT = CHECKS + "fight."; public static final String FIGHT_CANCELDEAD = FIGHT + "canceldead"; @@ -402,7 +402,7 @@ public abstract class ConfPaths { * 888 * 888 */ - private static final String INVENTORY = CHECKS + "inventory."; + public static final String INVENTORY = CHECKS + "inventory."; private static final String INVENTORY_DROP = INVENTORY + "drop."; public static final String INVENTORY_DROP_CHECK = INVENTORY_DROP + "active"; @@ -431,7 +431,7 @@ public abstract class ConfPaths { * , 88P * "8",P" */ - private static final String MOVING = CHECKS + "moving."; + public static final String MOVING = CHECKS + "moving."; private static final String MOVING_CREATIVEFLY = MOVING + "creativefly."; public static final String MOVING_CREATIVEFLY_CHECK = MOVING_CREATIVEFLY + "active";