mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-02 13:57:49 +01:00
Add per check section debug flag support.
This commit is contained in:
parent
0ebb8b60d3
commit
5baaedce74
@ -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.");
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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<String> debugParts;
|
||||
if (debug){
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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";
|
||||
|
Loading…
Reference in New Issue
Block a user