[BLEEDING] Integrate net checks into the check system.

* Extend CheckConfigFactory with a remove-all method.
* DataManager.clearConfigs() now uses CheckType for getting factories.
* Split off Check.hasBypass method to check exemption + permission.
* Allow null permissions in CheckType (interpret as no bypass).
* Add Check types for FlyingFrequency and SoundDistance.
* Add exemption and actions to FlyingFrequency, alter defaults.
This commit is contained in:
asofold 2015-01-30 01:18:37 +01:00
parent b3fa312ceb
commit 86732764e3
23 changed files with 598 additions and 439 deletions

View File

@ -1,8 +1,6 @@
package fr.neatmonster.nocheatplus.checks.net.protocollib; package fr.neatmonster.nocheatplus.checks.net.protocollib;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -13,14 +11,16 @@ import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.events.PacketEvent;
import fr.neatmonster.nocheatplus.NCPAPIProvider; 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.moving.MovingData;
import fr.neatmonster.nocheatplus.checks.net.NetConfig; import fr.neatmonster.nocheatplus.checks.net.NetConfig;
import fr.neatmonster.nocheatplus.checks.net.NetConfigCache; 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.logging.Streams;
import fr.neatmonster.nocheatplus.stats.Counters; import fr.neatmonster.nocheatplus.stats.Counters;
import fr.neatmonster.nocheatplus.time.monotonic.Monotonic; import fr.neatmonster.nocheatplus.time.monotonic.Monotonic;
import fr.neatmonster.nocheatplus.utilities.ActionFrequency;
import fr.neatmonster.nocheatplus.utilities.CheckUtils; import fr.neatmonster.nocheatplus.utilities.CheckUtils;
import fr.neatmonster.nocheatplus.utilities.TrigUtil; import fr.neatmonster.nocheatplus.utilities.TrigUtil;
@ -31,66 +31,36 @@ import fr.neatmonster.nocheatplus.utilities.TrigUtil;
* @author dev1mc * @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 double minMoveDistSq = 1f / 256; // PlayerConnection magic.
public static final float minLookChange = 10f; 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<String, FFData> freqMap = new HashMap<String, FFData>();
private final Counters counters = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(Counters.class); 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 final int idNullPlayer = counters.registerKey("packet.flying.nullplayer");
private boolean cancelRedundant = true; private boolean cancelRedundant = true;
private final NetConfigCache configs; private final NetConfigCache configs;
private final NetDataFactory dataFactory;
public FlyingFrequency(NetConfigCache configs, Plugin plugin) { public FlyingFrequency(Plugin plugin) {
// PacketPlayInFlying[3, legacy: 10] // PacketPlayInFlying[3, legacy: 10]
super(plugin, PacketType.Play.Client.FLYING); // TODO: How does POS and POS_LOOK relate/translate? super(plugin, PacketType.Play.Client.FLYING); // TODO: How does POS and POS_LOOK relate/translate?
this.configs = configs; this.configs = (NetConfigCache) CheckType.NET.getConfigFactory();
} this.dataFactory = (NetDataFactory) CheckType.NET.getDataFactory();
@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;
}
} }
@Override @Override
@ -109,32 +79,32 @@ public class FlyingFrequency extends PacketAdapter implements JoinLeaveListener
return; return;
} }
final FFData data = getData(player.getName(), cc); final NetData data = dataFactory.getData(player);
final long t = System.currentTimeMillis(); final long time = Monotonic.millis();
// Counting all packets. // Counting all packets.
data.all.add(t, 1f); // TODO: Consider using the NetStatic check.
final float allScore = data.all.score(1f); data.flyingFrequencyAll.add(time, 1f);
if (allScore > cc.flyingFrequencyMaxPackets) { final float allScore = data.flyingFrequencyAll.score(1f);
counters.add(idSilent, 1); // Until it is sure if we can get these async. 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); event.setCancelled(true);
return; return;
} }
// Cancel redundant packets, when frequency is high anyway. // 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); 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: Consider quick return conditions.
// TODO: Debug logging (better with integration into DataManager). // TODO: Debug logging (better with integration into DataManager).
// TODO: Consider to compare to moving data directly, skip keeping track extra. // TODO: Consider to compare to moving data directly, skip keeping track extra.
final PacketContainer packet = event.getPacket(); final PacketContainer packet = event.getPacket();
final List<Boolean> booleans = packet.getBooleans().getValues(); final List<Boolean> booleans = packet.getBooleans().getValues();
if (booleans.size() != FFData.numBooleans) { if (booleans.size() != FlyingFrequency.numBooleans) {
return packetMismatch(); return packetMismatch();
} }
@ -143,30 +113,29 @@ public class FlyingFrequency extends PacketAdapter implements JoinLeaveListener
// Can not check. // Can not check.
return false; return false;
} }
final boolean hasPos = booleans.get(FFData.indexhasPos).booleanValue(); final boolean hasPos = booleans.get(FlyingFrequency.indexhasPos).booleanValue();
final boolean hasLook = booleans.get(FFData.indexhasLook).booleanValue(); final boolean hasLook = booleans.get(FlyingFrequency.indexhasLook).booleanValue();
final boolean onGround = booleans.get(FFData.indexOnGround).booleanValue(); final boolean onGround = booleans.get(FlyingFrequency.indexOnGround).booleanValue();
boolean onGroundSkip = false; boolean onGroundSkip = false;
// Allow at least one on-ground change per state and second. // Allow at least one on-ground change per state and second.
// TODO: Consider to verify on ground somehow (could tell MovingData the state). // TODO: Consider to verify on ground somehow (could tell MovingData the state).
if (onGround != data.onGround) { if (onGround != data.flyingFrequencyOnGround) {
// Regard as not redundant only if sending the same state happened at least a second ago. // Regard as not redundant only if sending the same state happened at least a second ago.
final long time = Monotonic.millis();
final long lastTime; final long lastTime;
if (onGround) { if (onGround) {
lastTime = data.timeOnGround; lastTime = data.flyingFrequencyTimeOnGround;
data.timeOnGround = time; data.flyingFrequencyTimeOnGround = time;
} else { } else {
lastTime = data.timeNotOnGround; lastTime = data.flyingFrequencyTimeNotOnGround;
data.timeNotOnGround = time; data.flyingFrequencyTimeNotOnGround = time;
} }
if (time - lastTime > 1000) { if (time - lastTime > 1000) {
// Override // Override
onGroundSkip = true; onGroundSkip = true;
} }
} }
data.onGround = onGround; data.flyingFrequencyOnGround = onGround;
if (hasPos) { if (hasPos) {
final List<Double> doubles = packet.getDoubles().getValues(); final List<Double> doubles = packet.getDoubles().getValues();
@ -206,13 +175,15 @@ public class FlyingFrequency extends PacketAdapter implements JoinLeaveListener
return false; return false;
} }
// TODO: Could check first bucket or even just 50 ms to last packet. // Packet is redundant, if more than 20 packets per second arrive.
if (allScore / cc.flyingFrequencySeconds > 20f) { if (allScore / cc.flyingFrequencySeconds > 20f && !frequency.hasBypass(player)) {
counters.add(idRedundant, 1); // (Must re-check bypass here.)
return true; data.flyingFrequencyRedundantFreq.add(time, 1f);
} else { if (frequency.executeActions(player, data.flyingFrequencyRedundantFreq.score(1f) / cc.flyingFrequencyRedundantSeconds, 1.0 / cc.flyingFrequencyRedundantSeconds, cc.flyingFrequencyRedundantActions, true)) {
return false; return true;
}
} }
return false;
} }
/** /**

View File

@ -12,7 +12,7 @@ import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketAdapter;
import fr.neatmonster.nocheatplus.NCPAPIProvider; 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.DisableListener;
import fr.neatmonster.nocheatplus.components.INotifyReload; import fr.neatmonster.nocheatplus.components.INotifyReload;
import fr.neatmonster.nocheatplus.components.NoCheatPlusAPI; import fr.neatmonster.nocheatplus.components.NoCheatPlusAPI;
@ -28,7 +28,6 @@ import fr.neatmonster.nocheatplus.utilities.StringUtil;
*/ */
public class ProtocolLibComponent implements DisableListener, INotifyReload { public class ProtocolLibComponent implements DisableListener, INotifyReload {
private final NetConfigCache configs = new NetConfigCache();
private final List<PacketAdapter> registeredPacketAdapters = new LinkedList<PacketAdapter>(); private final List<PacketAdapter> registeredPacketAdapters = new LinkedList<PacketAdapter>();
public ProtocolLibComponent(Plugin plugin) { public ProtocolLibComponent(Plugin plugin) {
@ -75,7 +74,7 @@ public class ProtocolLibComponent implements DisableListener, INotifyReload {
private void register(Class<? extends PacketAdapter> clazz, Plugin plugin) { private void register(Class<? extends PacketAdapter> clazz, Plugin plugin) {
try { try {
// Construct a new instance using reflection. // 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); ProtocolLibrary.getProtocolManager().addPacketListener(adapter);
registeredPacketAdapters.add(adapter); registeredPacketAdapters.add(adapter);
} catch (Throwable t) { } catch (Throwable t) {
@ -92,6 +91,7 @@ public class ProtocolLibComponent implements DisableListener, INotifyReload {
@Override @Override
public void onReload() { public void onReload() {
unregister(); unregister();
CheckType.NET.getDataFactory().removeAllData(); // Currently needed for FlyingFRequency.
register(Bukkit.getPluginManager().getPlugin("NoCheatPlus")); // Store instead ? register(Bukkit.getPluginManager().getPlugin("NoCheatPlus")); // Store instead ?
} }
@ -107,7 +107,6 @@ public class ProtocolLibComponent implements DisableListener, INotifyReload {
} }
} }
registeredPacketAdapters.clear(); registeredPacketAdapters.clear();
configs.clearAllConfigs();
} }
} }

View File

@ -10,6 +10,7 @@ import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.reflect.StructureModifier; 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.NetConfig;
import fr.neatmonster.nocheatplus.checks.net.NetConfigCache; import fr.neatmonster.nocheatplus.checks.net.NetConfigCache;
import fr.neatmonster.nocheatplus.utilities.TrigUtil; import fr.neatmonster.nocheatplus.utilities.TrigUtil;
@ -38,9 +39,9 @@ public class SoundDistance extends PacketAdapter {
private final NetConfigCache configs; private final NetConfigCache configs;
private final Location useLoc = new Location(null, 0, 0, 0); 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); super(plugin, PacketType.Play.Server.NAMED_SOUND_EFFECT);
this.configs = configs; this.configs = (NetConfigCache) CheckType.NET.getConfigFactory(); // TODO: DataManager.getConfig(NetConfigCache.class);
} }
@Override @Override

View File

@ -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 * @param player
* the player * the player
@ -170,17 +171,29 @@ public abstract class Check implements MCAccessHolder{
if (!type.isEnabled(player)) { if (!type.isEnabled(player)) {
return false; 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. // TODO: Checking for the thread might be a temporary measure.
if (Bukkit.isPrimaryThread()) { if (Bukkit.isPrimaryThread()) {
// Check permissions directly. // Check permissions directly.
if (player.hasPermission(type.getPermission())) { final String permission = type.getPermission();
return false; if (permission != null && player.hasPermission(permission)) {
return true;
} }
} }
else if (type.hasCachedPermission(player)) { else if (type.hasCachedPermission(player)) {
// Assume asynchronously running check. // Assume asynchronously running check.
return false; return true;
} }
// TODO: ExemptionManager relies on initial setup (problematic).
return !NCPExemptionManager.isExempted(player, type); return !NCPExemptionManager.isExempted(player, type);
} }

View File

@ -20,6 +20,8 @@ import fr.neatmonster.nocheatplus.checks.inventory.InventoryConfig;
import fr.neatmonster.nocheatplus.checks.inventory.InventoryData; import fr.neatmonster.nocheatplus.checks.inventory.InventoryData;
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig; import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
import fr.neatmonster.nocheatplus.checks.moving.MovingData; 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; import fr.neatmonster.nocheatplus.permissions.Permissions;
/** /**
@ -60,8 +62,8 @@ public enum CheckType {
CHAT_TEXT(CHAT, Permissions.CHAT_TEXT), CHAT_TEXT(CHAT, Permissions.CHAT_TEXT),
CHAT_LOGINS(CHAT, Permissions.CHAT_LOGINS), CHAT_LOGINS(CHAT, Permissions.CHAT_LOGINS),
CHAT_RELOG(CHAT, Permissions.CHAT_RELOG), CHAT_RELOG(CHAT, Permissions.CHAT_RELOG),
COMBINED(CombinedConfig.factory, CombinedData.factory, Permissions.COMBINED), COMBINED(CombinedConfig.factory, CombinedData.factory, Permissions.COMBINED),
COMBINED_BEDLEAVE(COMBINED, Permissions.COMBINED_BEDLEAVE), COMBINED_BEDLEAVE(COMBINED, Permissions.COMBINED_BEDLEAVE),
COMBINED_IMPROBABLE(COMBINED, Permissions.COMBINED_IMPROBABLE), COMBINED_IMPROBABLE(COMBINED, Permissions.COMBINED_IMPROBABLE),
@ -95,68 +97,76 @@ public enum CheckType {
MOVING_NOFALL(MOVING, Permissions.MOVING_NOFALL), MOVING_NOFALL(MOVING, Permissions.MOVING_NOFALL),
MOVING_PASSABLE(MOVING, Permissions.MOVING_PASSABLE), MOVING_PASSABLE(MOVING, Permissions.MOVING_PASSABLE),
MOVING_SURVIVALFLY(MOVING, Permissions.MOVING_SURVIVALFLY), 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; UNKNOWN;
/** If not null, this is the check group usually. */ /** If not null, this is the check group usually. */
private final CheckType parent; private final CheckType parent;
/** The check config factory (access CheckConfig instances by CheckType). */ /** The check config factory (access CheckConfig instances by CheckType). */
private final CheckConfigFactory configFactory; private final CheckConfigFactory configFactory;
/** The check data factory (access CheckData instances by CheckType). */ /** The check data factory (access CheckData instances by CheckType). */
private final CheckDataFactory dataFactory; private final CheckDataFactory dataFactory;
/** The bypass permission. */ /** The bypass permission. */
private final String permission; private final String permission;
/** /**
* Special purpose check types (likely not actual checks). * Special purpose check types (likely not actual checks).
*/ */
private CheckType() { private CheckType() {
this(null, null, null); 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);
}
/** /**
* Constructor for sub-checks grouped under another check type. * Special purpose for grouping (ALL).
* @param parent * @param permission
* @param permission */
*/ private CheckType(final String permission){
private CheckType(final CheckType parent, final String permission) { this(null, null, permission);
this(parent, permission, parent.getConfigFactory(), parent.getDataFactory()); }
}
/** private CheckType(final CheckType parent) {
* General constructor (usually used for root check groups). this(parent, null);
* @param parent Super check type (usually the group). }
* @param permission Bypass permission.
* @param configFactory Check config factory. /**
* @param dataFactory Check data factory. * Constructor for root checks or check groups, that are not grouped under another check type.
*/ * @param configFactory
private CheckType(final CheckType parent, final String permission, final CheckConfigFactory configFactory, final CheckDataFactory dataFactory) { * @param dataFactory
this.parent = parent; * @param permission
this.permission = permission; */
this.configFactory = configFactory; private CheckType(final CheckConfigFactory configFactory, final CheckDataFactory dataFactory, final String permission) {
this.dataFactory = dataFactory; 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. * Gets the configFactory.
@ -202,16 +212,16 @@ public enum CheckType {
public String getPermission() { public String getPermission() {
return permission; return permission;
} }
/** /**
* Quick permission check for cached entriy only (for async checks). If not present, after failure will need to deal with this. * Quick permission check for cached entriy only (for async checks). If not present, after failure will need to deal with this.
* @param player * @param player
* @return * @return
*/ */
public boolean hasCachedPermission(final Player player){ 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. * Quick permission check for cached entries only (for async checks). If not present, after failure will need to deal with this.
* @param player * @param player
@ -219,7 +229,7 @@ public enum CheckType {
* @return * @return
*/ */
public boolean hasCachedPermission(final Player player, final String permission){ public boolean hasCachedPermission(final Player player, final String permission){
return dataFactory.getData(player).hasCachedPermission(permission); return dataFactory.getData(player).hasCachedPermission(permission);
} }
/** /**

View File

@ -18,4 +18,9 @@ public interface CheckConfigFactory {
*/ */
public ICheckConfig getConfig(Player player); public ICheckConfig getConfig(Player player);
/**
* Remove all stored configurations.
*/
public void removeAllConfigs();
} }

View File

@ -21,13 +21,18 @@ import fr.neatmonster.nocheatplus.permissions.Permissions;
*/ */
public class BlockBreakConfig extends ACheckConfig { public class BlockBreakConfig extends ACheckConfig {
/** The factory creating configurations. */ /** The factory creating configurations. */
public static final CheckConfigFactory factory = new CheckConfigFactory() { public static final CheckConfigFactory factory = new CheckConfigFactory() {
@Override @Override
public final ICheckConfig getConfig(final Player player) { public final ICheckConfig getConfig(final Player player) {
return BlockBreakConfig.getConfig(player); return BlockBreakConfig.getConfig(player);
} }
};
@Override
public void removeAllConfigs() {
clear(); // Band-aid.
}
};
/** The map containing the configurations per world. */ /** The map containing the configurations per world. */
private static final Map<String, BlockBreakConfig> worldsMap = new HashMap<String, BlockBreakConfig>(); private static final Map<String, BlockBreakConfig> worldsMap = new HashMap<String, BlockBreakConfig>();
@ -58,27 +63,27 @@ public class BlockBreakConfig extends ACheckConfig {
public final boolean fastBreakCheck; public final boolean fastBreakCheck;
public final boolean fastBreakStrict; public final boolean fastBreakStrict;
public final int fastBreakBuckets; public final int fastBreakBuckets;
public final long fastBreakBucketDur; public final long fastBreakBucketDur;
public final float fastBreakBucketFactor; public final float fastBreakBucketFactor;
public final long fastBreakGrace; public final long fastBreakGrace;
public final long fastBreakDelay; public final long fastBreakDelay;
public final int fastBreakModSurvival; public final int fastBreakModSurvival;
public final ActionList fastBreakActions; public final ActionList fastBreakActions;
public final boolean frequencyCheck; public final boolean frequencyCheck;
public final int frequencyBuckets; public final int frequencyBuckets;
public final long frequencyBucketDur; public final long frequencyBucketDur;
public final float frequencyBucketFactor; public final float frequencyBucketFactor;
public final int frequencyIntervalCreative; public final int frequencyIntervalCreative;
public final int frequencyIntervalSurvival; public final int frequencyIntervalSurvival;
public final int frequencyShortTermLimit; public final int frequencyShortTermLimit;
public final int frequencyShortTermTicks; public final int frequencyShortTermTicks;
public final ActionList frequencyActions; public final ActionList frequencyActions;
public boolean improbableFastBreakCheck; public boolean improbableFastBreakCheck;
public final boolean noSwingCheck; public final boolean noSwingCheck;
public final ActionList noSwingActions; public final ActionList noSwingActions;
@ -87,9 +92,9 @@ public class BlockBreakConfig extends ACheckConfig {
public final ActionList reachActions; public final ActionList reachActions;
public final boolean wrongBlockCheck; public final boolean wrongBlockCheck;
public final float wrongBLockLevel; public final float wrongBLockLevel;
public final ActionList wrongBlockActions; public final ActionList wrongBlockActions;
/** /**
* Instantiates a new block break configuration. * Instantiates a new block break configuration.
* *
@ -120,15 +125,15 @@ public class BlockBreakConfig extends ACheckConfig {
frequencyIntervalCreative = data.getInt(ConfPaths.BLOCKBREAK_FREQUENCY_MOD_CREATIVE); frequencyIntervalCreative = data.getInt(ConfPaths.BLOCKBREAK_FREQUENCY_MOD_CREATIVE);
frequencyIntervalSurvival = data.getInt(ConfPaths.BLOCKBREAK_FREQUENCY_MOD_SURVIVAL); frequencyIntervalSurvival = data.getInt(ConfPaths.BLOCKBREAK_FREQUENCY_MOD_SURVIVAL);
frequencyShortTermLimit = data.getInt(ConfPaths.BLOCKBREAK_FREQUENCY_SHORTTERM_LIMIT); 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); frequencyActions = data.getOptimizedActionList(ConfPaths.BLOCKBREAK_FREQUENCY_ACTIONS, Permissions.BLOCKBREAK_FREQUENCY);
noSwingCheck = data.getBoolean(ConfPaths.BLOCKBREAK_NOSWING_CHECK); noSwingCheck = data.getBoolean(ConfPaths.BLOCKBREAK_NOSWING_CHECK);
noSwingActions = data.getOptimizedActionList(ConfPaths.BLOCKBREAK_NOSWING_ACTIONS, Permissions.BLOCKBREAK_NOSWING); noSwingActions = data.getOptimizedActionList(ConfPaths.BLOCKBREAK_NOSWING_ACTIONS, Permissions.BLOCKBREAK_NOSWING);
reachCheck = data.getBoolean(ConfPaths.BLOCKBREAK_REACH_CHECK); reachCheck = data.getBoolean(ConfPaths.BLOCKBREAK_REACH_CHECK);
reachActions = data.getOptimizedActionList(ConfPaths.BLOCKBREAK_REACH_ACTIONS, Permissions.BLOCKBREAK_REACH); reachActions = data.getOptimizedActionList(ConfPaths.BLOCKBREAK_REACH_ACTIONS, Permissions.BLOCKBREAK_REACH);
wrongBlockCheck = data.getBoolean(ConfPaths.BLOCKBREAK_WRONGBLOCK_CHECK); wrongBlockCheck = data.getBoolean(ConfPaths.BLOCKBREAK_WRONGBLOCK_CHECK);
wrongBLockLevel = data.getInt(ConfPaths.BLOCKBREAK_WRONGBLOCK_LEVEL); wrongBLockLevel = data.getInt(ConfPaths.BLOCKBREAK_WRONGBLOCK_LEVEL);
wrongBlockActions = data.getOptimizedActionList(ConfPaths.BLOCKBREAK_WRONGBLOCK_ACTIONS, Permissions.BLOCKBREAK_WRONGBLOCK); wrongBlockActions = data.getOptimizedActionList(ConfPaths.BLOCKBREAK_WRONGBLOCK_ACTIONS, Permissions.BLOCKBREAK_WRONGBLOCK);
@ -140,22 +145,22 @@ public class BlockBreakConfig extends ACheckConfig {
@Override @Override
public final boolean isEnabled(final CheckType checkType) { public final boolean isEnabled(final CheckType checkType) {
switch (checkType) { switch (checkType) {
case BLOCKBREAK_DIRECTION: case BLOCKBREAK_DIRECTION:
return directionCheck; return directionCheck;
case BLOCKBREAK_FASTBREAK: case BLOCKBREAK_FASTBREAK:
return fastBreakCheck; return fastBreakCheck;
case BLOCKBREAK_FREQUENCY: case BLOCKBREAK_FREQUENCY:
return frequencyCheck; return frequencyCheck;
case BLOCKBREAK_NOSWING: case BLOCKBREAK_NOSWING:
return noSwingCheck; return noSwingCheck;
case BLOCKBREAK_REACH: case BLOCKBREAK_REACH:
return reachCheck; return reachCheck;
case BLOCKBREAK_WRONGBLOCK: case BLOCKBREAK_WRONGBLOCK:
return wrongBlockCheck; return wrongBlockCheck;
case BLOCKBREAK_BREAK: case BLOCKBREAK_BREAK:
return true; return true;
default: default:
return true; return true;
} }
} }
} }

View File

@ -21,13 +21,18 @@ import fr.neatmonster.nocheatplus.permissions.Permissions;
*/ */
public class BlockInteractConfig extends ACheckConfig { public class BlockInteractConfig extends ACheckConfig {
/** The factory creating configurations. */ /** The factory creating configurations. */
public static final CheckConfigFactory factory = new CheckConfigFactory() { public static final CheckConfigFactory factory = new CheckConfigFactory() {
@Override @Override
public final ICheckConfig getConfig(final Player player) { public final ICheckConfig getConfig(final Player player) {
return BlockInteractConfig.getConfig(player); return BlockInteractConfig.getConfig(player);
} }
};
@Override
public void removeAllConfigs() {
clear(); // Band-aid.
}
};
/** The map containing the configurations per world. */ /** The map containing the configurations per world. */
private static final Map<String, BlockInteractConfig> worldsMap = new HashMap<String, BlockInteractConfig>(); private static final Map<String, BlockInteractConfig> worldsMap = new HashMap<String, BlockInteractConfig>();
@ -58,12 +63,12 @@ public class BlockInteractConfig extends ACheckConfig {
public final boolean reachCheck; public final boolean reachCheck;
public final ActionList reachActions; public final ActionList reachActions;
public final boolean speedCheck; public final boolean speedCheck;
public final long speedInterval; public final long speedInterval;
public final int speedLimit; public final int speedLimit;
public final ActionList speedActions; public final ActionList speedActions;
public final boolean visibleCheck; public final boolean visibleCheck;
public final ActionList visibleActions; public final ActionList visibleActions;
@ -81,12 +86,12 @@ public class BlockInteractConfig extends ACheckConfig {
reachCheck = data.getBoolean(ConfPaths.BLOCKINTERACT_REACH_CHECK); reachCheck = data.getBoolean(ConfPaths.BLOCKINTERACT_REACH_CHECK);
reachActions = data.getOptimizedActionList(ConfPaths.BLOCKINTERACT_REACH_ACTIONS, Permissions.BLOCKINTERACT_REACH); reachActions = data.getOptimizedActionList(ConfPaths.BLOCKINTERACT_REACH_ACTIONS, Permissions.BLOCKINTERACT_REACH);
speedCheck = data.getBoolean(ConfPaths.BLOCKINTERACT_SPEED_CHECK); speedCheck = data.getBoolean(ConfPaths.BLOCKINTERACT_SPEED_CHECK);
speedInterval = data.getLong(ConfPaths.BLOCKINTERACT_SPEED_INTERVAL); speedInterval = data.getLong(ConfPaths.BLOCKINTERACT_SPEED_INTERVAL);
speedLimit = data.getInt(ConfPaths.BLOCKINTERACT_SPEED_LIMIT); speedLimit = data.getInt(ConfPaths.BLOCKINTERACT_SPEED_LIMIT);
speedActions = data.getOptimizedActionList(ConfPaths.BLOCKINTERACT_SPEED_ACTIONS, Permissions.BLOCKINTERACT_SPEED); speedActions = data.getOptimizedActionList(ConfPaths.BLOCKINTERACT_SPEED_ACTIONS, Permissions.BLOCKINTERACT_SPEED);
visibleCheck = data.getBoolean(ConfPaths.BLOCKINTERACT_VISIBLE_CHECK); visibleCheck = data.getBoolean(ConfPaths.BLOCKINTERACT_VISIBLE_CHECK);
visibleActions = data.getOptimizedActionList(ConfPaths.BLOCKINTERACT_VISIBLE_ACTIONS, Permissions.BLOCKINTERACT_VISIBLE); visibleActions = data.getOptimizedActionList(ConfPaths.BLOCKINTERACT_VISIBLE_ACTIONS, Permissions.BLOCKINTERACT_VISIBLE);
} }
@ -97,16 +102,16 @@ public class BlockInteractConfig extends ACheckConfig {
@Override @Override
public final boolean isEnabled(final CheckType checkType) { public final boolean isEnabled(final CheckType checkType) {
switch (checkType) { switch (checkType) {
case BLOCKINTERACT_SPEED: case BLOCKINTERACT_SPEED:
return speedCheck; return speedCheck;
case BLOCKINTERACT_DIRECTION: case BLOCKINTERACT_DIRECTION:
return directionCheck; return directionCheck;
case BLOCKINTERACT_REACH: case BLOCKINTERACT_REACH:
return reachCheck; return reachCheck;
case BLOCKINTERACT_VISIBLE: case BLOCKINTERACT_VISIBLE:
return visibleCheck; return visibleCheck;
default: default:
return true; return true;
} }
} }
} }

View File

@ -24,13 +24,18 @@ import fr.neatmonster.nocheatplus.permissions.Permissions;
*/ */
public class BlockPlaceConfig extends ACheckConfig { public class BlockPlaceConfig extends ACheckConfig {
/** The factory creating configurations. */ /** The factory creating configurations. */
public static final CheckConfigFactory factory = new CheckConfigFactory() { public static final CheckConfigFactory factory = new CheckConfigFactory() {
@Override @Override
public final ICheckConfig getConfig(final Player player) { public final ICheckConfig getConfig(final Player player) {
return BlockPlaceConfig.getConfig(player); return BlockPlaceConfig.getConfig(player);
} }
};
@Override
public void removeAllConfigs() {
clear(); // Band-aid.
}
};
/** The map containing the configurations per world. */ /** The map containing the configurations per world. */
private static final Map<String, BlockPlaceConfig> worldsMap = new HashMap<String, BlockPlaceConfig>(); private static final Map<String, BlockPlaceConfig> worldsMap = new HashMap<String, BlockPlaceConfig>();
@ -55,10 +60,10 @@ public class BlockPlaceConfig extends ACheckConfig {
new BlockPlaceConfig(ConfigManager.getConfigFile(player.getWorld().getName()))); new BlockPlaceConfig(ConfigManager.getConfigFile(player.getWorld().getName())));
return worldsMap.get(player.getWorld().getName()); return worldsMap.get(player.getWorld().getName());
} }
public final boolean againstCheck; public final boolean againstCheck;
public final ActionList againstActions; public final ActionList againstActions;
public final boolean autoSignCheck; public final boolean autoSignCheck;
public final ActionList autoSignActions; public final ActionList autoSignActions;
@ -90,14 +95,14 @@ public class BlockPlaceConfig extends ACheckConfig {
*/ */
public BlockPlaceConfig(final ConfigFile data) { public BlockPlaceConfig(final ConfigFile data) {
super(data, ConfPaths.BLOCKPLACE); super(data, ConfPaths.BLOCKPLACE);
againstCheck = data.getBoolean(ConfPaths.BLOCKPLACE_AGAINST_CHECK); againstCheck = data.getBoolean(ConfPaths.BLOCKPLACE_AGAINST_CHECK);
againstActions = data.getOptimizedActionList(ConfPaths.BLOCKPLACE_AGAINST_ACTIONS, Permissions.BLOCKPLACE_AGAINST); againstActions = data.getOptimizedActionList(ConfPaths.BLOCKPLACE_AGAINST_ACTIONS, Permissions.BLOCKPLACE_AGAINST);
autoSignCheck = data.getBoolean(ConfPaths.BLOCKPLACE_AUTOSIGN_CHECK); autoSignCheck = data.getBoolean(ConfPaths.BLOCKPLACE_AUTOSIGN_CHECK);
autoSignActions = data.getOptimizedActionList(ConfPaths.BLOCKPLACE_AUTOSIGN_ACTIONS, Permissions.BLOCKPLACE_AUTOSIGN); autoSignActions = data.getOptimizedActionList(ConfPaths.BLOCKPLACE_AUTOSIGN_ACTIONS, Permissions.BLOCKPLACE_AUTOSIGN);
directionCheck = data.getBoolean(ConfPaths.BLOCKPLACE_DIRECTION_CHECK); directionCheck = data.getBoolean(ConfPaths.BLOCKPLACE_DIRECTION_CHECK);
directionActions = data.getOptimizedActionList(ConfPaths.BLOCKPLACE_DIRECTION_ACTIONS, Permissions.BLOCKPLACE_DIRECTION); directionActions = data.getOptimizedActionList(ConfPaths.BLOCKPLACE_DIRECTION_ACTIONS, Permissions.BLOCKPLACE_DIRECTION);
@ -125,22 +130,22 @@ public class BlockPlaceConfig extends ACheckConfig {
@Override @Override
public final boolean isEnabled(final CheckType checkType) { public final boolean isEnabled(final CheckType checkType) {
switch (checkType) { switch (checkType) {
case BLOCKPLACE_DIRECTION: case BLOCKPLACE_DIRECTION:
return directionCheck; return directionCheck;
case BLOCKPLACE_FASTPLACE: case BLOCKPLACE_FASTPLACE:
return fastPlaceCheck; return fastPlaceCheck;
case BLOCKPLACE_NOSWING: case BLOCKPLACE_NOSWING:
return noSwingCheck; return noSwingCheck;
case BLOCKPLACE_REACH: case BLOCKPLACE_REACH:
return reachCheck; return reachCheck;
case BLOCKPLACE_SPEED: case BLOCKPLACE_SPEED:
return speedCheck; return speedCheck;
case BLOCKPLACE_AGAINST: case BLOCKPLACE_AGAINST:
return againstCheck; return againstCheck;
case BLOCKPLACE_AUTOSIGN: case BLOCKPLACE_AUTOSIGN:
return autoSignCheck; return autoSignCheck;
default: default:
return true; return true;
} }
} }
} }

View File

@ -25,15 +25,20 @@ public class ChatConfig extends ACheckConfig {
/** The factory creating configurations. */ /** The factory creating configurations. */
public static final CheckConfigFactory factory = new CheckConfigFactory() { public static final CheckConfigFactory factory = new CheckConfigFactory() {
@Override @Override
public final ICheckConfig getConfig(final Player player) { public final ICheckConfig getConfig(final Player player) {
return ChatConfig.getConfig(player); return ChatConfig.getConfig(player);
} }
};
@Override
public void removeAllConfigs() {
clear(); // Band-aid.
}
};
/** The map containing the configurations per world. */ /** The map containing the configurations per world. */
private static final Map<String, ChatConfig> worldsMap = new HashMap<String, ChatConfig>(); private static final Map<String, ChatConfig> worldsMap = new HashMap<String, ChatConfig>();
/** /**
* Clear all the configurations. * Clear all the configurations.
*/ */
@ -43,7 +48,7 @@ public class ChatConfig extends ACheckConfig {
} }
} }
/** /**
* Gets the configuration for a specified player. * Gets the configuration for a specified player.
* *
* @param player * @param player
@ -58,7 +63,7 @@ public class ChatConfig extends ACheckConfig {
return worldsMap.get(player.getWorld().getName()); return worldsMap.get(player.getWorld().getName());
} }
} }
public final boolean captchaCheck; public final boolean captchaCheck;
public final String captchaCharacters; public final String captchaCharacters;
public final int captchaLength; public final int captchaLength;
@ -69,19 +74,19 @@ public class ChatConfig extends ACheckConfig {
public final boolean colorCheck; public final boolean colorCheck;
public final ActionList colorActions; public final ActionList colorActions;
public final boolean commandsCheck; public final boolean commandsCheck;
public final double commandsLevel; public final double commandsLevel;
public final int commandsShortTermTicks; public final int commandsShortTermTicks;
public final double commandsShortTermLevel; public final double commandsShortTermLevel;
public final ActionList commandsActions; public final ActionList commandsActions;
public final boolean textCheck; public final boolean textCheck;
public final boolean textGlobalCheck; public final boolean textGlobalCheck;
public final boolean textPlayerCheck; public final boolean textPlayerCheck;
public final EnginePlayerConfig textEnginePlayerConfig; public final EnginePlayerConfig textEnginePlayerConfig;
public final float textFreqNormFactor; public final float textFreqNormFactor;
public final float textFreqNormWeight; public final float textFreqNormWeight;
public final float textFreqNormMin; public final float textFreqNormMin;
public final double textFreqNormLevel; public final double textFreqNormLevel;
public final ActionList textFreqNormActions; public final ActionList textFreqNormActions;
@ -91,29 +96,29 @@ public class ChatConfig extends ACheckConfig {
public final float textFreqShortTermMin; public final float textFreqShortTermMin;
public final ActionList textFreqShortTermActions; public final ActionList textFreqShortTermActions;
public final float textMessageLetterCount; public final float textMessageLetterCount;
public final float textMessageUpperCase; public final float textMessageUpperCase;
public final float textMessagePartition; public final float textMessagePartition;
public final float textMsgRepeatCancel; public final float textMsgRepeatCancel;
public final float textMsgAfterJoin; public final float textMsgAfterJoin;
public final float textMsgRepeatSelf; public final float textMsgRepeatSelf;
public final float textMsgRepeatGlobal; public final float textMsgRepeatGlobal;
public final float textMsgNoMoving; public final float textMsgNoMoving;
// words // words
public final float textMessageLengthAv; public final float textMessageLengthAv;
public final float textMessageLengthMsg; public final float textMessageLengthMsg;
public final float textMessageNoLetter; public final float textMessageNoLetter;
public final float textGlobalWeight; public final float textGlobalWeight;
public final float textPlayerWeight; public final float textPlayerWeight;
public final boolean textEngineMaximum; public final boolean textEngineMaximum;
public final boolean textAllowVLReset; public final boolean textAllowVLReset;
public final boolean textDebug; public final boolean textDebug;
public final boolean chatWarningCheck; public final boolean chatWarningCheck;
public final float chatWarningLevel; public final float chatWarningLevel;
public final String chatWarningMessage; public final String chatWarningMessage;
public final long chatWarningTimeout; public final long chatWarningTimeout;
public final boolean loginsCheck; public final boolean loginsCheck;
public final boolean loginsPerWorldCount; public final boolean loginsPerWorldCount;
public final int loginsSeconds; public final int loginsSeconds;
@ -124,7 +129,7 @@ public class ChatConfig extends ACheckConfig {
public final boolean consoleOnlyCheck; public final boolean consoleOnlyCheck;
public final String consoleOnlyMessage; public final String consoleOnlyMessage;
public final boolean relogCheck; public final boolean relogCheck;
public final String relogKickMessage; public final String relogKickMessage;
public final long relogTimeout; public final long relogTimeout;
@ -132,7 +137,7 @@ public class ChatConfig extends ACheckConfig {
public final int relogWarningNumber; public final int relogWarningNumber;
public final long relogWarningTimeout; public final long relogWarningTimeout;
public final ActionList relogActions; public final ActionList relogActions;
/** /**
* Instantiates a new chat configuration. * Instantiates a new chat configuration.
* *
@ -140,13 +145,13 @@ public class ChatConfig extends ACheckConfig {
* the data * the data
*/ */
public ChatConfig(final ConfigFile config) { public ChatConfig(final ConfigFile config) {
super(config, ConfPaths.CHAT, new String[]{ super(config, ConfPaths.CHAT, new String[]{
// Only the permissions needed for async. checking. // Only the permissions needed for async. checking.
Permissions.CHAT_COLOR, Permissions.CHAT_COLOR,
Permissions.CHAT_TEXT, Permissions.CHAT_TEXT,
Permissions.CHAT_CAPTCHA, Permissions.CHAT_CAPTCHA,
}); });
captchaCheck = config.getBoolean(ConfPaths.CHAT_CAPTCHA_CHECK); captchaCheck = config.getBoolean(ConfPaths.CHAT_CAPTCHA_CHECK);
captchaCharacters = config.getString(ConfPaths.CHAT_CAPTCHA_CHARACTERS); captchaCharacters = config.getString(ConfPaths.CHAT_CAPTCHA_CHARACTERS);
captchaLength = config.getInt(ConfPaths.CHAT_CAPTCHA_LENGTH); captchaLength = config.getInt(ConfPaths.CHAT_CAPTCHA_LENGTH);
@ -154,20 +159,20 @@ public class ChatConfig extends ACheckConfig {
captchaSuccess = config.getString(ConfPaths.CHAT_CAPTCHA_SUCCESS); captchaSuccess = config.getString(ConfPaths.CHAT_CAPTCHA_SUCCESS);
captchaTries = config.getInt(ConfPaths.CHAT_CAPTCHA_TRIES); captchaTries = config.getInt(ConfPaths.CHAT_CAPTCHA_TRIES);
captchaActions = config.getOptimizedActionList(ConfPaths.CHAT_CAPTCHA_ACTIONS, Permissions.CHAT_CAPTCHA); captchaActions = config.getOptimizedActionList(ConfPaths.CHAT_CAPTCHA_ACTIONS, Permissions.CHAT_CAPTCHA);
colorCheck = config.getBoolean(ConfPaths.CHAT_COLOR_CHECK); colorCheck = config.getBoolean(ConfPaths.CHAT_COLOR_CHECK);
colorActions = config.getOptimizedActionList(ConfPaths.CHAT_COLOR_ACTIONS, Permissions.CHAT_COLOR); colorActions = config.getOptimizedActionList(ConfPaths.CHAT_COLOR_ACTIONS, Permissions.CHAT_COLOR);
commandsCheck = config.getBoolean(ConfPaths.CHAT_COMMANDS_CHECK); commandsCheck = config.getBoolean(ConfPaths.CHAT_COMMANDS_CHECK);
commandsLevel = config.getDouble(ConfPaths.CHAT_COMMANDS_LEVEL); commandsLevel = config.getDouble(ConfPaths.CHAT_COMMANDS_LEVEL);
commandsShortTermTicks = config.getInt(ConfPaths.CHAT_COMMANDS_SHORTTERM_TICKS); commandsShortTermTicks = config.getInt(ConfPaths.CHAT_COMMANDS_SHORTTERM_TICKS);
commandsShortTermLevel = config.getDouble(ConfPaths.CHAT_COMMANDS_SHORTTERM_LEVEL);; commandsShortTermLevel = config.getDouble(ConfPaths.CHAT_COMMANDS_SHORTTERM_LEVEL);;
commandsActions = config.getOptimizedActionList(ConfPaths.CHAT_COMMANDS_ACTIONS, Permissions.CHAT_COMMANDS); commandsActions = config.getOptimizedActionList(ConfPaths.CHAT_COMMANDS_ACTIONS, Permissions.CHAT_COMMANDS);
textCheck = config.getBoolean(ConfPaths.CHAT_TEXT_CHECK); textCheck = config.getBoolean(ConfPaths.CHAT_TEXT_CHECK);
textGlobalCheck = config.getBoolean(ConfPaths.CHAT_TEXT_GL_CHECK, true); textGlobalCheck = config.getBoolean(ConfPaths.CHAT_TEXT_GL_CHECK, true);
textPlayerCheck = config.getBoolean(ConfPaths.CHAT_TEXT_PP_CHECK, true); textPlayerCheck = config.getBoolean(ConfPaths.CHAT_TEXT_PP_CHECK, true);
textEnginePlayerConfig = new EnginePlayerConfig(config); textEnginePlayerConfig = new EnginePlayerConfig(config);
textFreqNormMin = (float) config.getDouble(ConfPaths.CHAT_TEXT_FREQ_NORM_MIN); textFreqNormMin = (float) config.getDouble(ConfPaths.CHAT_TEXT_FREQ_NORM_MIN);
textFreqNormFactor = (float) config.getDouble(ConfPaths.CHAT_TEXT_FREQ_NORM_FACTOR); 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); textMsgRepeatSelf = (float) config.getDouble(ConfPaths.CHAT_TEXT_MSG_REPEATSELF);
textMsgRepeatGlobal = (float) config.getDouble(ConfPaths.CHAT_TEXT_MSG_REPEATGLOBAL); textMsgRepeatGlobal = (float) config.getDouble(ConfPaths.CHAT_TEXT_MSG_REPEATGLOBAL);
textMsgNoMoving = (float) config.getDouble(ConfPaths.CHAT_TEXT_MSG_NOMOVING); textMsgNoMoving = (float) config.getDouble(ConfPaths.CHAT_TEXT_MSG_NOMOVING);
textMessageLengthAv = (float) config.getDouble(ConfPaths.CHAT_TEXT_MSG_WORDS_LENGTHAV); textMessageLengthAv = (float) config.getDouble(ConfPaths.CHAT_TEXT_MSG_WORDS_LENGTHAV);
textMessageLengthMsg = (float) config.getDouble(ConfPaths.CHAT_TEXT_MSG_WORDS_LENGTHMSG); textMessageLengthMsg = (float) config.getDouble(ConfPaths.CHAT_TEXT_MSG_WORDS_LENGTHMSG);
textMessageNoLetter = (float) config.getDouble(ConfPaths.CHAT_TEXT_MSG_WORDS_NOLETTER); textMessageNoLetter = (float) config.getDouble(ConfPaths.CHAT_TEXT_MSG_WORDS_NOLETTER);
textGlobalWeight = (float) config.getDouble(ConfPaths.CHAT_TEXT_GL_WEIGHT, 1.0); textGlobalWeight = (float) config.getDouble(ConfPaths.CHAT_TEXT_GL_WEIGHT, 1.0);
textPlayerWeight = (float) config.getDouble(ConfPaths.CHAT_TEXT_PP_WEIGHT, 1.0); textPlayerWeight = (float) config.getDouble(ConfPaths.CHAT_TEXT_PP_WEIGHT, 1.0);
textFreqNormLevel = config.getDouble(ConfPaths.CHAT_TEXT_FREQ_NORM_LEVEL); textFreqNormLevel = config.getDouble(ConfPaths.CHAT_TEXT_FREQ_NORM_LEVEL);
textEngineMaximum = config.getBoolean(ConfPaths.CHAT_TEXT_ENGINE_MAXIMUM, true); textEngineMaximum = config.getBoolean(ConfPaths.CHAT_TEXT_ENGINE_MAXIMUM, true);
textDebug = config.getBoolean(ConfPaths.CHAT_TEXT_DEBUG, false); textDebug = config.getBoolean(ConfPaths.CHAT_TEXT_DEBUG, false);
textFreqNormActions = config.getOptimizedActionList(ConfPaths.CHAT_TEXT_FREQ_NORM_ACTIONS, Permissions.CHAT_TEXT); textFreqNormActions = config.getOptimizedActionList(ConfPaths.CHAT_TEXT_FREQ_NORM_ACTIONS, Permissions.CHAT_TEXT);
textAllowVLReset = config.getBoolean(ConfPaths.CHAT_TEXT_ALLOWVLRESET); textAllowVLReset = config.getBoolean(ConfPaths.CHAT_TEXT_ALLOWVLRESET);
chatWarningCheck = config.getBoolean(ConfPaths.CHAT_WARNING_CHECK); chatWarningCheck = config.getBoolean(ConfPaths.CHAT_WARNING_CHECK);
chatWarningLevel = (float) config.getDouble(ConfPaths.CHAT_WARNING_LEVEL); chatWarningLevel = (float) config.getDouble(ConfPaths.CHAT_WARNING_LEVEL);
chatWarningMessage = config.getString(ConfPaths.CHAT_WARNING_MESSAGE); chatWarningMessage = config.getString(ConfPaths.CHAT_WARNING_MESSAGE);
chatWarningTimeout = config.getLong(ConfPaths.CHAT_WARNING_TIMEOUT) * 1000; chatWarningTimeout = config.getLong(ConfPaths.CHAT_WARNING_TIMEOUT) * 1000;
loginsCheck = config.getBoolean(ConfPaths.CHAT_LOGINS_CHECK); loginsCheck = config.getBoolean(ConfPaths.CHAT_LOGINS_CHECK);
loginsPerWorldCount = config.getBoolean(ConfPaths.CHAT_LOGINS_PERWORLDCOUNT); loginsPerWorldCount = config.getBoolean(ConfPaths.CHAT_LOGINS_PERWORLDCOUNT);
loginsSeconds = config.getInt(ConfPaths.CHAT_LOGINS_SECONDS); loginsSeconds = config.getInt(ConfPaths.CHAT_LOGINS_SECONDS);
loginsLimit = config.getInt(ConfPaths.CHAT_LOGINS_LIMIT); loginsLimit = config.getInt(ConfPaths.CHAT_LOGINS_LIMIT);
loginsKickMessage = config.getString(ConfPaths.CHAT_LOGINS_KICKMESSAGE); loginsKickMessage = config.getString(ConfPaths.CHAT_LOGINS_KICKMESSAGE);
loginsStartupDelay = config.getInt(ConfPaths.CHAT_LOGINS_STARTUPDELAY) * 1000; loginsStartupDelay = config.getInt(ConfPaths.CHAT_LOGINS_STARTUPDELAY) * 1000;
relogCheck = config.getBoolean(ConfPaths.CHAT_RELOG_CHECK); relogCheck = config.getBoolean(ConfPaths.CHAT_RELOG_CHECK);
relogKickMessage = config.getString(ConfPaths.CHAT_RELOG_KICKMESSAGE); relogKickMessage = config.getString(ConfPaths.CHAT_RELOG_KICKMESSAGE);
relogTimeout = config.getLong(ConfPaths.CHAT_RELOG_TIMEOUT); relogTimeout = config.getLong(ConfPaths.CHAT_RELOG_TIMEOUT);
@ -228,20 +233,20 @@ public class ChatConfig extends ACheckConfig {
@Override @Override
public boolean isEnabled(final CheckType checkType) { public boolean isEnabled(final CheckType checkType) {
switch (checkType) { switch (checkType) {
case CHAT_COLOR: case CHAT_COLOR:
return colorCheck; return colorCheck;
case CHAT_TEXT: case CHAT_TEXT:
return textCheck; return textCheck;
case CHAT_COMMANDS: case CHAT_COMMANDS:
return commandsCheck; return commandsCheck;
case CHAT_CAPTCHA: case CHAT_CAPTCHA:
return captchaCheck; return captchaCheck;
case CHAT_RELOG: case CHAT_RELOG:
return relogCheck; return relogCheck;
case CHAT_LOGINS: case CHAT_LOGINS:
return loginsCheck; return loginsCheck;
default: default:
return true; return true;
} }
} }
} }

View File

@ -23,91 +23,96 @@ import fr.neatmonster.nocheatplus.permissions.Permissions;
import fr.neatmonster.nocheatplus.utilities.StringUtil; import fr.neatmonster.nocheatplus.utilities.StringUtil;
public class CombinedConfig extends ACheckConfig { 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<String, CombinedConfig> worldsMap = new HashMap<String, CombinedConfig>(); /** 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) { @Override
final String worldName = player.getWorld().getName(); public void removeAllConfigs() {
CombinedConfig cc = worldsMap.get(worldName); clear(); // Band-aid.
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 private static final Map<String, CombinedConfig> worldsMap = new HashMap<String, CombinedConfig>();
/** Do mind that this flag is not used by all components. */
public final boolean improbableCheck; public static CombinedConfig getConfig(final Player player) {
public final float improbableLevel; final String worldName = player.getWorld().getName();
public final ActionList improbableActions; CombinedConfig cc = worldsMap.get(worldName);
if (cc == null){
// Invulnerable management. cc = new CombinedConfig(ConfigManager.getConfigFile(worldName));
public final boolean invulnerableCheck; 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 int invulnerableInitialTicksJoin;
public final Set<DamageCause> invulnerableIgnore = new HashSet<DamageCause>(); public final Set<DamageCause> invulnerableIgnore = new HashSet<DamageCause>();
public final Map<DamageCause, Integer> invulnerableModifiers = new HashMap<DamageCause, Integer>(); public final Map<DamageCause, Integer> invulnerableModifiers = new HashMap<DamageCause, Integer>();
public final int invulnerableModifierDefault; public final int invulnerableModifierDefault;
public final boolean invulnerableTriggerAlways; public final boolean invulnerableTriggerAlways;
public final boolean invulnerableTriggerFallDistance; public final boolean invulnerableTriggerFallDistance;
public final boolean munchHausenCheck; public final boolean munchHausenCheck;
public final ActionList munchHausenActions; public final ActionList munchHausenActions;
// Last yaw tracking // Last yaw tracking
public final float yawRate; public final float yawRate;
public final boolean yawRateImprobable; public final boolean yawRateImprobable;
public final float yawRatePenaltyFactor; public final float yawRatePenaltyFactor;
public final int yawRatePenaltyMin; public final int yawRatePenaltyMin;
public final int yawRatePenaltyMax; 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); public CombinedConfig(final ConfigFile config) {
enderPearlPreventClickBlock = config.getBoolean(ConfPaths.COMBINED_ENDERPEARL_PREVENTCLICKBLOCK); super(config, ConfPaths.COMBINED);
improbableCheck = config.getBoolean(ConfPaths.COMBINED_IMPROBABLE_CHECK); bedLeaveCheck = config.getBoolean(ConfPaths.COMBINED_BEDLEAVE_CHECK);
improbableLevel = (float) config.getDouble(ConfPaths.COMBINED_IMPROBABLE_LEVEL); bedLeaveActions = config.getOptimizedActionList(ConfPaths.COMBINED_BEDLEAVE_ACTIONS, Permissions.COMBINED_BEDLEAVE);
improbableActions = config.getOptimizedActionList(ConfPaths.COMBINED_IMPROBABLE_ACTIONS, Permissions.COMBINED_IMPROBABLE);
enderPearlCheck = config.getBoolean(ConfPaths.COMBINED_ENDERPEARL_CHECK);
invulnerableCheck = config.getBoolean(ConfPaths.COMBINED_INVULNERABLE_CHECK); enderPearlPreventClickBlock = config.getBoolean(ConfPaths.COMBINED_ENDERPEARL_PREVENTCLICKBLOCK);
invulnerableInitialTicksJoin = config.getInt(ConfPaths.COMBINED_INVULNERABLE_INITIALTICKS_JOIN);
boolean error = false; improbableCheck = config.getBoolean(ConfPaths.COMBINED_IMPROBABLE_CHECK);
// Read ignored causes. improbableLevel = (float) config.getDouble(ConfPaths.COMBINED_IMPROBABLE_LEVEL);
for (final String input : config.getStringList(ConfPaths.COMBINED_INVULNERABLE_IGNORE)){ improbableActions = config.getOptimizedActionList(ConfPaths.COMBINED_IMPROBABLE_ACTIONS, Permissions.COMBINED_IMPROBABLE);
final String normInput = input.trim().toUpperCase();
try{ invulnerableCheck = config.getBoolean(ConfPaths.COMBINED_INVULNERABLE_CHECK);
invulnerableIgnore.add(DamageCause.valueOf(normInput.replace(' ', '_').replace('-', '_'))); invulnerableInitialTicksJoin = config.getInt(ConfPaths.COMBINED_INVULNERABLE_INITIALTICKS_JOIN);
} boolean error = false;
catch (final Exception e){ // Read ignored causes.
error = true; for (final String input : config.getStringList(ConfPaths.COMBINED_INVULNERABLE_IGNORE)){
StaticLog.logWarning("[NoCheatPlus] Bad damage cause (combined.invulnerable.ignore): " + input); final String normInput = input.trim().toUpperCase();
} try{
} invulnerableIgnore.add(DamageCause.valueOf(normInput.replace(' ', '_').replace('-', '_')));
// Read modifiers for causes. }
Integer defaultMod = 0; catch (final Exception e){
final ConfigurationSection sec = config.getConfigurationSection(ConfPaths.COMBINED_INVULNERABLE_MODIFIERS); 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)){ for (final String input : sec.getKeys(false)){
final int modifier = sec.getInt(input, 0); final int modifier = sec.getInt(input, 0);
final String normInput = input.trim().toUpperCase(); final String normInput = input.trim().toUpperCase();
@ -124,36 +129,36 @@ public class CombinedConfig extends ACheckConfig {
} }
} }
invulnerableModifierDefault = defaultMod; invulnerableModifierDefault = defaultMod;
if (error) StaticLog.logInfo("[NoCheatPlus] Damage causes can be: " + StringUtil.join(Arrays.asList(DamageCause.values()), ", ")); if (error) StaticLog.logInfo("[NoCheatPlus] Damage causes can be: " + StringUtil.join(Arrays.asList(DamageCause.values()), ", "));
invulnerableTriggerAlways = config.getBoolean(ConfPaths.COMBINED_INVULNERABLE_TRIGGERS_ALWAYS); invulnerableTriggerAlways = config.getBoolean(ConfPaths.COMBINED_INVULNERABLE_TRIGGERS_ALWAYS);
invulnerableTriggerFallDistance = config.getBoolean(ConfPaths.COMBINED_INVULNERABLE_TRIGGERS_FALLDISTANCE); 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);
}
@Override munchHausenCheck = config.getBoolean(ConfPaths.COMBINED_MUNCHHAUSEN_CHECK);
public boolean isEnabled(final CheckType checkType) { munchHausenActions = config.getOptimizedActionList(ConfPaths.COMBINED_MUNCHHAUSEN_ACTIONS, Permissions.COMBINED_MUNCHHAUSEN);
switch(checkType){
case COMBINED_IMPROBABLE:
return improbableCheck;
case COMBINED_BEDLEAVE:
return bedLeaveCheck;
case COMBINED_MUNCHHAUSEN:
return munchHausenCheck;
default:
return false;
}
}
public static void clear() { yawRate = config.getInt(ConfPaths.COMBINED_YAWRATE_RATE);
worldsMap.clear(); 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();
}
} }

View File

@ -29,6 +29,11 @@ public class FightConfig extends ACheckConfig {
public final ICheckConfig getConfig(final Player player) { public final ICheckConfig getConfig(final Player player) {
return FightConfig.getConfig(player); return FightConfig.getConfig(player);
} }
@Override
public void removeAllConfigs() {
clear(); // Band-aid.
}
}; };
/** The map containing the configurations per world. */ /** The map containing the configurations per world. */

View File

@ -31,6 +31,11 @@ public class InventoryConfig extends ACheckConfig {
public final ICheckConfig getConfig(final Player player) { public final ICheckConfig getConfig(final Player player) {
return InventoryConfig.getConfig(player); return InventoryConfig.getConfig(player);
} }
@Override
public void removeAllConfigs() {
clear(); // Band-aid.
}
}; };
/** The map containing the configurations per world. */ /** The map containing the configurations per world. */

View File

@ -30,6 +30,11 @@ public class MovingConfig extends ACheckConfig {
public final ICheckConfig getConfig(final Player player) { public final ICheckConfig getConfig(final Player player) {
return MovingConfig.getConfig(player); return MovingConfig.getConfig(player);
} }
@Override
public void removeAllConfigs() {
clear(); // Band-aid.
}
}; };
/** The map containing the configurations per world. */ /** The map containing the configurations per world. */

View File

@ -1,32 +1,44 @@
package fr.neatmonster.nocheatplus.checks.net; 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.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigFile; import fr.neatmonster.nocheatplus.config.ConfigFile;
import fr.neatmonster.nocheatplus.config.ConfigManager; import fr.neatmonster.nocheatplus.config.ConfigManager;
import fr.neatmonster.nocheatplus.permissions.Permissions;
/** /**
* Configuration for the net checks (fast version, sparse). * Configuration for the net checks (fast version, sparse).
* @author web4web1 * @author web4web1
* *
*/ */
public class NetConfig { public class NetConfig extends ACheckConfig {
public final boolean flyingFrequencyActive; public final boolean flyingFrequencyActive;
public final int flyingFrequencySeconds; public final int flyingFrequencySeconds;
public final int flyingFrequencyMaxPackets; public final double flyingFrequencyPPS;
public final boolean flyingFrequencyCancelRedundant; public final ActionList flyingFrequencyActions;
public final boolean flyingFrequencyRedundantActive;
public final int flyingFrequencyRedundantSeconds;
public final ActionList flyingFrequencyRedundantActions;
public final boolean soundDistanceActive; public final boolean soundDistanceActive;
/** Maximum distance for lightning effects (squared). */ /** Maximum distance for lightning effects (squared). */
public final double soundDistanceSq; public final double soundDistanceSq;
public NetConfig(final ConfigFile config) { public NetConfig(final ConfigFile config) {
super(config, ConfPaths.NET);
final ConfigFile globalConfig = ConfigManager.getConfigFile(); final ConfigFile globalConfig = ConfigManager.getConfigFile();
flyingFrequencyActive = config.getBoolean(ConfPaths.NET_FLYINGFREQUENCY_ACTIVE); flyingFrequencyActive = config.getBoolean(ConfPaths.NET_FLYINGFREQUENCY_ACTIVE);
flyingFrequencySeconds = Math.max(1, globalConfig.getInt(ConfPaths.NET_FLYINGFREQUENCY_SECONDS)); flyingFrequencySeconds = Math.max(1, globalConfig.getInt(ConfPaths.NET_FLYINGFREQUENCY_SECONDS));
flyingFrequencyMaxPackets = Math.max(1, globalConfig.getInt(ConfPaths.NET_FLYINGFREQUENCY_MAXPACKETS)); flyingFrequencyPPS = Math.max(1.0, globalConfig.getDouble(ConfPaths.NET_FLYINGFREQUENCY_PACKETSPERSECOND));
flyingFrequencyCancelRedundant = config.getBoolean(ConfPaths.NET_FLYINGFREQUENCY_CANCELREDUNDANT); 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); soundDistanceActive = config.getBoolean(ConfPaths.NET_SOUNDDISTANCE_ACTIVE);
double dist = config.getDouble(ConfPaths.NET_SOUNDDISTANCE_MAXDISTANCE); 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;
}
}
} }

View File

@ -1,5 +1,8 @@
package fr.neatmonster.nocheatplus.checks.net; 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.ConfigFile;
import fr.neatmonster.nocheatplus.config.WorldConfigCache; import fr.neatmonster.nocheatplus.config.WorldConfigCache;
@ -8,7 +11,7 @@ import fr.neatmonster.nocheatplus.config.WorldConfigCache;
* @author web4web1 * @author web4web1
* *
*/ */
public class NetConfigCache extends WorldConfigCache<NetConfig> { public class NetConfigCache extends WorldConfigCache<NetConfig> implements CheckConfigFactory {
public NetConfigCache() { public NetConfigCache() {
super(true); super(true);
@ -19,4 +22,14 @@ public class NetConfigCache extends WorldConfigCache<NetConfig> {
return new NetConfig(configFile); return new NetConfig(configFile);
} }
@Override
public NetConfig getConfig(final Player player) {
return getConfig(player.getWorld());
}
@Override
public void removeAllConfigs() {
clearAllConfigs();
}
} }

View File

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

View File

@ -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<String, NetData> dataMap = new HashMap<String, NetData>();
@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);
}
}

View File

@ -595,19 +595,23 @@ public abstract class ConfPaths {
public static final String MOVING_TRACE_SIZE = MOVING_TRACE + "size"; public static final String MOVING_TRACE_SIZE = MOVING_TRACE + "size";
public static final String MOVING_TRACE_MERGEDIST = MOVING_TRACE + "mergedist"; 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."; private static final String NET_SOUNDDISTANCE = NET + "sounddistance.";
public static final String NET_SOUNDDISTANCE_ACTIVE = NET_SOUNDDISTANCE + "active"; public static final String NET_SOUNDDISTANCE_ACTIVE = NET_SOUNDDISTANCE + "active";
public static final String NET_SOUNDDISTANCE_MAXDISTANCE = NET_SOUNDDISTANCE + "maxdistance"; public static final String NET_SOUNDDISTANCE_MAXDISTANCE = NET_SOUNDDISTANCE + "maxdistance";
private static final String NET_FLYINGFREQUENCY = NET + "flyingfrequency."; private static final String NET_FLYINGFREQUENCY = NET + "flyingfrequency.";
public static final String NET_FLYINGFREQUENCY_ACTIVE = NET_FLYINGFREQUENCY + "active"; public static final String NET_FLYINGFREQUENCY_ACTIVE = NET_FLYINGFREQUENCY + "active";
@GlobalConfig @GlobalConfig
public static final String NET_FLYINGFREQUENCY_SECONDS = NET_FLYINGFREQUENCY + "seconds"; public static final String NET_FLYINGFREQUENCY_SECONDS = NET_FLYINGFREQUENCY + "seconds";
@GlobalConfig @GlobalConfig
public static final String NET_FLYINGFREQUENCY_MAXPACKETS = NET_FLYINGFREQUENCY + "maxpackets"; public static final String NET_FLYINGFREQUENCY_PACKETSPERSECOND = NET_FLYINGFREQUENCY + "packetspersecond";
public static final String NET_FLYINGFREQUENCY_CANCELREDUNDANT = NET_FLYINGFREQUENCY + "cancelredundant"; 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"; public static final String STRINGS = "strings";
@ -650,6 +654,8 @@ public abstract class ConfPaths {
public static final String INVENTORY_ENSURECLOSE = "checks.inventory.ensureclose"; public static final String INVENTORY_ENSURECLOSE = "checks.inventory.ensureclose";
@Moved(newPath = LOGGING_EXTENDED_STATUS) @Moved(newPath = LOGGING_EXTENDED_STATUS)
public static final String LOGGING_DEBUG = "logging.debug"; 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 @Deprecated
public static final String MISCELLANEOUS_REPORTTOMETRICS = "miscellaneous.reporttometrics"; public static final String MISCELLANEOUS_REPORTTOMETRICS = "miscellaneous.reporttometrics";
@Deprecated @Deprecated
@ -666,5 +672,7 @@ public abstract class ConfPaths {
public static final String FIGHT_KNOCKBACK_INTERVAL = "checks.fight.knockback.interval"; public static final String FIGHT_KNOCKBACK_INTERVAL = "checks.fight.knockback.interval";
@Deprecated @Deprecated
public static final String FIGHT_KNOCKBACK_ACTIONS = "checks.fight.knockback.actions"; public static final String FIGHT_KNOCKBACK_ACTIONS = "checks.fight.knockback.actions";
@Deprecated
public static final String NET_FLYINGFREQUENCY_MAXPACKETS = "checks.net.flyingfrequency.maxpackets";
} }

View File

@ -434,8 +434,11 @@ public class DefaultConfig extends ConfigFile {
// FlyingFrequency // FlyingFrequency
set(ConfPaths.NET_FLYINGFREQUENCY_ACTIVE, true); set(ConfPaths.NET_FLYINGFREQUENCY_ACTIVE, true);
set(ConfPaths.NET_FLYINGFREQUENCY_SECONDS, 5); set(ConfPaths.NET_FLYINGFREQUENCY_SECONDS, 5);
set(ConfPaths.NET_FLYINGFREQUENCY_MAXPACKETS, 300); set(ConfPaths.NET_FLYINGFREQUENCY_PACKETSPERSECOND, 60);
set(ConfPaths.NET_FLYINGFREQUENCY_CANCELREDUNDANT, true); 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 // SoundDistance
set(ConfPaths.NET_SOUNDDISTANCE_ACTIVE, true); set(ConfPaths.NET_SOUNDDISTANCE_ACTIVE, true);

View File

@ -114,6 +114,9 @@ public class Permissions {
public static final String INVENTORY_ITEMS = INVENTORY + ".items"; public static final String INVENTORY_ITEMS = INVENTORY + ".items";
public static final String INVENTORY_OPEN = INVENTORY + ".open"; 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 = CHECKS + ".moving";
public static final String MOVING_CREATIVEFLY = MOVING + ".creativefly"; public static final String MOVING_CREATIVEFLY = MOVING + ".creativefly";
public static final String MOVING_MOREPACKETS = MOVING + ".morepackets"; public static final String MOVING_MOREPACKETS = MOVING + ".morepackets";
@ -166,5 +169,5 @@ public class Permissions {
private static final String JOURNEY = MODS + ".journey"; private static final String JOURNEY = MODS + ".journey";
public static final String JOURNEY_RADAR = JOURNEY + ".radar"; public static final String JOURNEY_RADAR = JOURNEY + ".radar";
public static final String JOURNEY_CAVE = JOURNEY + ".cavemap"; public static final String JOURNEY_CAVE = JOURNEY + ".cavemap";
} }

View File

@ -28,15 +28,7 @@ import fr.neatmonster.nocheatplus.checks.access.CheckConfigFactory;
import fr.neatmonster.nocheatplus.checks.access.CheckDataFactory; import fr.neatmonster.nocheatplus.checks.access.CheckDataFactory;
import fr.neatmonster.nocheatplus.checks.access.ICheckConfig; import fr.neatmonster.nocheatplus.checks.access.ICheckConfig;
import fr.neatmonster.nocheatplus.checks.access.ICheckData; 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.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.compat.BridgeMisc;
import fr.neatmonster.nocheatplus.components.ComponentRegistry; import fr.neatmonster.nocheatplus.components.ComponentRegistry;
import fr.neatmonster.nocheatplus.components.ComponentWithName; import fr.neatmonster.nocheatplus.components.ComponentWithName;
@ -406,19 +398,20 @@ public class DataManager implements Listener, INotifyReload, INeedConfig, Compon
} }
/** /**
* Clear all stored (check) config instances.<br> * Clear all cached CheckConfig instances.<br>
* This does not cleanup ConfigManager, i.e. stored yml-versions. * This does not cleanup ConfigManager, i.e. stored yml-versions.
*/ */
public static void clearConfigs() { public static void clearConfigs() {
// The dirty bit ! final Set<CheckConfigFactory> factories = new LinkedHashSet<CheckConfigFactory>();
BlockBreakConfig.clear(); for (final CheckType checkType : CheckType.values()) {
BlockInteractConfig.clear(); final CheckConfigFactory factory = checkType.getConfigFactory();
BlockPlaceConfig.clear(); if (factory != null) {
ChatConfig.clear(); factories.add(factory);
CombinedConfig.clear(); }
FightConfig.clear(); }
InventoryConfig.clear(); for (final CheckConfigFactory factory : factories) {
MovingConfig.clear(); factory.removeAllConfigs();
}
} }
/** /**

View File

@ -169,7 +169,7 @@ permissions:
nocheatplus.checks.moving.nofall: nocheatplus.checks.moving.nofall:
description: Allow the player to bypass the NoFall check. description: Allow the player to bypass the NoFall check.
nocheatplus.checks.moving.passable: nocheatplus.checks.moving.passable:
description: Allow bypassing the passable check. description: Allow bypassing the Passable check.
nocheatplus.checks.moving.survivalfly: nocheatplus.checks.moving.survivalfly:
description: Allow the player to bypass the SurvivalFly check. description: Allow the player to bypass the SurvivalFly check.
children: children:
@ -183,6 +183,11 @@ permissions:
description: Allow the player to sprint backwards. description: Allow the player to sprint backwards.
nocheatplus.checks.moving.survivalfly.step: nocheatplus.checks.moving.survivalfly.step:
description: Allow the player to use the 'step' functionality of his client. 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: nocheatplus.mods:
description: Allow the player to use all the client mods. description: Allow the player to use all the client mods.