diff --git a/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/FlyingFrequency.java b/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/FlyingFrequency.java index faeb7d89..7ee645ee 100644 --- a/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/FlyingFrequency.java +++ b/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/FlyingFrequency.java @@ -1,8 +1,6 @@ package fr.neatmonster.nocheatplus.checks.net.protocollib; -import java.util.HashMap; import java.util.List; -import java.util.Map; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; @@ -13,14 +11,16 @@ import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import fr.neatmonster.nocheatplus.NCPAPIProvider; +import fr.neatmonster.nocheatplus.checks.Check; +import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.checks.moving.MovingData; import fr.neatmonster.nocheatplus.checks.net.NetConfig; import fr.neatmonster.nocheatplus.checks.net.NetConfigCache; -import fr.neatmonster.nocheatplus.components.JoinLeaveListener; +import fr.neatmonster.nocheatplus.checks.net.NetData; +import fr.neatmonster.nocheatplus.checks.net.NetDataFactory; import fr.neatmonster.nocheatplus.logging.Streams; import fr.neatmonster.nocheatplus.stats.Counters; import fr.neatmonster.nocheatplus.time.monotonic.Monotonic; -import fr.neatmonster.nocheatplus.utilities.ActionFrequency; import fr.neatmonster.nocheatplus.utilities.CheckUtils; import fr.neatmonster.nocheatplus.utilities.TrigUtil; @@ -31,66 +31,36 @@ import fr.neatmonster.nocheatplus.utilities.TrigUtil; * @author dev1mc * */ -public class FlyingFrequency extends PacketAdapter implements JoinLeaveListener { +public class FlyingFrequency extends PacketAdapter { + // Setup for flying packets. + public static final int numBooleans = 3; + public static final int indexOnGround = 0; + public static final int indexhasPos = 1; + public static final int indexhasLook = 2; + + // Thresholds for firing moving events (CraftBukkit). public static final double minMoveDistSq = 1f / 256; // PlayerConnection magic. - public static final float minLookChange = 10f; - // TODO: Most efficient registration + optimize (primary thread or asynchronous). + /** Dummy check to access hasBypass for FlyingFrequency. */ + private final Check frequency = new Check(CheckType.NET_FLYINGFREQUENCY) { + // Dummy check to access hasBypass. + }; - private class FFData { - public static final int numBooleans = 3; - public static final int indexOnGround = 0; - public static final int indexhasPos = 1; - public static final int indexhasLook = 2; - - public final ActionFrequency all; - // Last move on-ground. - public boolean onGround = false; - public long timeOnGround = 0; - public long timeNotOnGround = 0; - - public FFData(int seconds) { - all = new ActionFrequency(seconds, 1000L); - } - } - - private final Map freqMap = new HashMap(); private final Counters counters = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(Counters.class); - private final int idSilent = counters.registerKey("packet.flying.silentcancel"); - private final int idRedundant = counters.registerKey("packet.flying.silentcancel.redundant"); private final int idNullPlayer = counters.registerKey("packet.flying.nullplayer"); private boolean cancelRedundant = true; private final NetConfigCache configs; + private final NetDataFactory dataFactory; - public FlyingFrequency(NetConfigCache configs, Plugin plugin) { + public FlyingFrequency(Plugin plugin) { // PacketPlayInFlying[3, legacy: 10] super(plugin, PacketType.Play.Client.FLYING); // TODO: How does POS and POS_LOOK relate/translate? - this.configs = configs; - } - - @Override - public void playerJoins(Player player) { - // Ignore. - } - - @Override - public void playerLeaves(Player player) { - freqMap.remove(player.getName()); - } - - private FFData getData(final String name, final NetConfig cc) { - final FFData freq = this.freqMap.get(name); - if (freq != null) { - return freq; - } else { - final FFData newFreq = new FFData(cc.flyingFrequencySeconds); - this.freqMap.put(name, newFreq); - return newFreq; - } + this.configs = (NetConfigCache) CheckType.NET.getConfigFactory(); + this.dataFactory = (NetDataFactory) CheckType.NET.getDataFactory(); } @Override @@ -109,32 +79,32 @@ public class FlyingFrequency extends PacketAdapter implements JoinLeaveListener return; } - final FFData data = getData(player.getName(), cc); - final long t = System.currentTimeMillis(); + final NetData data = dataFactory.getData(player); + final long time = Monotonic.millis(); // Counting all packets. - data.all.add(t, 1f); - final float allScore = data.all.score(1f); - if (allScore > cc.flyingFrequencyMaxPackets) { - counters.add(idSilent, 1); // Until it is sure if we can get these async. + // TODO: Consider using the NetStatic check. + data.flyingFrequencyAll.add(time, 1f); + final float allScore = data.flyingFrequencyAll.score(1f); + if (allScore / cc.flyingFrequencySeconds > cc.flyingFrequencyPPS && !frequency.hasBypass(player) && frequency.executeActions(player, allScore / cc.flyingFrequencySeconds - cc.flyingFrequencyPPS, 1.0 / cc.flyingFrequencySeconds, cc.flyingFrequencyActions, true)) { event.setCancelled(true); return; } // Cancel redundant packets, when frequency is high anyway. - if (cancelRedundant && cc.flyingFrequencyCancelRedundant && checkRedundantPackets(player, event, allScore, data, cc)) { + if (cancelRedundant && cc.flyingFrequencyRedundantActive && checkRedundantPackets(player, event, allScore, time, data, cc) ) { event.setCancelled(true); } } - private boolean checkRedundantPackets(final Player player, final PacketEvent event, final float allScore, final FFData data, final NetConfig cc) { + private boolean checkRedundantPackets(final Player player, final PacketEvent event, final float allScore, final long time, final NetData data, final NetConfig cc) { // TODO: Consider quick return conditions. // TODO: Debug logging (better with integration into DataManager). // TODO: Consider to compare to moving data directly, skip keeping track extra. final PacketContainer packet = event.getPacket(); final List booleans = packet.getBooleans().getValues(); - if (booleans.size() != FFData.numBooleans) { + if (booleans.size() != FlyingFrequency.numBooleans) { return packetMismatch(); } @@ -143,30 +113,29 @@ public class FlyingFrequency extends PacketAdapter implements JoinLeaveListener // Can not check. return false; } - final boolean hasPos = booleans.get(FFData.indexhasPos).booleanValue(); - final boolean hasLook = booleans.get(FFData.indexhasLook).booleanValue(); - final boolean onGround = booleans.get(FFData.indexOnGround).booleanValue(); + final boolean hasPos = booleans.get(FlyingFrequency.indexhasPos).booleanValue(); + final boolean hasLook = booleans.get(FlyingFrequency.indexhasLook).booleanValue(); + final boolean onGround = booleans.get(FlyingFrequency.indexOnGround).booleanValue(); boolean onGroundSkip = false; // Allow at least one on-ground change per state and second. // TODO: Consider to verify on ground somehow (could tell MovingData the state). - if (onGround != data.onGround) { - // Regard as not redundant only if sending the same state happened at least a second ago. - final long time = Monotonic.millis(); + if (onGround != data.flyingFrequencyOnGround) { + // Regard as not redundant only if sending the same state happened at least a second ago. final long lastTime; if (onGround) { - lastTime = data.timeOnGround; - data.timeOnGround = time; + lastTime = data.flyingFrequencyTimeOnGround; + data.flyingFrequencyTimeOnGround = time; } else { - lastTime = data.timeNotOnGround; - data.timeNotOnGround = time; + lastTime = data.flyingFrequencyTimeNotOnGround; + data.flyingFrequencyTimeNotOnGround = time; } if (time - lastTime > 1000) { // Override onGroundSkip = true; } } - data.onGround = onGround; + data.flyingFrequencyOnGround = onGround; if (hasPos) { final List doubles = packet.getDoubles().getValues(); @@ -206,13 +175,15 @@ public class FlyingFrequency extends PacketAdapter implements JoinLeaveListener return false; } - // TODO: Could check first bucket or even just 50 ms to last packet. - if (allScore / cc.flyingFrequencySeconds > 20f) { - counters.add(idRedundant, 1); - return true; - } else { - return false; + // Packet is redundant, if more than 20 packets per second arrive. + if (allScore / cc.flyingFrequencySeconds > 20f && !frequency.hasBypass(player)) { + // (Must re-check bypass here.) + data.flyingFrequencyRedundantFreq.add(time, 1f); + if (frequency.executeActions(player, data.flyingFrequencyRedundantFreq.score(1f) / cc.flyingFrequencyRedundantSeconds, 1.0 / cc.flyingFrequencyRedundantSeconds, cc.flyingFrequencyRedundantActions, true)) { + return true; + } } + return false; } /** diff --git a/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/ProtocolLibComponent.java b/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/ProtocolLibComponent.java index 41ae7e31..e0c4720b 100644 --- a/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/ProtocolLibComponent.java +++ b/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/ProtocolLibComponent.java @@ -12,7 +12,7 @@ import com.comphenix.protocol.ProtocolManager; import com.comphenix.protocol.events.PacketAdapter; import fr.neatmonster.nocheatplus.NCPAPIProvider; -import fr.neatmonster.nocheatplus.checks.net.NetConfigCache; +import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.components.DisableListener; import fr.neatmonster.nocheatplus.components.INotifyReload; import fr.neatmonster.nocheatplus.components.NoCheatPlusAPI; @@ -28,7 +28,6 @@ import fr.neatmonster.nocheatplus.utilities.StringUtil; */ public class ProtocolLibComponent implements DisableListener, INotifyReload { - private final NetConfigCache configs = new NetConfigCache(); private final List registeredPacketAdapters = new LinkedList(); public ProtocolLibComponent(Plugin plugin) { @@ -75,7 +74,7 @@ public class ProtocolLibComponent implements DisableListener, INotifyReload { private void register(Class clazz, Plugin plugin) { try { // Construct a new instance using reflection. - PacketAdapter adapter = clazz.getDeclaredConstructor(NetConfigCache.class, Plugin.class).newInstance(configs, plugin); + PacketAdapter adapter = clazz.getDeclaredConstructor(Plugin.class).newInstance(plugin); ProtocolLibrary.getProtocolManager().addPacketListener(adapter); registeredPacketAdapters.add(adapter); } catch (Throwable t) { @@ -92,6 +91,7 @@ public class ProtocolLibComponent implements DisableListener, INotifyReload { @Override public void onReload() { unregister(); + CheckType.NET.getDataFactory().removeAllData(); // Currently needed for FlyingFRequency. register(Bukkit.getPluginManager().getPlugin("NoCheatPlus")); // Store instead ? } @@ -107,7 +107,6 @@ public class ProtocolLibComponent implements DisableListener, INotifyReload { } } registeredPacketAdapters.clear(); - configs.clearAllConfigs(); } } diff --git a/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/SoundDistance.java b/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/SoundDistance.java index a3f2b58c..72d1fa0b 100644 --- a/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/SoundDistance.java +++ b/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/SoundDistance.java @@ -10,6 +10,7 @@ import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.reflect.StructureModifier; +import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.checks.net.NetConfig; import fr.neatmonster.nocheatplus.checks.net.NetConfigCache; import fr.neatmonster.nocheatplus.utilities.TrigUtil; @@ -38,9 +39,9 @@ public class SoundDistance extends PacketAdapter { private final NetConfigCache configs; private final Location useLoc = new Location(null, 0, 0, 0); - public SoundDistance(NetConfigCache configs, Plugin plugin) { + public SoundDistance(Plugin plugin) { super(plugin, PacketType.Play.Server.NAMED_SOUND_EFFECT); - this.configs = configs; + this.configs = (NetConfigCache) CheckType.NET.getConfigFactory(); // TODO: DataManager.getConfig(NetConfigCache.class); } @Override diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/Check.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/Check.java index 36b63276..c8ff45d3 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/Check.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/Check.java @@ -160,7 +160,8 @@ public abstract class Check implements MCAccessHolder{ } /** - * Checks if this check is enabled for the specified player. + * Checks both configuration flags and if the player is exempted from this + * check (hasBypass). * * @param player * the player @@ -170,17 +171,29 @@ public abstract class Check implements MCAccessHolder{ if (!type.isEnabled(player)) { return false; } + return !hasBypass(player); + } + + /** + * Check if the player is exempted by permissions or otherwise. + * + * @param player + * @return + */ + public boolean hasBypass(final Player player) { // TODO: Checking for the thread might be a temporary measure. if (Bukkit.isPrimaryThread()) { // Check permissions directly. - if (player.hasPermission(type.getPermission())) { - return false; + final String permission = type.getPermission(); + if (permission != null && player.hasPermission(permission)) { + return true; } } else if (type.hasCachedPermission(player)) { // Assume asynchronously running check. - return false; + return true; } + // TODO: ExemptionManager relies on initial setup (problematic). return !NCPExemptionManager.isExempted(player, type); } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/CheckType.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/CheckType.java index 175c32c2..d89d1a77 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/CheckType.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/CheckType.java @@ -20,6 +20,8 @@ import fr.neatmonster.nocheatplus.checks.inventory.InventoryConfig; import fr.neatmonster.nocheatplus.checks.inventory.InventoryData; import fr.neatmonster.nocheatplus.checks.moving.MovingConfig; import fr.neatmonster.nocheatplus.checks.moving.MovingData; +import fr.neatmonster.nocheatplus.checks.net.NetConfigCache; +import fr.neatmonster.nocheatplus.checks.net.NetDataFactory; import fr.neatmonster.nocheatplus.permissions.Permissions; /** @@ -60,8 +62,8 @@ public enum CheckType { CHAT_TEXT(CHAT, Permissions.CHAT_TEXT), CHAT_LOGINS(CHAT, Permissions.CHAT_LOGINS), CHAT_RELOG(CHAT, Permissions.CHAT_RELOG), - - + + COMBINED(CombinedConfig.factory, CombinedData.factory, Permissions.COMBINED), COMBINED_BEDLEAVE(COMBINED, Permissions.COMBINED_BEDLEAVE), COMBINED_IMPROBABLE(COMBINED, Permissions.COMBINED_IMPROBABLE), @@ -95,68 +97,76 @@ public enum CheckType { MOVING_NOFALL(MOVING, Permissions.MOVING_NOFALL), MOVING_PASSABLE(MOVING, Permissions.MOVING_PASSABLE), MOVING_SURVIVALFLY(MOVING, Permissions.MOVING_SURVIVALFLY), - + + NET(new NetConfigCache(), new NetDataFactory(), Permissions.NET), + NET_FLYINGFREQUENCY(NET, Permissions.NET_FLYINGFREQUENCY), + NET_SOUNDDISTANCE(NET), // Can not exempt players from this one. + UNKNOWN; - /** If not null, this is the check group usually. */ - private final CheckType parent; + /** If not null, this is the check group usually. */ + private final CheckType parent; - /** The check config factory (access CheckConfig instances by CheckType). */ - private final CheckConfigFactory configFactory; + /** The check config factory (access CheckConfig instances by CheckType). */ + private final CheckConfigFactory configFactory; - /** The check data factory (access CheckData instances by CheckType). */ - private final CheckDataFactory dataFactory; + /** The check data factory (access CheckData instances by CheckType). */ + private final CheckDataFactory dataFactory; - /** The bypass permission. */ - private final String permission; + /** The bypass permission. */ + private final String permission; - /** - * Special purpose check types (likely not actual checks). - */ - private CheckType() { - this(null, null, null); - } - - /** - * Special purpose for grouping (ALL). - * @param permission - */ - private CheckType(final String permission){ - this(null, null, permission); - } - - /** - * Constructor for root checks or check groups, that are not grouped under another check type. - * @param configFactory - * @param dataFactory - * @param permission - */ - private CheckType(final CheckConfigFactory configFactory, final CheckDataFactory dataFactory, final String permission) { - this(null, permission, configFactory, dataFactory); - } + /** + * Special purpose check types (likely not actual checks). + */ + private CheckType() { + this(null, null, null); + } - /** - * Constructor for sub-checks grouped under another check type. - * @param parent - * @param permission - */ - private CheckType(final CheckType parent, final String permission) { - this(parent, permission, parent.getConfigFactory(), parent.getDataFactory()); - } + /** + * Special purpose for grouping (ALL). + * @param permission + */ + private CheckType(final String permission){ + this(null, null, permission); + } - /** - * General constructor (usually used for root check groups). - * @param parent Super check type (usually the group). - * @param permission Bypass permission. - * @param configFactory Check config factory. - * @param dataFactory Check data factory. - */ - private CheckType(final CheckType parent, final String permission, final CheckConfigFactory configFactory, final CheckDataFactory dataFactory) { - this.parent = parent; - this.permission = permission; - this.configFactory = configFactory; - this.dataFactory = dataFactory; - } + private CheckType(final CheckType parent) { + this(parent, null); + } + + /** + * Constructor for root checks or check groups, that are not grouped under another check type. + * @param configFactory + * @param dataFactory + * @param permission + */ + private CheckType(final CheckConfigFactory configFactory, final CheckDataFactory dataFactory, final String permission) { + this(null, permission, configFactory, dataFactory); + } + + /** + * Constructor for sub-checks grouped under another check type. + * @param parent + * @param permission + */ + private CheckType(final CheckType parent, final String permission) { + this(parent, permission, parent.getConfigFactory(), parent.getDataFactory()); + } + + /** + * General constructor (usually used for root check groups). + * @param parent Super check type (usually the group). + * @param permission Bypass permission. + * @param configFactory Check config factory. + * @param dataFactory Check data factory. + */ + private CheckType(final CheckType parent, final String permission, final CheckConfigFactory configFactory, final CheckDataFactory dataFactory) { + this.parent = parent; + this.permission = permission; + this.configFactory = configFactory; + this.dataFactory = dataFactory; + } /** * Gets the configFactory. @@ -202,16 +212,16 @@ public enum CheckType { public String getPermission() { return permission; } - + /** * Quick permission check for cached entriy only (for async checks). If not present, after failure will need to deal with this. * @param player * @return */ public boolean hasCachedPermission(final Player player){ - return hasCachedPermission(player, getPermission()); + return hasCachedPermission(player, getPermission()); } - + /** * Quick permission check for cached entries only (for async checks). If not present, after failure will need to deal with this. * @param player @@ -219,7 +229,7 @@ public enum CheckType { * @return */ public boolean hasCachedPermission(final Player player, final String permission){ - return dataFactory.getData(player).hasCachedPermission(permission); + return dataFactory.getData(player).hasCachedPermission(permission); } /** diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/access/CheckConfigFactory.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/access/CheckConfigFactory.java index 175618fd..b9206132 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/access/CheckConfigFactory.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/access/CheckConfigFactory.java @@ -18,4 +18,9 @@ public interface CheckConfigFactory { */ public ICheckConfig getConfig(Player player); + /** + * Remove all stored configurations. + */ + public void removeAllConfigs(); + } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakConfig.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakConfig.java index 99f7498c..3acc4fa7 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakConfig.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakConfig.java @@ -21,13 +21,18 @@ import fr.neatmonster.nocheatplus.permissions.Permissions; */ public class BlockBreakConfig extends ACheckConfig { - /** The factory creating configurations. */ - public static final CheckConfigFactory factory = new CheckConfigFactory() { - @Override - public final ICheckConfig getConfig(final Player player) { - return BlockBreakConfig.getConfig(player); - } - }; + /** The factory creating configurations. */ + public static final CheckConfigFactory factory = new CheckConfigFactory() { + @Override + public final ICheckConfig getConfig(final Player player) { + return BlockBreakConfig.getConfig(player); + } + + @Override + public void removeAllConfigs() { + clear(); // Band-aid. + } + }; /** The map containing the configurations per world. */ private static final Map worldsMap = new HashMap(); @@ -58,27 +63,27 @@ public class BlockBreakConfig extends ACheckConfig { public final boolean fastBreakCheck; public final boolean fastBreakStrict; - public final int fastBreakBuckets; - public final long fastBreakBucketDur; - public final float fastBreakBucketFactor; - public final long fastBreakGrace; - public final long fastBreakDelay; - public final int fastBreakModSurvival; + public final int fastBreakBuckets; + public final long fastBreakBucketDur; + public final float fastBreakBucketFactor; + public final long fastBreakGrace; + public final long fastBreakDelay; + public final int fastBreakModSurvival; public final ActionList fastBreakActions; - - - public final boolean frequencyCheck; - public final int frequencyBuckets; - public final long frequencyBucketDur; - public final float frequencyBucketFactor; - public final int frequencyIntervalCreative; - public final int frequencyIntervalSurvival; + + + public final boolean frequencyCheck; + public final int frequencyBuckets; + public final long frequencyBucketDur; + public final float frequencyBucketFactor; + public final int frequencyIntervalCreative; + public final int frequencyIntervalSurvival; public final int frequencyShortTermLimit; - public final int frequencyShortTermTicks; - public final ActionList frequencyActions; - - public boolean improbableFastBreakCheck; + public final int frequencyShortTermTicks; + public final ActionList frequencyActions; + + public boolean improbableFastBreakCheck; public final boolean noSwingCheck; public final ActionList noSwingActions; @@ -87,9 +92,9 @@ public class BlockBreakConfig extends ACheckConfig { public final ActionList reachActions; public final boolean wrongBlockCheck; - public final float wrongBLockLevel; - public final ActionList wrongBlockActions; - + public final float wrongBLockLevel; + public final ActionList wrongBlockActions; + /** * Instantiates a new block break configuration. * @@ -120,15 +125,15 @@ public class BlockBreakConfig extends ACheckConfig { frequencyIntervalCreative = data.getInt(ConfPaths.BLOCKBREAK_FREQUENCY_MOD_CREATIVE); frequencyIntervalSurvival = data.getInt(ConfPaths.BLOCKBREAK_FREQUENCY_MOD_SURVIVAL); frequencyShortTermLimit = data.getInt(ConfPaths.BLOCKBREAK_FREQUENCY_SHORTTERM_LIMIT); - frequencyShortTermTicks = data.getInt(ConfPaths.BLOCKBREAK_FREQUENCY_SHORTTERM_TICKS); + frequencyShortTermTicks = data.getInt(ConfPaths.BLOCKBREAK_FREQUENCY_SHORTTERM_TICKS); frequencyActions = data.getOptimizedActionList(ConfPaths.BLOCKBREAK_FREQUENCY_ACTIONS, Permissions.BLOCKBREAK_FREQUENCY); - + noSwingCheck = data.getBoolean(ConfPaths.BLOCKBREAK_NOSWING_CHECK); noSwingActions = data.getOptimizedActionList(ConfPaths.BLOCKBREAK_NOSWING_ACTIONS, Permissions.BLOCKBREAK_NOSWING); reachCheck = data.getBoolean(ConfPaths.BLOCKBREAK_REACH_CHECK); reachActions = data.getOptimizedActionList(ConfPaths.BLOCKBREAK_REACH_ACTIONS, Permissions.BLOCKBREAK_REACH); - + wrongBlockCheck = data.getBoolean(ConfPaths.BLOCKBREAK_WRONGBLOCK_CHECK); wrongBLockLevel = data.getInt(ConfPaths.BLOCKBREAK_WRONGBLOCK_LEVEL); wrongBlockActions = data.getOptimizedActionList(ConfPaths.BLOCKBREAK_WRONGBLOCK_ACTIONS, Permissions.BLOCKBREAK_WRONGBLOCK); @@ -140,22 +145,22 @@ public class BlockBreakConfig extends ACheckConfig { @Override public final boolean isEnabled(final CheckType checkType) { switch (checkType) { - case BLOCKBREAK_DIRECTION: - return directionCheck; - case BLOCKBREAK_FASTBREAK: - return fastBreakCheck; - case BLOCKBREAK_FREQUENCY: - return frequencyCheck; - case BLOCKBREAK_NOSWING: - return noSwingCheck; - case BLOCKBREAK_REACH: - return reachCheck; - case BLOCKBREAK_WRONGBLOCK: - return wrongBlockCheck; - case BLOCKBREAK_BREAK: - return true; - default: - return true; + case BLOCKBREAK_DIRECTION: + return directionCheck; + case BLOCKBREAK_FASTBREAK: + return fastBreakCheck; + case BLOCKBREAK_FREQUENCY: + return frequencyCheck; + case BLOCKBREAK_NOSWING: + return noSwingCheck; + case BLOCKBREAK_REACH: + return reachCheck; + case BLOCKBREAK_WRONGBLOCK: + return wrongBlockCheck; + case BLOCKBREAK_BREAK: + return true; + default: + return true; } } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractConfig.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractConfig.java index eb930744..1f79bba8 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractConfig.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractConfig.java @@ -21,13 +21,18 @@ import fr.neatmonster.nocheatplus.permissions.Permissions; */ public class BlockInteractConfig extends ACheckConfig { - /** The factory creating configurations. */ - public static final CheckConfigFactory factory = new CheckConfigFactory() { - @Override - public final ICheckConfig getConfig(final Player player) { - return BlockInteractConfig.getConfig(player); - } - }; + /** The factory creating configurations. */ + public static final CheckConfigFactory factory = new CheckConfigFactory() { + @Override + public final ICheckConfig getConfig(final Player player) { + return BlockInteractConfig.getConfig(player); + } + + @Override + public void removeAllConfigs() { + clear(); // Band-aid. + } + }; /** The map containing the configurations per world. */ private static final Map worldsMap = new HashMap(); @@ -58,12 +63,12 @@ public class BlockInteractConfig extends ACheckConfig { public final boolean reachCheck; public final ActionList reachActions; - + public final boolean speedCheck; public final long speedInterval; public final int speedLimit; public final ActionList speedActions; - + public final boolean visibleCheck; public final ActionList visibleActions; @@ -81,12 +86,12 @@ public class BlockInteractConfig extends ACheckConfig { reachCheck = data.getBoolean(ConfPaths.BLOCKINTERACT_REACH_CHECK); reachActions = data.getOptimizedActionList(ConfPaths.BLOCKINTERACT_REACH_ACTIONS, Permissions.BLOCKINTERACT_REACH); - + speedCheck = data.getBoolean(ConfPaths.BLOCKINTERACT_SPEED_CHECK); speedInterval = data.getLong(ConfPaths.BLOCKINTERACT_SPEED_INTERVAL); speedLimit = data.getInt(ConfPaths.BLOCKINTERACT_SPEED_LIMIT); speedActions = data.getOptimizedActionList(ConfPaths.BLOCKINTERACT_SPEED_ACTIONS, Permissions.BLOCKINTERACT_SPEED); - + visibleCheck = data.getBoolean(ConfPaths.BLOCKINTERACT_VISIBLE_CHECK); visibleActions = data.getOptimizedActionList(ConfPaths.BLOCKINTERACT_VISIBLE_ACTIONS, Permissions.BLOCKINTERACT_VISIBLE); } @@ -97,16 +102,16 @@ public class BlockInteractConfig extends ACheckConfig { @Override public final boolean isEnabled(final CheckType checkType) { switch (checkType) { - case BLOCKINTERACT_SPEED: - return speedCheck; - case BLOCKINTERACT_DIRECTION: - return directionCheck; - case BLOCKINTERACT_REACH: - return reachCheck; - case BLOCKINTERACT_VISIBLE: - return visibleCheck; - default: - return true; + case BLOCKINTERACT_SPEED: + return speedCheck; + case BLOCKINTERACT_DIRECTION: + return directionCheck; + case BLOCKINTERACT_REACH: + return reachCheck; + case BLOCKINTERACT_VISIBLE: + return visibleCheck; + default: + return true; } } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/blockplace/BlockPlaceConfig.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/blockplace/BlockPlaceConfig.java index 71d7dba2..d0a3c88d 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/blockplace/BlockPlaceConfig.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/blockplace/BlockPlaceConfig.java @@ -24,13 +24,18 @@ import fr.neatmonster.nocheatplus.permissions.Permissions; */ public class BlockPlaceConfig extends ACheckConfig { - /** The factory creating configurations. */ - public static final CheckConfigFactory factory = new CheckConfigFactory() { - @Override - public final ICheckConfig getConfig(final Player player) { - return BlockPlaceConfig.getConfig(player); - } - }; + /** The factory creating configurations. */ + public static final CheckConfigFactory factory = new CheckConfigFactory() { + @Override + public final ICheckConfig getConfig(final Player player) { + return BlockPlaceConfig.getConfig(player); + } + + @Override + public void removeAllConfigs() { + clear(); // Band-aid. + } + }; /** The map containing the configurations per world. */ private static final Map worldsMap = new HashMap(); @@ -55,10 +60,10 @@ public class BlockPlaceConfig extends ACheckConfig { new BlockPlaceConfig(ConfigManager.getConfigFile(player.getWorld().getName()))); return worldsMap.get(player.getWorld().getName()); } - + public final boolean againstCheck; public final ActionList againstActions; - + public final boolean autoSignCheck; public final ActionList autoSignActions; @@ -90,14 +95,14 @@ public class BlockPlaceConfig extends ACheckConfig { */ public BlockPlaceConfig(final ConfigFile data) { super(data, ConfPaths.BLOCKPLACE); - + againstCheck = data.getBoolean(ConfPaths.BLOCKPLACE_AGAINST_CHECK); againstActions = data.getOptimizedActionList(ConfPaths.BLOCKPLACE_AGAINST_ACTIONS, Permissions.BLOCKPLACE_AGAINST); autoSignCheck = data.getBoolean(ConfPaths.BLOCKPLACE_AUTOSIGN_CHECK); autoSignActions = data.getOptimizedActionList(ConfPaths.BLOCKPLACE_AUTOSIGN_ACTIONS, Permissions.BLOCKPLACE_AUTOSIGN); - + directionCheck = data.getBoolean(ConfPaths.BLOCKPLACE_DIRECTION_CHECK); directionActions = data.getOptimizedActionList(ConfPaths.BLOCKPLACE_DIRECTION_ACTIONS, Permissions.BLOCKPLACE_DIRECTION); @@ -125,22 +130,22 @@ public class BlockPlaceConfig extends ACheckConfig { @Override public final boolean isEnabled(final CheckType checkType) { switch (checkType) { - case BLOCKPLACE_DIRECTION: - return directionCheck; - case BLOCKPLACE_FASTPLACE: - return fastPlaceCheck; - case BLOCKPLACE_NOSWING: - return noSwingCheck; - case BLOCKPLACE_REACH: - return reachCheck; - case BLOCKPLACE_SPEED: - return speedCheck; - case BLOCKPLACE_AGAINST: - return againstCheck; - case BLOCKPLACE_AUTOSIGN: - return autoSignCheck; - default: - return true; + case BLOCKPLACE_DIRECTION: + return directionCheck; + case BLOCKPLACE_FASTPLACE: + return fastPlaceCheck; + case BLOCKPLACE_NOSWING: + return noSwingCheck; + case BLOCKPLACE_REACH: + return reachCheck; + case BLOCKPLACE_SPEED: + return speedCheck; + case BLOCKPLACE_AGAINST: + return againstCheck; + case BLOCKPLACE_AUTOSIGN: + return autoSignCheck; + default: + return true; } } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/chat/ChatConfig.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/chat/ChatConfig.java index 84a22346..3efac810 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/chat/ChatConfig.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/chat/ChatConfig.java @@ -25,15 +25,20 @@ public class ChatConfig extends ACheckConfig { /** The factory creating configurations. */ public static final CheckConfigFactory factory = new CheckConfigFactory() { - @Override - public final ICheckConfig getConfig(final Player player) { - return ChatConfig.getConfig(player); - } - }; + @Override + public final ICheckConfig getConfig(final Player player) { + return ChatConfig.getConfig(player); + } + + @Override + public void removeAllConfigs() { + clear(); // Band-aid. + } + }; /** The map containing the configurations per world. */ private static final Map worldsMap = new HashMap(); - + /** * Clear all the configurations. */ @@ -43,7 +48,7 @@ public class ChatConfig extends ACheckConfig { } } - /** + /** * Gets the configuration for a specified player. * * @param player @@ -58,7 +63,7 @@ public class ChatConfig extends ACheckConfig { return worldsMap.get(player.getWorld().getName()); } } - + public final boolean captchaCheck; public final String captchaCharacters; public final int captchaLength; @@ -69,19 +74,19 @@ public class ChatConfig extends ACheckConfig { public final boolean colorCheck; public final ActionList colorActions; - + public final boolean commandsCheck; public final double commandsLevel; public final int commandsShortTermTicks; public final double commandsShortTermLevel; public final ActionList commandsActions; - + public final boolean textCheck; - public final boolean textGlobalCheck; - public final boolean textPlayerCheck; - public final EnginePlayerConfig textEnginePlayerConfig; - public final float textFreqNormFactor; - public final float textFreqNormWeight; + public final boolean textGlobalCheck; + public final boolean textPlayerCheck; + public final EnginePlayerConfig textEnginePlayerConfig; + public final float textFreqNormFactor; + public final float textFreqNormWeight; public final float textFreqNormMin; public final double textFreqNormLevel; public final ActionList textFreqNormActions; @@ -91,29 +96,29 @@ public class ChatConfig extends ACheckConfig { public final float textFreqShortTermMin; public final ActionList textFreqShortTermActions; public final float textMessageLetterCount; - public final float textMessageUpperCase; + public final float textMessageUpperCase; public final float textMessagePartition; public final float textMsgRepeatCancel; public final float textMsgAfterJoin; public final float textMsgRepeatSelf; public final float textMsgRepeatGlobal; public final float textMsgNoMoving; - + // words public final float textMessageLengthAv; public final float textMessageLengthMsg; public final float textMessageNoLetter; - public final float textGlobalWeight; - public final float textPlayerWeight; - public final boolean textEngineMaximum; - public final boolean textAllowVLReset; - public final boolean textDebug; - + public final float textGlobalWeight; + public final float textPlayerWeight; + public final boolean textEngineMaximum; + public final boolean textAllowVLReset; + public final boolean textDebug; + public final boolean chatWarningCheck; public final float chatWarningLevel; public final String chatWarningMessage; public final long chatWarningTimeout; - + public final boolean loginsCheck; public final boolean loginsPerWorldCount; public final int loginsSeconds; @@ -124,7 +129,7 @@ public class ChatConfig extends ACheckConfig { public final boolean consoleOnlyCheck; public final String consoleOnlyMessage; - + public final boolean relogCheck; public final String relogKickMessage; public final long relogTimeout; @@ -132,7 +137,7 @@ public class ChatConfig extends ACheckConfig { public final int relogWarningNumber; public final long relogWarningTimeout; public final ActionList relogActions; - + /** * Instantiates a new chat configuration. * @@ -140,13 +145,13 @@ public class ChatConfig extends ACheckConfig { * the data */ public ChatConfig(final ConfigFile config) { - super(config, ConfPaths.CHAT, new String[]{ - // Only the permissions needed for async. checking. - Permissions.CHAT_COLOR, - Permissions.CHAT_TEXT, - Permissions.CHAT_CAPTCHA, - }); - + super(config, ConfPaths.CHAT, new String[]{ + // Only the permissions needed for async. checking. + Permissions.CHAT_COLOR, + Permissions.CHAT_TEXT, + Permissions.CHAT_CAPTCHA, + }); + captchaCheck = config.getBoolean(ConfPaths.CHAT_CAPTCHA_CHECK); captchaCharacters = config.getString(ConfPaths.CHAT_CAPTCHA_CHARACTERS); captchaLength = config.getInt(ConfPaths.CHAT_CAPTCHA_LENGTH); @@ -154,20 +159,20 @@ public class ChatConfig extends ACheckConfig { captchaSuccess = config.getString(ConfPaths.CHAT_CAPTCHA_SUCCESS); captchaTries = config.getInt(ConfPaths.CHAT_CAPTCHA_TRIES); captchaActions = config.getOptimizedActionList(ConfPaths.CHAT_CAPTCHA_ACTIONS, Permissions.CHAT_CAPTCHA); - + colorCheck = config.getBoolean(ConfPaths.CHAT_COLOR_CHECK); colorActions = config.getOptimizedActionList(ConfPaths.CHAT_COLOR_ACTIONS, Permissions.CHAT_COLOR); - + commandsCheck = config.getBoolean(ConfPaths.CHAT_COMMANDS_CHECK); commandsLevel = config.getDouble(ConfPaths.CHAT_COMMANDS_LEVEL); commandsShortTermTicks = config.getInt(ConfPaths.CHAT_COMMANDS_SHORTTERM_TICKS); commandsShortTermLevel = config.getDouble(ConfPaths.CHAT_COMMANDS_SHORTTERM_LEVEL);; commandsActions = config.getOptimizedActionList(ConfPaths.CHAT_COMMANDS_ACTIONS, Permissions.CHAT_COMMANDS); - - + + textCheck = config.getBoolean(ConfPaths.CHAT_TEXT_CHECK); - textGlobalCheck = config.getBoolean(ConfPaths.CHAT_TEXT_GL_CHECK, true); - textPlayerCheck = config.getBoolean(ConfPaths.CHAT_TEXT_PP_CHECK, true); + textGlobalCheck = config.getBoolean(ConfPaths.CHAT_TEXT_GL_CHECK, true); + textPlayerCheck = config.getBoolean(ConfPaths.CHAT_TEXT_PP_CHECK, true); textEnginePlayerConfig = new EnginePlayerConfig(config); textFreqNormMin = (float) config.getDouble(ConfPaths.CHAT_TEXT_FREQ_NORM_MIN); textFreqNormFactor = (float) config.getDouble(ConfPaths.CHAT_TEXT_FREQ_NORM_FACTOR); @@ -185,30 +190,30 @@ public class ChatConfig extends ACheckConfig { textMsgRepeatSelf = (float) config.getDouble(ConfPaths.CHAT_TEXT_MSG_REPEATSELF); textMsgRepeatGlobal = (float) config.getDouble(ConfPaths.CHAT_TEXT_MSG_REPEATGLOBAL); textMsgNoMoving = (float) config.getDouble(ConfPaths.CHAT_TEXT_MSG_NOMOVING); - + textMessageLengthAv = (float) config.getDouble(ConfPaths.CHAT_TEXT_MSG_WORDS_LENGTHAV); textMessageLengthMsg = (float) config.getDouble(ConfPaths.CHAT_TEXT_MSG_WORDS_LENGTHMSG); textMessageNoLetter = (float) config.getDouble(ConfPaths.CHAT_TEXT_MSG_WORDS_NOLETTER); textGlobalWeight = (float) config.getDouble(ConfPaths.CHAT_TEXT_GL_WEIGHT, 1.0); textPlayerWeight = (float) config.getDouble(ConfPaths.CHAT_TEXT_PP_WEIGHT, 1.0); - textFreqNormLevel = config.getDouble(ConfPaths.CHAT_TEXT_FREQ_NORM_LEVEL); - textEngineMaximum = config.getBoolean(ConfPaths.CHAT_TEXT_ENGINE_MAXIMUM, true); - textDebug = config.getBoolean(ConfPaths.CHAT_TEXT_DEBUG, false); + textFreqNormLevel = config.getDouble(ConfPaths.CHAT_TEXT_FREQ_NORM_LEVEL); + textEngineMaximum = config.getBoolean(ConfPaths.CHAT_TEXT_ENGINE_MAXIMUM, true); + textDebug = config.getBoolean(ConfPaths.CHAT_TEXT_DEBUG, false); textFreqNormActions = config.getOptimizedActionList(ConfPaths.CHAT_TEXT_FREQ_NORM_ACTIONS, Permissions.CHAT_TEXT); textAllowVLReset = config.getBoolean(ConfPaths.CHAT_TEXT_ALLOWVLRESET); - + chatWarningCheck = config.getBoolean(ConfPaths.CHAT_WARNING_CHECK); chatWarningLevel = (float) config.getDouble(ConfPaths.CHAT_WARNING_LEVEL); chatWarningMessage = config.getString(ConfPaths.CHAT_WARNING_MESSAGE); chatWarningTimeout = config.getLong(ConfPaths.CHAT_WARNING_TIMEOUT) * 1000; - + loginsCheck = config.getBoolean(ConfPaths.CHAT_LOGINS_CHECK); loginsPerWorldCount = config.getBoolean(ConfPaths.CHAT_LOGINS_PERWORLDCOUNT); loginsSeconds = config.getInt(ConfPaths.CHAT_LOGINS_SECONDS); loginsLimit = config.getInt(ConfPaths.CHAT_LOGINS_LIMIT); loginsKickMessage = config.getString(ConfPaths.CHAT_LOGINS_KICKMESSAGE); loginsStartupDelay = config.getInt(ConfPaths.CHAT_LOGINS_STARTUPDELAY) * 1000; - + relogCheck = config.getBoolean(ConfPaths.CHAT_RELOG_CHECK); relogKickMessage = config.getString(ConfPaths.CHAT_RELOG_KICKMESSAGE); relogTimeout = config.getLong(ConfPaths.CHAT_RELOG_TIMEOUT); @@ -228,20 +233,20 @@ public class ChatConfig extends ACheckConfig { @Override public boolean isEnabled(final CheckType checkType) { switch (checkType) { - case CHAT_COLOR: - return colorCheck; - case CHAT_TEXT: - return textCheck; - case CHAT_COMMANDS: - return commandsCheck; - case CHAT_CAPTCHA: - return captchaCheck; - case CHAT_RELOG: - return relogCheck; - case CHAT_LOGINS: - return loginsCheck; - default: - return true; + case CHAT_COLOR: + return colorCheck; + case CHAT_TEXT: + return textCheck; + case CHAT_COMMANDS: + return commandsCheck; + case CHAT_CAPTCHA: + return captchaCheck; + case CHAT_RELOG: + return relogCheck; + case CHAT_LOGINS: + return loginsCheck; + default: + return true; } } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java index c4e13d6b..3cccebea 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java @@ -23,91 +23,96 @@ import fr.neatmonster.nocheatplus.permissions.Permissions; import fr.neatmonster.nocheatplus.utilities.StringUtil; public class CombinedConfig extends ACheckConfig { - - /** The factory creating configurations. */ - public static final CheckConfigFactory factory = new CheckConfigFactory() { - @Override - public final ICheckConfig getConfig(final Player player) { - return CombinedConfig.getConfig(player); - } - }; - private static final Map worldsMap = new HashMap(); + /** The factory creating configurations. */ + public static final CheckConfigFactory factory = new CheckConfigFactory() { + @Override + public final ICheckConfig getConfig(final Player player) { + return CombinedConfig.getConfig(player); + } - public static CombinedConfig getConfig(final Player player) { - final String worldName = player.getWorld().getName(); - CombinedConfig cc = worldsMap.get(worldName); - if (cc == null){ - cc = new CombinedConfig(ConfigManager.getConfigFile(worldName)); - worldsMap.put(worldName, cc); - } - return cc; - } - - - // Bedleave check. - public final boolean bedLeaveCheck; - public final ActionList bedLeaveActions; - - // Ender pearl - public final boolean enderPearlCheck; - public final boolean enderPearlPreventClickBlock; + @Override + public void removeAllConfigs() { + clear(); // Band-aid. + } + }; - // Improbable check - /** Do mind that this flag is not used by all components. */ - public final boolean improbableCheck; - public final float improbableLevel; - public final ActionList improbableActions; - - // Invulnerable management. - public final boolean invulnerableCheck; + private static final Map worldsMap = new HashMap(); + + public static CombinedConfig getConfig(final Player player) { + final String worldName = player.getWorld().getName(); + CombinedConfig cc = worldsMap.get(worldName); + if (cc == null){ + cc = new CombinedConfig(ConfigManager.getConfigFile(worldName)); + worldsMap.put(worldName, cc); + } + return cc; + } + + + // Bedleave check. + public final boolean bedLeaveCheck; + public final ActionList bedLeaveActions; + + // Ender pearl + public final boolean enderPearlCheck; + public final boolean enderPearlPreventClickBlock; + + // Improbable check + /** Do mind that this flag is not used by all components. */ + public final boolean improbableCheck; + public final float improbableLevel; + public final ActionList improbableActions; + + // Invulnerable management. + public final boolean invulnerableCheck; public final int invulnerableInitialTicksJoin; public final Set invulnerableIgnore = new HashSet(); public final Map invulnerableModifiers = new HashMap(); public final int invulnerableModifierDefault; public final boolean invulnerableTriggerAlways; public final boolean invulnerableTriggerFallDistance; - - public final boolean munchHausenCheck; - public final ActionList munchHausenActions; - - // Last yaw tracking - public final float yawRate; - public final boolean yawRateImprobable; + + public final boolean munchHausenCheck; + public final ActionList munchHausenActions; + + // Last yaw tracking + public final float yawRate; + public final boolean yawRateImprobable; public final float yawRatePenaltyFactor; public final int yawRatePenaltyMin; public final int yawRatePenaltyMax; - - public CombinedConfig(final ConfigFile config) { - super(config, ConfPaths.COMBINED); - - bedLeaveCheck = config.getBoolean(ConfPaths.COMBINED_BEDLEAVE_CHECK); - bedLeaveActions = config.getOptimizedActionList(ConfPaths.COMBINED_BEDLEAVE_ACTIONS, Permissions.COMBINED_BEDLEAVE); - enderPearlCheck = config.getBoolean(ConfPaths.COMBINED_ENDERPEARL_CHECK); - enderPearlPreventClickBlock = config.getBoolean(ConfPaths.COMBINED_ENDERPEARL_PREVENTCLICKBLOCK); - - improbableCheck = config.getBoolean(ConfPaths.COMBINED_IMPROBABLE_CHECK); - improbableLevel = (float) config.getDouble(ConfPaths.COMBINED_IMPROBABLE_LEVEL); - improbableActions = config.getOptimizedActionList(ConfPaths.COMBINED_IMPROBABLE_ACTIONS, Permissions.COMBINED_IMPROBABLE); - - invulnerableCheck = config.getBoolean(ConfPaths.COMBINED_INVULNERABLE_CHECK); - invulnerableInitialTicksJoin = config.getInt(ConfPaths.COMBINED_INVULNERABLE_INITIALTICKS_JOIN); - boolean error = false; - // Read ignored causes. - for (final String input : config.getStringList(ConfPaths.COMBINED_INVULNERABLE_IGNORE)){ - final String normInput = input.trim().toUpperCase(); - try{ - invulnerableIgnore.add(DamageCause.valueOf(normInput.replace(' ', '_').replace('-', '_'))); - } - catch (final Exception e){ - error = true; - StaticLog.logWarning("[NoCheatPlus] Bad damage cause (combined.invulnerable.ignore): " + input); - } - } - // Read modifiers for causes. - Integer defaultMod = 0; - final ConfigurationSection sec = config.getConfigurationSection(ConfPaths.COMBINED_INVULNERABLE_MODIFIERS); + public CombinedConfig(final ConfigFile config) { + super(config, ConfPaths.COMBINED); + + bedLeaveCheck = config.getBoolean(ConfPaths.COMBINED_BEDLEAVE_CHECK); + bedLeaveActions = config.getOptimizedActionList(ConfPaths.COMBINED_BEDLEAVE_ACTIONS, Permissions.COMBINED_BEDLEAVE); + + enderPearlCheck = config.getBoolean(ConfPaths.COMBINED_ENDERPEARL_CHECK); + enderPearlPreventClickBlock = config.getBoolean(ConfPaths.COMBINED_ENDERPEARL_PREVENTCLICKBLOCK); + + improbableCheck = config.getBoolean(ConfPaths.COMBINED_IMPROBABLE_CHECK); + improbableLevel = (float) config.getDouble(ConfPaths.COMBINED_IMPROBABLE_LEVEL); + improbableActions = config.getOptimizedActionList(ConfPaths.COMBINED_IMPROBABLE_ACTIONS, Permissions.COMBINED_IMPROBABLE); + + invulnerableCheck = config.getBoolean(ConfPaths.COMBINED_INVULNERABLE_CHECK); + invulnerableInitialTicksJoin = config.getInt(ConfPaths.COMBINED_INVULNERABLE_INITIALTICKS_JOIN); + boolean error = false; + // Read ignored causes. + for (final String input : config.getStringList(ConfPaths.COMBINED_INVULNERABLE_IGNORE)){ + final String normInput = input.trim().toUpperCase(); + try{ + invulnerableIgnore.add(DamageCause.valueOf(normInput.replace(' ', '_').replace('-', '_'))); + } + catch (final Exception e){ + error = true; + StaticLog.logWarning("[NoCheatPlus] Bad damage cause (combined.invulnerable.ignore): " + input); + } + } + // Read modifiers for causes. + Integer defaultMod = 0; + final ConfigurationSection sec = config.getConfigurationSection(ConfPaths.COMBINED_INVULNERABLE_MODIFIERS); for (final String input : sec.getKeys(false)){ final int modifier = sec.getInt(input, 0); final String normInput = input.trim().toUpperCase(); @@ -124,36 +129,36 @@ public class CombinedConfig extends ACheckConfig { } } invulnerableModifierDefault = defaultMod; - if (error) StaticLog.logInfo("[NoCheatPlus] Damage causes can be: " + StringUtil.join(Arrays.asList(DamageCause.values()), ", ")); - invulnerableTriggerAlways = config.getBoolean(ConfPaths.COMBINED_INVULNERABLE_TRIGGERS_ALWAYS); - invulnerableTriggerFallDistance = config.getBoolean(ConfPaths.COMBINED_INVULNERABLE_TRIGGERS_FALLDISTANCE); - - munchHausenCheck = config.getBoolean(ConfPaths.COMBINED_MUNCHHAUSEN_CHECK); - munchHausenActions = config.getOptimizedActionList(ConfPaths.COMBINED_MUNCHHAUSEN_ACTIONS, Permissions.COMBINED_MUNCHHAUSEN); - - yawRate = config.getInt(ConfPaths.COMBINED_YAWRATE_RATE); - yawRateImprobable = config.getBoolean(ConfPaths.COMBINED_YAWRATE_IMPROBABLE); - yawRatePenaltyFactor = (float) config.getDouble(ConfPaths.COMBINED_YAWRATE_PENALTY_FACTOR); - yawRatePenaltyMin = config.getInt(ConfPaths.COMBINED_YAWRATE_PENALTY_MIN); - yawRatePenaltyMax = config.getInt(ConfPaths.COMBINED_YAWRATE_PENALTY_MAX); - } + if (error) StaticLog.logInfo("[NoCheatPlus] Damage causes can be: " + StringUtil.join(Arrays.asList(DamageCause.values()), ", ")); + invulnerableTriggerAlways = config.getBoolean(ConfPaths.COMBINED_INVULNERABLE_TRIGGERS_ALWAYS); + invulnerableTriggerFallDistance = config.getBoolean(ConfPaths.COMBINED_INVULNERABLE_TRIGGERS_FALLDISTANCE); - @Override - public boolean isEnabled(final CheckType checkType) { - switch(checkType){ - case COMBINED_IMPROBABLE: - return improbableCheck; - case COMBINED_BEDLEAVE: - return bedLeaveCheck; - case COMBINED_MUNCHHAUSEN: - return munchHausenCheck; - default: - return false; - } - } + munchHausenCheck = config.getBoolean(ConfPaths.COMBINED_MUNCHHAUSEN_CHECK); + munchHausenActions = config.getOptimizedActionList(ConfPaths.COMBINED_MUNCHHAUSEN_ACTIONS, Permissions.COMBINED_MUNCHHAUSEN); - public static void clear() { - worldsMap.clear(); - } + yawRate = config.getInt(ConfPaths.COMBINED_YAWRATE_RATE); + yawRateImprobable = config.getBoolean(ConfPaths.COMBINED_YAWRATE_IMPROBABLE); + yawRatePenaltyFactor = (float) config.getDouble(ConfPaths.COMBINED_YAWRATE_PENALTY_FACTOR); + yawRatePenaltyMin = config.getInt(ConfPaths.COMBINED_YAWRATE_PENALTY_MIN); + yawRatePenaltyMax = config.getInt(ConfPaths.COMBINED_YAWRATE_PENALTY_MAX); + } + + @Override + public boolean isEnabled(final CheckType checkType) { + switch(checkType){ + case COMBINED_IMPROBABLE: + return improbableCheck; + case COMBINED_BEDLEAVE: + return bedLeaveCheck; + case COMBINED_MUNCHHAUSEN: + return munchHausenCheck; + default: + return false; + } + } + + public static void clear() { + worldsMap.clear(); + } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/fight/FightConfig.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/fight/FightConfig.java index 8dd9f5af..5d4d0149 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/fight/FightConfig.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/fight/FightConfig.java @@ -29,6 +29,11 @@ public class FightConfig extends ACheckConfig { public final ICheckConfig getConfig(final Player player) { return FightConfig.getConfig(player); } + + @Override + public void removeAllConfigs() { + clear(); // Band-aid. + } }; /** The map containing the configurations per world. */ diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/inventory/InventoryConfig.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/inventory/InventoryConfig.java index 7d324e42..947d9cea 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/inventory/InventoryConfig.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/inventory/InventoryConfig.java @@ -31,6 +31,11 @@ public class InventoryConfig extends ACheckConfig { public final ICheckConfig getConfig(final Player player) { return InventoryConfig.getConfig(player); } + + @Override + public void removeAllConfigs() { + clear(); // Band-aid. + } }; /** The map containing the configurations per world. */ diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java index d86aa8f9..7276d314 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java @@ -30,6 +30,11 @@ public class MovingConfig extends ACheckConfig { public final ICheckConfig getConfig(final Player player) { return MovingConfig.getConfig(player); } + + @Override + public void removeAllConfigs() { + clear(); // Band-aid. + } }; /** The map containing the configurations per world. */ diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/net/NetConfig.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/net/NetConfig.java index 39c4d613..fabaa370 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/net/NetConfig.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/net/NetConfig.java @@ -1,32 +1,44 @@ package fr.neatmonster.nocheatplus.checks.net; +import fr.neatmonster.nocheatplus.actions.ActionList; +import fr.neatmonster.nocheatplus.checks.CheckType; +import fr.neatmonster.nocheatplus.checks.access.ACheckConfig; import fr.neatmonster.nocheatplus.config.ConfPaths; import fr.neatmonster.nocheatplus.config.ConfigFile; import fr.neatmonster.nocheatplus.config.ConfigManager; +import fr.neatmonster.nocheatplus.permissions.Permissions; /** * Configuration for the net checks (fast version, sparse). * @author web4web1 * */ -public class NetConfig { +public class NetConfig extends ACheckConfig { public final boolean flyingFrequencyActive; public final int flyingFrequencySeconds; - public final int flyingFrequencyMaxPackets; - public final boolean flyingFrequencyCancelRedundant; + public final double flyingFrequencyPPS; + public final ActionList flyingFrequencyActions; + public final boolean flyingFrequencyRedundantActive; + public final int flyingFrequencyRedundantSeconds; + public final ActionList flyingFrequencyRedundantActions; public final boolean soundDistanceActive; /** Maximum distance for lightning effects (squared). */ public final double soundDistanceSq; public NetConfig(final ConfigFile config) { + super(config, ConfPaths.NET); final ConfigFile globalConfig = ConfigManager.getConfigFile(); flyingFrequencyActive = config.getBoolean(ConfPaths.NET_FLYINGFREQUENCY_ACTIVE); flyingFrequencySeconds = Math.max(1, globalConfig.getInt(ConfPaths.NET_FLYINGFREQUENCY_SECONDS)); - flyingFrequencyMaxPackets = Math.max(1, globalConfig.getInt(ConfPaths.NET_FLYINGFREQUENCY_MAXPACKETS)); - flyingFrequencyCancelRedundant = config.getBoolean(ConfPaths.NET_FLYINGFREQUENCY_CANCELREDUNDANT); + flyingFrequencyPPS = Math.max(1.0, globalConfig.getDouble(ConfPaths.NET_FLYINGFREQUENCY_PACKETSPERSECOND)); + flyingFrequencyActions = config.getOptimizedActionList(ConfPaths.NET_FLYINGFREQUENCY_ACTIONS, Permissions.NET_FLYINGFREQUENCY); + flyingFrequencyRedundantActive = config.getBoolean(ConfPaths.NET_FLYINGFREQUENCY_CANCELREDUNDANT); + flyingFrequencyRedundantSeconds = Math.max(1, config.getInt(ConfPaths.NET_FLYINGFREQUENCY_REDUNDANT_SECONDS)); + // Same permission for "silent". + flyingFrequencyRedundantActions = config.getOptimizedActionList(ConfPaths.NET_FLYINGFREQUENCY_REDUNDANT_ACTIONS, Permissions.NET_FLYINGFREQUENCY); soundDistanceActive = config.getBoolean(ConfPaths.NET_SOUNDDISTANCE_ACTIVE); double dist = config.getDouble(ConfPaths.NET_SOUNDDISTANCE_MAXDISTANCE); @@ -34,4 +46,16 @@ public class NetConfig { } + @Override + public boolean isEnabled(final CheckType checkType) { + switch(checkType) { + case NET_FLYINGFREQUENCY: + return flyingFrequencyActive; + case NET_SOUNDDISTANCE: + return soundDistanceActive; + default: + return true; + } + } + } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/net/NetConfigCache.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/net/NetConfigCache.java index 04f77e20..0c684aab 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/net/NetConfigCache.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/net/NetConfigCache.java @@ -1,5 +1,8 @@ package fr.neatmonster.nocheatplus.checks.net; +import org.bukkit.entity.Player; + +import fr.neatmonster.nocheatplus.checks.access.CheckConfigFactory; import fr.neatmonster.nocheatplus.config.ConfigFile; import fr.neatmonster.nocheatplus.config.WorldConfigCache; @@ -8,7 +11,7 @@ import fr.neatmonster.nocheatplus.config.WorldConfigCache; * @author web4web1 * */ -public class NetConfigCache extends WorldConfigCache { +public class NetConfigCache extends WorldConfigCache implements CheckConfigFactory { public NetConfigCache() { super(true); @@ -19,4 +22,14 @@ public class NetConfigCache extends WorldConfigCache { return new NetConfig(configFile); } + @Override + public NetConfig getConfig(final Player player) { + return getConfig(player.getWorld()); + } + + @Override + public void removeAllConfigs() { + clearAllConfigs(); + } + } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/net/NetData.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/net/NetData.java new file mode 100644 index 00000000..5a279234 --- /dev/null +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/net/NetData.java @@ -0,0 +1,30 @@ +package fr.neatmonster.nocheatplus.checks.net; + +import fr.neatmonster.nocheatplus.checks.access.ACheckData; +import fr.neatmonster.nocheatplus.utilities.ActionFrequency; + +/** + * Primary thread only. + * @author web4web1 + * + */ +public class NetData extends ACheckData { + + /** All flying packets, use Monotonic.millis() for time. */ + public final ActionFrequency flyingFrequencyAll; + public boolean flyingFrequencyOnGround = false; + public long flyingFrequencyTimeOnGround = 0L; + public long flyingFrequencyTimeNotOnGround = 0L; + /** + * Monitors redundant packets, when more than 20 packets per second are + * sent. Use Monotonic.millis() for time. + */ + public final ActionFrequency flyingFrequencyRedundantFreq; + + public NetData(final NetConfig config) { + super(config); + flyingFrequencyAll = new ActionFrequency(config.flyingFrequencySeconds, 1000L); + flyingFrequencyRedundantFreq = new ActionFrequency(config.flyingFrequencyRedundantSeconds, 1000L); + } + +} diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/net/NetDataFactory.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/net/NetDataFactory.java new file mode 100644 index 00000000..e9126ece --- /dev/null +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/net/NetDataFactory.java @@ -0,0 +1,41 @@ +package fr.neatmonster.nocheatplus.checks.net; + +import java.util.HashMap; + +import org.bukkit.entity.Player; + +import fr.neatmonster.nocheatplus.checks.CheckType; +import fr.neatmonster.nocheatplus.checks.access.CheckDataFactory; + +/** + * Currently primary thread only! + * @author web4web1 + * + */ +public class NetDataFactory implements CheckDataFactory { + + private final HashMap dataMap = new HashMap(); + + @Override + public void removeAllData() { + dataMap.clear(); + } + + @Override + public NetData getData(Player player) { + NetData data = dataMap.get(player.getName()); + if (data != null) { + return data; + } else { + data = new NetData((NetConfig) CheckType.NET.getConfigFactory().getConfig(player)); + dataMap.put(player.getName(), data); + return data; + } + } + + @Override + public NetData removeData(String playerName) { + return dataMap.remove(playerName); + } + +} diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfPaths.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfPaths.java index b749b54a..31721cbb 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfPaths.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfPaths.java @@ -595,19 +595,23 @@ public abstract class ConfPaths { public static final String MOVING_TRACE_SIZE = MOVING_TRACE + "size"; public static final String MOVING_TRACE_MERGEDIST = MOVING_TRACE + "mergedist"; - private static final String NET = CHECKS + "net."; + public static final String NET = CHECKS + "net."; - private static final String NET_SOUNDDISTANCE = NET + "sounddistance."; - public static final String NET_SOUNDDISTANCE_ACTIVE = NET_SOUNDDISTANCE + "active"; - public static final String NET_SOUNDDISTANCE_MAXDISTANCE = NET_SOUNDDISTANCE + "maxdistance"; + private static final String NET_SOUNDDISTANCE = NET + "sounddistance."; + public static final String NET_SOUNDDISTANCE_ACTIVE = NET_SOUNDDISTANCE + "active"; + public static final String NET_SOUNDDISTANCE_MAXDISTANCE = NET_SOUNDDISTANCE + "maxdistance"; - private static final String NET_FLYINGFREQUENCY = NET + "flyingfrequency."; - public static final String NET_FLYINGFREQUENCY_ACTIVE = NET_FLYINGFREQUENCY + "active"; + private static final String NET_FLYINGFREQUENCY = NET + "flyingfrequency."; + public static final String NET_FLYINGFREQUENCY_ACTIVE = NET_FLYINGFREQUENCY + "active"; @GlobalConfig - public static final String NET_FLYINGFREQUENCY_SECONDS = NET_FLYINGFREQUENCY + "seconds"; + public static final String NET_FLYINGFREQUENCY_SECONDS = NET_FLYINGFREQUENCY + "seconds"; @GlobalConfig - public static final String NET_FLYINGFREQUENCY_MAXPACKETS = NET_FLYINGFREQUENCY + "maxpackets"; - public static final String NET_FLYINGFREQUENCY_CANCELREDUNDANT = NET_FLYINGFREQUENCY + "cancelredundant"; + public static final String NET_FLYINGFREQUENCY_PACKETSPERSECOND = NET_FLYINGFREQUENCY + "packetspersecond"; + public static final String NET_FLYINGFREQUENCY_ACTIONS = NET_FLYINGFREQUENCY + "actions"; + private static final String NET_FLYINGFREQUENCY_REDUNDANT = NET_FLYINGFREQUENCY + "reduceredundant."; + public static final String NET_FLYINGFREQUENCY_REDUNDANT_ACTIVE = NET_FLYINGFREQUENCY_REDUNDANT + "active"; + public static final String NET_FLYINGFREQUENCY_REDUNDANT_SECONDS = NET_FLYINGFREQUENCY_REDUNDANT + "seconds"; + public static final String NET_FLYINGFREQUENCY_REDUNDANT_ACTIONS = NET_FLYINGFREQUENCY_REDUNDANT + "actions"; public static final String STRINGS = "strings"; @@ -650,6 +654,8 @@ public abstract class ConfPaths { public static final String INVENTORY_ENSURECLOSE = "checks.inventory.ensureclose"; @Moved(newPath = LOGGING_EXTENDED_STATUS) public static final String LOGGING_DEBUG = "logging.debug"; + @Moved(newPath = NET_FLYINGFREQUENCY_REDUNDANT_ACTIVE) + public static final String NET_FLYINGFREQUENCY_CANCELREDUNDANT = "checks.net.flyingfrequency.cancelredundant"; @Deprecated public static final String MISCELLANEOUS_REPORTTOMETRICS = "miscellaneous.reporttometrics"; @Deprecated @@ -666,5 +672,7 @@ public abstract class ConfPaths { public static final String FIGHT_KNOCKBACK_INTERVAL = "checks.fight.knockback.interval"; @Deprecated public static final String FIGHT_KNOCKBACK_ACTIONS = "checks.fight.knockback.actions"; + @Deprecated + public static final String NET_FLYINGFREQUENCY_MAXPACKETS = "checks.net.flyingfrequency.maxpackets"; } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/DefaultConfig.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/DefaultConfig.java index 9fbb4cf2..02c78ca1 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/DefaultConfig.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/DefaultConfig.java @@ -434,8 +434,11 @@ public class DefaultConfig extends ConfigFile { // FlyingFrequency set(ConfPaths.NET_FLYINGFREQUENCY_ACTIVE, true); set(ConfPaths.NET_FLYINGFREQUENCY_SECONDS, 5); - set(ConfPaths.NET_FLYINGFREQUENCY_MAXPACKETS, 300); - set(ConfPaths.NET_FLYINGFREQUENCY_CANCELREDUNDANT, true); + set(ConfPaths.NET_FLYINGFREQUENCY_PACKETSPERSECOND, 60); + set(ConfPaths.NET_FLYINGFREQUENCY_ACTIONS, "cancel"); // TODO: Log actions. + set(ConfPaths.NET_FLYINGFREQUENCY_REDUNDANT_ACTIVE, true); + set(ConfPaths.NET_FLYINGFREQUENCY_REDUNDANT_SECONDS, 3); + set(ConfPaths.NET_FLYINGFREQUENCY_REDUNDANT_ACTIONS, "cancel"); // TODO: Log actions. // SoundDistance set(ConfPaths.NET_SOUNDDISTANCE_ACTIVE, true); diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/permissions/Permissions.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/permissions/Permissions.java index 102280a5..967d0879 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/permissions/Permissions.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/permissions/Permissions.java @@ -114,6 +114,9 @@ public class Permissions { public static final String INVENTORY_ITEMS = INVENTORY + ".items"; public static final String INVENTORY_OPEN = INVENTORY + ".open"; + public static final String NET = CHECKS + ".net"; + public static final String NET_FLYINGFREQUENCY = NET + ".flyingfrequency"; + public static final String MOVING = CHECKS + ".moving"; public static final String MOVING_CREATIVEFLY = MOVING + ".creativefly"; public static final String MOVING_MOREPACKETS = MOVING + ".morepackets"; @@ -166,5 +169,5 @@ public class Permissions { private static final String JOURNEY = MODS + ".journey"; public static final String JOURNEY_RADAR = JOURNEY + ".radar"; public static final String JOURNEY_CAVE = JOURNEY + ".cavemap"; - + } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/players/DataManager.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/players/DataManager.java index a4a014d8..ca1ae19d 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/players/DataManager.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/players/DataManager.java @@ -28,15 +28,7 @@ import fr.neatmonster.nocheatplus.checks.access.CheckConfigFactory; import fr.neatmonster.nocheatplus.checks.access.CheckDataFactory; import fr.neatmonster.nocheatplus.checks.access.ICheckConfig; import fr.neatmonster.nocheatplus.checks.access.ICheckData; -import fr.neatmonster.nocheatplus.checks.blockbreak.BlockBreakConfig; -import fr.neatmonster.nocheatplus.checks.blockinteract.BlockInteractConfig; -import fr.neatmonster.nocheatplus.checks.blockplace.BlockPlaceConfig; -import fr.neatmonster.nocheatplus.checks.chat.ChatConfig; -import fr.neatmonster.nocheatplus.checks.combined.CombinedConfig; import fr.neatmonster.nocheatplus.checks.combined.CombinedData; -import fr.neatmonster.nocheatplus.checks.fight.FightConfig; -import fr.neatmonster.nocheatplus.checks.inventory.InventoryConfig; -import fr.neatmonster.nocheatplus.checks.moving.MovingConfig; import fr.neatmonster.nocheatplus.compat.BridgeMisc; import fr.neatmonster.nocheatplus.components.ComponentRegistry; import fr.neatmonster.nocheatplus.components.ComponentWithName; @@ -406,19 +398,20 @@ public class DataManager implements Listener, INotifyReload, INeedConfig, Compon } /** - * Clear all stored (check) config instances.
+ * Clear all cached CheckConfig instances.
* This does not cleanup ConfigManager, i.e. stored yml-versions. */ public static void clearConfigs() { - // The dirty bit ! - BlockBreakConfig.clear(); - BlockInteractConfig.clear(); - BlockPlaceConfig.clear(); - ChatConfig.clear(); - CombinedConfig.clear(); - FightConfig.clear(); - InventoryConfig.clear(); - MovingConfig.clear(); + final Set factories = new LinkedHashSet(); + for (final CheckType checkType : CheckType.values()) { + final CheckConfigFactory factory = checkType.getConfigFactory(); + if (factory != null) { + factories.add(factory); + } + } + for (final CheckConfigFactory factory : factories) { + factory.removeAllConfigs(); + } } /** diff --git a/NCPPlugin/src/main/resources/plugin.yml b/NCPPlugin/src/main/resources/plugin.yml index 1ba99353..cddcd406 100644 --- a/NCPPlugin/src/main/resources/plugin.yml +++ b/NCPPlugin/src/main/resources/plugin.yml @@ -169,7 +169,7 @@ permissions: nocheatplus.checks.moving.nofall: description: Allow the player to bypass the NoFall check. nocheatplus.checks.moving.passable: - description: Allow bypassing the passable check. + description: Allow bypassing the Passable check. nocheatplus.checks.moving.survivalfly: description: Allow the player to bypass the SurvivalFly check. children: @@ -183,6 +183,11 @@ permissions: description: Allow the player to sprint backwards. nocheatplus.checks.moving.survivalfly.step: description: Allow the player to use the 'step' functionality of his client. + nocheatplus.checks.net: + description: Allow a player to bypass the net (packet) checks. + children: + nocheatplus.checks.net.flyingfrequency: + description: Bypass the FlyingFrequency check (flying packet spam). nocheatplus.mods: description: Allow the player to use all the client mods.