From 866f4fde6c5bc524490a08111bd974c67a4568f0 Mon Sep 17 00:00:00 2001 From: asofold Date: Wed, 12 Sep 2012 08:01:32 +0200 Subject: [PATCH] Clean up fastbreak: Add check for frequency of block breaking to leave the survival block breaking duration to the fastbreak check. Adaptions to the configuration. Fix creative / speed. --- .../neatmonster/nocheatplus/NoCheatPlus.java | 3 +- .../nocheatplus/checks/CheckType.java | 1 + .../checks/blockbreak/BlockBreakConfig.java | 42 +++++-- .../checks/blockbreak/BlockBreakData.java | 13 +- .../checks/blockbreak/BlockBreakListener.java | 34 +++-- .../checks/blockbreak/FastBreak.java | 118 ++++++------------ .../checks/blockbreak/Frequency.java | 42 +++++++ .../checks/blockbreak/WrongBlock.java | 8 ++ .../nocheatplus/checks/fight/Speed.java | 2 +- .../nocheatplus/config/ConfPaths.java | 18 ++- .../nocheatplus/config/DefaultConfig.java | 16 ++- .../nocheatplus/players/Permissions.java | 4 + 12 files changed, 187 insertions(+), 114 deletions(-) create mode 100644 src/fr/neatmonster/nocheatplus/checks/blockbreak/Frequency.java diff --git a/src/fr/neatmonster/nocheatplus/NoCheatPlus.java b/src/fr/neatmonster/nocheatplus/NoCheatPlus.java index 2c24abdf..4aeff2fa 100644 --- a/src/fr/neatmonster/nocheatplus/NoCheatPlus.java +++ b/src/fr/neatmonster/nocheatplus/NoCheatPlus.java @@ -286,7 +286,8 @@ public class NoCheatPlus extends JavaPlugin implements Listener { } catch (final Exception e) {} // Debug information about unknown blocks. - if (!config.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_OLDCHECK)) BlockUtils.dumpBlocks(config.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_DEBUG, false)); // false); + // (Probably removed later.) + BlockUtils.dumpBlocks(config.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_DEBUG, false)); // Tell the server administrator that we finished loading NoCheatPlus now. System.out.println("[NoCheatPlus] Version " + getDescription().getVersion() + " is enabled."); diff --git a/src/fr/neatmonster/nocheatplus/checks/CheckType.java b/src/fr/neatmonster/nocheatplus/checks/CheckType.java index 03950674..33629bee 100644 --- a/src/fr/neatmonster/nocheatplus/checks/CheckType.java +++ b/src/fr/neatmonster/nocheatplus/checks/CheckType.java @@ -43,6 +43,7 @@ public enum CheckType { BLOCKBREAK(BlockBreakConfig.factory, BlockBreakData.factory), BLOCKBREAK_DIRECTION(BLOCKBREAK, Permissions.BLOCKBREAK_DIRECTION), BLOCKBREAK_FASTBREAK(BLOCKBREAK, Permissions.BLOCKBREAK_FASTBREAK), + BLOCKBREAK_FREQUENCY(BLOCKBREAK, Permissions.BLOCKBREAK_FREQUENCY), BLOCKBREAK_NOSWING(BLOCKBREAK, Permissions.BLOCKBREAK_NOSWING), BLOCKBREAK_REACH(BLOCKBREAK, Permissions.BLOCKBREAK_REACH), BLOCKBREAK_WRONGBLOCK(BLOCKBREAK, Permissions.BLOCKBREAK_WRONGBLOCK), diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakConfig.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakConfig.java index 348018ea..47785f08 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakConfig.java @@ -79,13 +79,21 @@ public class BlockBreakConfig extends ACheckConfig { public final int fastBreakBuckets; public final long fastBreakBucketDur; public final float fastBreakBucketFactor; - public final int fastBreakBuffer; - public final long fastBreakContention; - public final long fastBreakDelay; - public final int fastBreakInterval; - public final boolean fastBreakOldCheck; + public final long fastBreakBucketContention; + public final long fastBreakDelay; + public final int fastBreakModSurvival; + public final int fastBreakModCreative; 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 ActionList frequencyActions; + public boolean improbableFastBreakCheck; public final boolean noSwingCheck; @@ -107,18 +115,28 @@ public class BlockBreakConfig extends ACheckConfig { directionCheck = data.getBoolean(ConfPaths.BLOCKBREAK_DIRECTION_CHECK); directionActions = data.getActionList(ConfPaths.BLOCKBREAK_DIRECTION_ACTIONS, Permissions.BLOCKBREAK_DIRECTION); + // Fastbreak. fastBreakCheck = data.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_CHECK); - fastBreakDebug = data.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_DEBUG, false); // hidden - fastBreakContention = data.getLong(ConfPaths.BLOCKBREAK_FASTBREAK_BUCKETS_CONTENTION, 2000); + // Hidden settings of new check. + fastBreakDebug = data.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_DEBUG, false); + fastBreakDelay = data.getLong(ConfPaths.BLOCKBREAK_FASTBREAK_DELAY); + fastBreakBucketContention = data.getLong(ConfPaths.BLOCKBREAK_FASTBREAK_BUCKETS_CONTENTION, 2000); fastBreakBucketDur = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_BUCKETS_DUR, 4000); fastBreakBucketFactor = (float) data.getDouble(ConfPaths.BLOCKBREAK_FASTBREAK_BUCKETS_FACTOR, 0.99); fastBreakBuckets = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_BUCKETS_N, 30); - fastBreakBuffer = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_BUFFER); - fastBreakDelay = data.getLong(ConfPaths.BLOCKBREAK_FASTBREAK_DELAY, 50); - fastBreakInterval = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_INTERVAL); - fastBreakOldCheck = data.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_OLDCHECK); + fastBreakModCreative = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_MOD_CREATIVE, 0); + fastBreakModSurvival = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_MOD_SURVIVAL); + // Fastbreak actions, shared. fastBreakActions = data.getActionList(ConfPaths.BLOCKBREAK_FASTBREAK_ACTIONS, Permissions.BLOCKBREAK_FASTBREAK); + frequencyCheck = data.getBoolean(ConfPaths.BLOCKBREAK_FREQUENCY_CHECK); + frequencyBuckets = data.getInt(ConfPaths.BLOCKBREAK_FREQUENCY_BUCKETS_N, 2); + frequencyBucketDur = data.getLong(ConfPaths.BLOCKBREAK_FREQUENCY_BUCKETS_DUR, 1000); + frequencyBucketFactor = (float) data.getDouble(ConfPaths.BLOCKBREAK_FREQUENCY_BUCKETS_FACTOR, 1f); + frequencyIntervalCreative = data.getInt(ConfPaths.BLOCKBREAK_FREQUENCY_MOD_CREATIVE); + frequencyIntervalSurvival = data.getInt(ConfPaths.BLOCKBREAK_FREQUENCY_MOD_SURVIVAL); + frequencyActions = data.getActionList(ConfPaths.BLOCKBREAK_FREQUENCY_ACTIONS, Permissions.BLOCKBREAK_FREQUENCY); + improbableFastBreakCheck = data.getBoolean(ConfPaths.COMBINED_IMPROBABLE_FASTBREAK_CHECK); noSwingCheck = data.getBoolean(ConfPaths.BLOCKBREAK_NOSWING_CHECK); @@ -141,6 +159,8 @@ public class BlockBreakConfig extends ACheckConfig { return directionCheck; case BLOCKBREAK_FASTBREAK: return fastBreakCheck; + case BLOCKBREAK_FREQUENCY: + return frequencyCheck; case BLOCKBREAK_NOSWING: return noSwingCheck; case BLOCKBREAK_REACH: diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakData.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakData.java index cd14cd6b..5f1179d6 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakData.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakData.java @@ -69,6 +69,7 @@ public class BlockBreakData extends ACheckData { // Violation levels. public double directionVL; public double fastBreakVL; + public double frequencyVL; public double noSwingVL; public double reachVL; public final ActionFrequency wrongBlockVL; @@ -84,8 +85,10 @@ public class BlockBreakData extends ACheckData { public final ActionFrequency fastBreakPenalties; public int fastBreakBuffer; public long fastBreakBreakTime = System.currentTimeMillis() - 1000L; - /** Old check sets this to the last interact time, new check sets to first interact time */ + /** Old check sets this to the last interact time, new check sets to first interact time for one block. */ public long fastBreakDamageTime = System.currentTimeMillis(); + + public final ActionFrequency frequencyBuckets; // Data of the no swing check. public boolean noSwingArmSwung = true; @@ -94,11 +97,11 @@ public class BlockBreakData extends ACheckData { public double reachDistance; - public BlockBreakData(BlockBreakConfig cc) { - fastBreakBuffer = cc.fastBreakBuffer; - fastBreakPenalties = new ActionFrequency(cc.fastBreakBuckets, cc.fastBreakBucketDur); - wrongBlockVL = new ActionFrequency(6, 20000); + public BlockBreakData(final BlockBreakConfig cc) { stats = cc.fastBreakDebug?(new Stats("NCP/FASTBREAK")):null; + fastBreakPenalties = cc.fastBreakCheck ? new ActionFrequency(cc.fastBreakBuckets, cc.fastBreakBucketDur) : null; + frequencyBuckets = cc.frequencyCheck ? new ActionFrequency(cc.frequencyBuckets, cc.frequencyBucketDur) : null; + wrongBlockVL = cc.wrongBlockCheck ? new ActionFrequency(6, 20000) : null; } } diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakListener.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakListener.java index b42e5e43..198d57d8 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakListener.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakListener.java @@ -37,8 +37,11 @@ public class BlockBreakListener implements Listener { /** The direction check. */ private final Direction direction = new Direction(); - /** The fast break check. */ + /** The fast break check (per block breaking speed). */ private final FastBreak fastBreak = new FastBreak(); + + /** The frequency check (number of blocks broken) */ + private final Frequency frequency = new Frequency(); /** The no swing check. */ private final NoSwing noSwing = new NoSwing(); @@ -76,9 +79,13 @@ public class BlockBreakListener implements Listener { // Has the player broken a block that was not damaged before? if (wrongBlock.isEnabled(player) && wrongBlock.check(player, block)) cancelled = true; + + // Has the player broken more blocks per second than allowed? + if (!cancelled && frequency.isEnabled(player) && frequency.check(player)) + cancelled = true; - // Has the player broken blocks too quickly? - if (fastBreak.isEnabled(player) && fastBreak.check(player, block)) + // Has the player broken blocks faster than possible? + if (!cancelled && fastBreak.isEnabled(player) && fastBreak.check(player, block)) cancelled = true; // Did the arm of the player move before breaking this block? @@ -129,7 +136,7 @@ public class BlockBreakListener implements Listener { * the event */ @EventHandler( - ignoreCancelled = true, priority = EventPriority.MONITOR) + ignoreCancelled = false, priority = EventPriority.MONITOR) public void onPlayerInteract(final PlayerInteractEvent event) { /* * ____ _ ___ _ _ @@ -140,17 +147,28 @@ public class BlockBreakListener implements Listener { * |___/ */ final Player player = event.getPlayer(); - final BlockBreakConfig cc = BlockBreakConfig.getConfig(player); + + // The following is to set the "first damage time" for a block. + // Return if it is not left clicking a block. - if (!cc.fastBreakOldCheck && event.getAction() != Action.LEFT_CLICK_BLOCK) return; + // (Allows right click to be ignored.) + if (event.getAction() != Action.LEFT_CLICK_BLOCK) return; + + final BlockBreakData data = BlockBreakData.getData(player); + + if (event.isCancelled()){ + // Reset the time, to avoid certain kinds of cheating. + data.fastBreakDamageTime = System.currentTimeMillis(); + data.clickedX = Integer.MAX_VALUE; // Should be enough to reset that one. + return; + } // Do not care about null blocks. final Block block = event.getClickedBlock(); if (block == null) return; - final BlockBreakData data = BlockBreakData.getData(player); - if (!cc.fastBreakOldCheck && data.clickedX == block.getX() && data.clickedZ == block.getZ() && data.clickedY == block.getY()) return; + if (data.clickedX == block.getX() && data.clickedZ == block.getZ() && data.clickedY == block.getY()) return; // Only record first damage: data.fastBreakDamageTime = System.currentTimeMillis(); // Also set last clicked blocks position. diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java index c3bf03d1..dc308e9a 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java @@ -1,7 +1,6 @@ package fr.neatmonster.nocheatplus.checks.blockbreak; import org.bukkit.GameMode; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -21,16 +20,10 @@ import fr.neatmonster.nocheatplus.utilities.BlockUtils; * MMMMMMMMMMMM M#########M */ /** - * A check used to verify if the player isn't breaking his blocks too quickly. + * A check used to verify if the player isn't breaking blocks faster than possible. */ public class FastBreak extends Check { - /** The minimum time that needs to be elapsed between two block breaks for a player in creative mode. */ - private static final long CREATIVE = 95L; - - /** The minimum time that needs to be elapsed between two block breaks for a player in survival mode. */ - private static final long SURVIVAL = 45L; - /** * Instantiates a new fast break check. */ @@ -55,77 +48,46 @@ public class FastBreak extends Check { boolean cancel = false; - if (cc.fastBreakOldCheck){ - // First, check the game mode of the player and choose the right limit. - long elapsedTimeLimit = Math.round(cc.fastBreakInterval / 100D * SURVIVAL); - if (player.getGameMode() == GameMode.CREATIVE) - elapsedTimeLimit = Math.round(cc.fastBreakInterval / 100D * CREATIVE); - // The elapsed time is the difference between the last damage time and the last break time. - final long elapsedTime = data.fastBreakDamageTime - data.fastBreakBreakTime; - if (elapsedTime < elapsedTimeLimit && data.fastBreakBreakTime > 0L && data.fastBreakDamageTime > 0L - && (player.getItemInHand().getType() != Material.SHEARS || block.getType() != Material.LEAVES)) { - // If the buffer has been consumed. - if (data.fastBreakBuffer <= 0) { - // Increment the violation level (but using the original limit). - data.fastBreakVL += elapsedTimeLimit - elapsedTime; - - // Cancel the event if needed. - cancel = executeActions(player, data.fastBreakVL, elapsedTimeLimit - elapsedTime, cc.fastBreakActions); - } else - // Remove one from the buffer. - data.fastBreakBuffer--; - } else { - // If the buffer isn't full. - if (data.fastBreakBuffer < cc.fastBreakBuffer) - // Add one to the buffer. - data.fastBreakBuffer++; - - // Reduce the violation level, the player was nice with blocks. - data.fastBreakVL *= 0.9D; - - } - } - else{ - // First, check the game mode of the player and choose the right limit. - long breakingTime = Math.round((double) cc.fastBreakInterval / 100D * (double) BlockUtils.getBreakingDuration(block.getTypeId(), player)); - if (player.getGameMode() == GameMode.CREATIVE) - breakingTime = Math.round((double) cc.fastBreakInterval / 100D * (double) CREATIVE); - - // fastBreakDamageTime is now first interact on block (!). - final long elapsedTime = now - data.fastBreakDamageTime; - - // Check if the time used time is lower than expected. - if (elapsedTime + cc.fastBreakDelay < breakingTime){ - // lag or cheat or Minecraft. - - final long missingTime = breakingTime - elapsedTime; - - - - // Add as penalty - data.fastBreakPenalties.add(now, (float) missingTime); - - // Only raise a violation, if the total penalty score exceeds the contention duration (for lag, delay). - if (data.fastBreakPenalties.getScore(cc.fastBreakBucketFactor) > cc.fastBreakContention){ - // TODO: maybe add one absolute penalty time for big amounts to stop breaking until then - data.fastBreakVL += missingTime; - cancel = executeActions(player, data.fastBreakVL, missingTime, cc.fastBreakActions); - } - // else: still within contention limits. - + // First, check the game mode of the player and choose the right limit. + long breakingTime = Math.round((double) cc.fastBreakModSurvival / 100D * (double) BlockUtils.getBreakingDuration(block.getTypeId(), player)); + if (player.getGameMode() == GameMode.CREATIVE) + breakingTime = Math.round((double) cc.fastBreakModCreative / 100D * (double) 95); + + // fastBreakDamageTime is now first interact on block (!). + final long elapsedTime = now - data.fastBreakDamageTime; + + // Check if the time used time is lower than expected. + if (elapsedTime + cc.fastBreakDelay < breakingTime){ + // lag or cheat or Minecraft. + + final long missingTime = breakingTime - elapsedTime; + + + + // Add as penalty + data.fastBreakPenalties.add(now, (float) missingTime); + + // Only raise a violation, if the total penalty score exceeds the contention duration (for lag, delay). + if (data.fastBreakPenalties.getScore(cc.fastBreakBucketFactor) > cc.fastBreakBucketContention){ + // TODO: maybe add one absolute penalty time for big amounts to stop breaking until then + data.fastBreakVL += missingTime; + cancel = executeActions(player, data.fastBreakVL, missingTime, cc.fastBreakActions); + } + // else: still within contention limits. + // System.out.println("violation : " + missingTime); - } - else{ - data.fastBreakVL *= 0.9D; - } - - if (cc.fastBreakDebug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){ - data.stats.addStats(data.stats.getId(Integer.toString(block.getTypeId())+"u", true), elapsedTime); - data.stats.addStats(data.stats.getId(Integer.toString(block.getTypeId())+ "r", true), breakingTime); - player.sendMessage(data.stats.getStatsStr(true)); - } - - } + } + else{ + data.fastBreakVL *= 0.9D; + } + + if (cc.fastBreakDebug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){ + data.stats.addStats(data.stats.getId(Integer.toString(block.getTypeId())+"u", true), elapsedTime); + data.stats.addStats(data.stats.getId(Integer.toString(block.getTypeId())+ "r", true), breakingTime); + player.sendMessage(data.stats.getStatsStr(true)); + } + + // Remember the block breaking time. data.fastBreakBreakTime = now; diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/Frequency.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/Frequency.java new file mode 100644 index 00000000..4d285f5b --- /dev/null +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/Frequency.java @@ -0,0 +1,42 @@ +package fr.neatmonster.nocheatplus.checks.blockbreak; + +import org.bukkit.GameMode; +import org.bukkit.entity.Player; + +import fr.neatmonster.nocheatplus.checks.Check; +import fr.neatmonster.nocheatplus.checks.CheckType; + +/** + * This checks just limits the number of blocks broken per time frame. + * @author mc_dev + * + */ +public class Frequency extends Check { + + public Frequency() { + super(CheckType.BLOCKBREAK_FREQUENCY); + } + + public boolean check(final Player player){ + final BlockBreakConfig cc = BlockBreakConfig.getConfig(player); + final BlockBreakData data = BlockBreakData.getData(player); + + final float interval = (float) ((player.getGameMode() == GameMode.CREATIVE)?(cc.frequencyIntervalCreative):(cc.frequencyIntervalSurvival)); + data.frequencyBuckets.add(System.currentTimeMillis(), interval); + + final float score = data.frequencyBuckets.getScore(cc.frequencyBucketFactor); + final float allowed = cc.frequencyBuckets * cc.frequencyBucketDur; + + boolean cancel = false; + if (score > allowed){ + final double change = (score - allowed) / 1000; + data.frequencyVL += change; + cancel = executeActions(player, data.frequencyVL, change, cc.frequencyActions); + } + else if (data.frequencyVL > 0d && score < allowed * .75) + data.frequencyVL *= 0.95; + + return cancel; + } + +} diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/WrongBlock.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/WrongBlock.java index d21e09f6..548cc843 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockbreak/WrongBlock.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/WrongBlock.java @@ -13,6 +13,14 @@ public class WrongBlock extends Check { super(CheckType.BLOCKBREAK_WRONGBLOCK); } + /** + * Check if the player destroys another block than interacted with last.
+ * This does occasionally trigger for players that destroy grass or snow, + * probably due to packet delaying issues for insta breaking. very effective against some nuker techniques. + * @param player + * @param block + * @return + */ public boolean check(final Player player, final Block block){ final BlockBreakConfig cc = BlockBreakConfig.getConfig(player); final BlockBreakData data = BlockBreakData.getData(player); diff --git a/src/fr/neatmonster/nocheatplus/checks/fight/Speed.java b/src/fr/neatmonster/nocheatplus/checks/fight/Speed.java index cd8dcc9a..4e615099 100644 --- a/src/fr/neatmonster/nocheatplus/checks/fight/Speed.java +++ b/src/fr/neatmonster/nocheatplus/checks/fight/Speed.java @@ -19,7 +19,7 @@ import fr.neatmonster.nocheatplus.utilities.LagMeasureTask; * dP */ /** - * The Speed check is used to detect players who are attacking entities too quickly. + * The Frequency check is used to detect players who are attacking entities too quickly. */ public class Speed extends Check { diff --git a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java index 2bb8b91a..e73d7525 100644 --- a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java +++ b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java @@ -66,19 +66,27 @@ public abstract class ConfPaths { public static final String BLOCKBREAK_DIRECTION_ACTIONS = BLOCKBREAK_DIRECTION + "actions"; private static final String BLOCKBREAK_FASTBREAK = BLOCKBREAK + "fastbreak."; - public static final String BLOCKBREAK_FASTBREAK_DEBUG = BLOCKBREAK_FASTBREAK + "debug"; public static final String BLOCKBREAK_FASTBREAK_CHECK = BLOCKBREAK_FASTBREAK + "active"; + public static final String BLOCKBREAK_FASTBREAK_DEBUG = BLOCKBREAK_FASTBREAK + "debug"; private static final String BLOCKBREAK_FASTBREAK_BUCKETS = BLOCKBREAK + "buckets."; public static final String BLOCKBREAK_FASTBREAK_BUCKETS_CONTENTION = BLOCKBREAK_FASTBREAK_BUCKETS + "contention"; public static final String BLOCKBREAK_FASTBREAK_BUCKETS_N = BLOCKBREAK_FASTBREAK_BUCKETS + "number"; public static final String BLOCKBREAK_FASTBREAK_BUCKETS_DUR = BLOCKBREAK_FASTBREAK_BUCKETS + "duration"; public static final String BLOCKBREAK_FASTBREAK_BUCKETS_FACTOR = BLOCKBREAK_FASTBREAK_BUCKETS + "factor"; - - public static final String BLOCKBREAK_FASTBREAK_BUFFER = BLOCKBREAK_FASTBREAK + "buffer"; public static final String BLOCKBREAK_FASTBREAK_DELAY = BLOCKBREAK_FASTBREAK + "delay"; - public static final String BLOCKBREAK_FASTBREAK_INTERVAL = BLOCKBREAK_FASTBREAK + "interval"; - public static final String BLOCKBREAK_FASTBREAK_OLDCHECK = BLOCKBREAK_FASTBREAK + "oldcheck"; + public static final String BLOCKBREAK_FASTBREAK_MOD_CREATIVE = BLOCKBREAK_FASTBREAK + "intervalcreative"; + public static final String BLOCKBREAK_FASTBREAK_MOD_SURVIVAL = BLOCKBREAK_FASTBREAK + "intervalsurvival"; public static final String BLOCKBREAK_FASTBREAK_ACTIONS = BLOCKBREAK_FASTBREAK + "actions"; + + private static final String BLOCKBREAK_FREQUENCY = BLOCKBREAK + "frequency."; + public static final String BLOCKBREAK_FREQUENCY_CHECK = BLOCKBREAK_FREQUENCY + "active"; + public static final String BLOCKBREAK_FREQUENCY_MOD_CREATIVE = BLOCKBREAK_FREQUENCY + "intervalcreative"; + public static final String BLOCKBREAK_FREQUENCY_MOD_SURVIVAL = BLOCKBREAK_FREQUENCY + "intervalsurvival"; + private static final String BLOCKBREAK_FREQUENCY_BUCKETS = BLOCKBREAK_FREQUENCY + "buckets."; + public static final String BLOCKBREAK_FREQUENCY_BUCKETS_DUR = BLOCKBREAK_FREQUENCY_BUCKETS + "duration"; + public static final String BLOCKBREAK_FREQUENCY_BUCKETS_FACTOR = BLOCKBREAK_FREQUENCY_BUCKETS + "factor"; + public static final String BLOCKBREAK_FREQUENCY_BUCKETS_N = BLOCKBREAK_FREQUENCY_BUCKETS + "number"; + public static final String BLOCKBREAK_FREQUENCY_ACTIONS = BLOCKBREAK_FREQUENCY + "actions"; private static final String BLOCKBREAK_NOSWING = BLOCKBREAK + "noswing."; public static final String BLOCKBREAK_NOSWING_CHECK = BLOCKBREAK_NOSWING + "active"; diff --git a/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java b/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java index 93081f97..26bf17ae 100644 --- a/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java +++ b/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java @@ -69,10 +69,14 @@ public class DefaultConfig extends ConfigFile { set(ConfPaths.BLOCKBREAK_DIRECTION_ACTIONS, "cancel vl>10 log:bdirection:0:5:if cancel"); set(ConfPaths.BLOCKBREAK_FASTBREAK_CHECK, true); - set(ConfPaths.BLOCKBREAK_FASTBREAK_BUFFER, 2); - set(ConfPaths.BLOCKBREAK_FASTBREAK_INTERVAL, 100); - set(ConfPaths.BLOCKBREAK_FASTBREAK_OLDCHECK, false); - set(ConfPaths.BLOCKBREAK_FASTBREAK_ACTIONS, "cancel vl>100 log:fastbreak:3:5:cif cancel"); + set(ConfPaths.BLOCKBREAK_FASTBREAK_DELAY, 50); + set(ConfPaths.BLOCKBREAK_FASTBREAK_MOD_SURVIVAL, 100); + set(ConfPaths.BLOCKBREAK_FASTBREAK_ACTIONS, "cancel vl>500 log:fastbreak:3:5:cif cancel"); + + set(ConfPaths.BLOCKBREAK_FREQUENCY_CHECK, true); + set(ConfPaths.BLOCKBREAK_FREQUENCY_MOD_CREATIVE, 100); + set(ConfPaths.BLOCKBREAK_FREQUENCY_MOD_SURVIVAL, 50); + set(ConfPaths.BLOCKBREAK_FREQUENCY_ACTIONS, "cancel vl>5 log:bbfrequency:3:5:cif cancel vl>60 log:bbfrequency:0:5:cif cancel cmd:kickfrequency"); set(ConfPaths.BLOCKBREAK_NOSWING_CHECK, true); set(ConfPaths.BLOCKBREAK_NOSWING_ACTIONS, "log:noswing:3:2:if cancel"); @@ -340,6 +344,7 @@ public class DefaultConfig extends ConfigFile { set(ConfPaths.STRINGS + ".angle", start + "tried to hit multiple entities at the same time" + end); set(ConfPaths.STRINGS + ".ban", "ban [player]"); set(ConfPaths.STRINGS + ".ban-ip", "ban-ip [ip]"); + set(ConfPaths.STRINGS + ".bbfrequency", start + "tried to break too many blocks within time frame" + end); set(ConfPaths.STRINGS + ".bdirection", start + "tried to interact with a block out of his line of sight" + end); set(ConfPaths.STRINGS + ".bpspeed", start + "tried to throw projectiles too quickly" + end); set(ConfPaths.STRINGS + ".breach", start @@ -350,7 +355,7 @@ public class DefaultConfig extends ConfigFile { set(ConfPaths.STRINGS + ".combspeed", start + "performs different actions at very high speed" + end); set(ConfPaths.STRINGS + ".critical", start + "tried to do a critical hit but wasn't technically jumping" + end); set(ConfPaths.STRINGS + ".drop", start + "tried to drop more items than allowed" + end); - set(ConfPaths.STRINGS + ".fastbreak", start + "tried to break too many blocks" + end); + set(ConfPaths.STRINGS + ".fastbreak", start + "tried to break blocks faster than possible" + end); set(ConfPaths.STRINGS + ".fastclick", start + "tried to move items in his inventory too quickly" + end); set(ConfPaths.STRINGS + ".fastplace", start + "tried to place too many blocks" + end); set(ConfPaths.STRINGS + ".fdirection", start + "tried to hit an entity out of line of sight" + end); @@ -369,6 +374,7 @@ public class DefaultConfig extends ConfigFile { set(ConfPaths.STRINGS + ".kick", "kick [player]"); set(ConfPaths.STRINGS + ".kicknopwnage", "ncp kick [player] You're not allowed to spam this server!"); set(ConfPaths.STRINGS + ".kickcaptcha", "ncp kick [player] Enter the captcha!"); + set(ConfPaths.STRINGS + ".kickfrequency", "ncp kick [player] How about doing that less often?"); set(ConfPaths.STRINGS + ".kickglchat", "ncp kick [player] Too many chat messages, take a break."); set(ConfPaths.STRINGS + ".kickselfhit", "ncp kick [player] That must be exhausting!"); set(ConfPaths.STRINGS + ".kickwb", "ncp kick [player] Wrong block!"); diff --git a/src/fr/neatmonster/nocheatplus/players/Permissions.java b/src/fr/neatmonster/nocheatplus/players/Permissions.java index 880e2fee..70d4595c 100644 --- a/src/fr/neatmonster/nocheatplus/players/Permissions.java +++ b/src/fr/neatmonster/nocheatplus/players/Permissions.java @@ -37,10 +37,13 @@ public class Permissions { // Debug permission, for player spam (not in plugin.yml, currently). public static final String ADMINISTRATION_DEBUG = ADMINISTRATION + ".debug"; + // Bypasses held extra from command permissions. private final static String BYPASS = NOCHEATPLUS + ".bypass"; public static final String BYPASS_DENY_LOGIN = BYPASS + "denylogin"; + + // Permissions for the individual checks. private static final String CHECKS = NOCHEATPLUS + ".checks"; /* @@ -53,6 +56,7 @@ public class Permissions { private static final String BLOCKBREAK = CHECKS + ".blockbreak"; public static final String BLOCKBREAK_DIRECTION = BLOCKBREAK + ".direction"; public static final String BLOCKBREAK_FASTBREAK = BLOCKBREAK + ".fastbreak"; + public static final String BLOCKBREAK_FREQUENCY = BLOCKBREAK + ".frequency"; public static final String BLOCKBREAK_NOSWING = BLOCKBREAK + ".noswing"; public static final String BLOCKBREAK_REACH = BLOCKBREAK + ".reach"; public static final String BLOCKBREAK_WRONGBLOCK = BLOCKBREAK + ".wrongblock";