mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-07 16:28:13 +01:00
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.
This commit is contained in:
parent
7cdfeb663a
commit
866f4fde6c
@ -286,7 +286,8 @@ public class NoCheatPlus extends JavaPlugin implements Listener {
|
|||||||
} catch (final Exception e) {}
|
} catch (final Exception e) {}
|
||||||
|
|
||||||
// Debug information about unknown blocks.
|
// 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.
|
// Tell the server administrator that we finished loading NoCheatPlus now.
|
||||||
System.out.println("[NoCheatPlus] Version " + getDescription().getVersion() + " is enabled.");
|
System.out.println("[NoCheatPlus] Version " + getDescription().getVersion() + " is enabled.");
|
||||||
|
@ -43,6 +43,7 @@ public enum CheckType {
|
|||||||
BLOCKBREAK(BlockBreakConfig.factory, BlockBreakData.factory),
|
BLOCKBREAK(BlockBreakConfig.factory, BlockBreakData.factory),
|
||||||
BLOCKBREAK_DIRECTION(BLOCKBREAK, Permissions.BLOCKBREAK_DIRECTION),
|
BLOCKBREAK_DIRECTION(BLOCKBREAK, Permissions.BLOCKBREAK_DIRECTION),
|
||||||
BLOCKBREAK_FASTBREAK(BLOCKBREAK, Permissions.BLOCKBREAK_FASTBREAK),
|
BLOCKBREAK_FASTBREAK(BLOCKBREAK, Permissions.BLOCKBREAK_FASTBREAK),
|
||||||
|
BLOCKBREAK_FREQUENCY(BLOCKBREAK, Permissions.BLOCKBREAK_FREQUENCY),
|
||||||
BLOCKBREAK_NOSWING(BLOCKBREAK, Permissions.BLOCKBREAK_NOSWING),
|
BLOCKBREAK_NOSWING(BLOCKBREAK, Permissions.BLOCKBREAK_NOSWING),
|
||||||
BLOCKBREAK_REACH(BLOCKBREAK, Permissions.BLOCKBREAK_REACH),
|
BLOCKBREAK_REACH(BLOCKBREAK, Permissions.BLOCKBREAK_REACH),
|
||||||
BLOCKBREAK_WRONGBLOCK(BLOCKBREAK, Permissions.BLOCKBREAK_WRONGBLOCK),
|
BLOCKBREAK_WRONGBLOCK(BLOCKBREAK, Permissions.BLOCKBREAK_WRONGBLOCK),
|
||||||
|
@ -79,13 +79,21 @@ public class BlockBreakConfig extends ACheckConfig {
|
|||||||
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 int fastBreakBuffer;
|
public final long fastBreakBucketContention;
|
||||||
public final long fastBreakContention;
|
|
||||||
public final long fastBreakDelay;
|
public final long fastBreakDelay;
|
||||||
public final int fastBreakInterval;
|
public final int fastBreakModSurvival;
|
||||||
public final boolean fastBreakOldCheck;
|
public final int fastBreakModCreative;
|
||||||
public final ActionList fastBreakActions;
|
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 boolean improbableFastBreakCheck;
|
||||||
|
|
||||||
public final boolean noSwingCheck;
|
public final boolean noSwingCheck;
|
||||||
@ -107,18 +115,28 @@ public class BlockBreakConfig extends ACheckConfig {
|
|||||||
directionCheck = data.getBoolean(ConfPaths.BLOCKBREAK_DIRECTION_CHECK);
|
directionCheck = data.getBoolean(ConfPaths.BLOCKBREAK_DIRECTION_CHECK);
|
||||||
directionActions = data.getActionList(ConfPaths.BLOCKBREAK_DIRECTION_ACTIONS, Permissions.BLOCKBREAK_DIRECTION);
|
directionActions = data.getActionList(ConfPaths.BLOCKBREAK_DIRECTION_ACTIONS, Permissions.BLOCKBREAK_DIRECTION);
|
||||||
|
|
||||||
|
// Fastbreak.
|
||||||
fastBreakCheck = data.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_CHECK);
|
fastBreakCheck = data.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_CHECK);
|
||||||
fastBreakDebug = data.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_DEBUG, false); // hidden
|
// Hidden settings of new check.
|
||||||
fastBreakContention = data.getLong(ConfPaths.BLOCKBREAK_FASTBREAK_BUCKETS_CONTENTION, 2000);
|
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);
|
fastBreakBucketDur = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_BUCKETS_DUR, 4000);
|
||||||
fastBreakBucketFactor = (float) data.getDouble(ConfPaths.BLOCKBREAK_FASTBREAK_BUCKETS_FACTOR, 0.99);
|
fastBreakBucketFactor = (float) data.getDouble(ConfPaths.BLOCKBREAK_FASTBREAK_BUCKETS_FACTOR, 0.99);
|
||||||
fastBreakBuckets = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_BUCKETS_N, 30);
|
fastBreakBuckets = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_BUCKETS_N, 30);
|
||||||
fastBreakBuffer = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_BUFFER);
|
fastBreakModCreative = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_MOD_CREATIVE, 0);
|
||||||
fastBreakDelay = data.getLong(ConfPaths.BLOCKBREAK_FASTBREAK_DELAY, 50);
|
fastBreakModSurvival = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_MOD_SURVIVAL);
|
||||||
fastBreakInterval = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_INTERVAL);
|
// Fastbreak actions, shared.
|
||||||
fastBreakOldCheck = data.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_OLDCHECK);
|
|
||||||
fastBreakActions = data.getActionList(ConfPaths.BLOCKBREAK_FASTBREAK_ACTIONS, Permissions.BLOCKBREAK_FASTBREAK);
|
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);
|
improbableFastBreakCheck = data.getBoolean(ConfPaths.COMBINED_IMPROBABLE_FASTBREAK_CHECK);
|
||||||
|
|
||||||
noSwingCheck = data.getBoolean(ConfPaths.BLOCKBREAK_NOSWING_CHECK);
|
noSwingCheck = data.getBoolean(ConfPaths.BLOCKBREAK_NOSWING_CHECK);
|
||||||
@ -141,6 +159,8 @@ public class BlockBreakConfig extends ACheckConfig {
|
|||||||
return directionCheck;
|
return directionCheck;
|
||||||
case BLOCKBREAK_FASTBREAK:
|
case BLOCKBREAK_FASTBREAK:
|
||||||
return fastBreakCheck;
|
return fastBreakCheck;
|
||||||
|
case BLOCKBREAK_FREQUENCY:
|
||||||
|
return frequencyCheck;
|
||||||
case BLOCKBREAK_NOSWING:
|
case BLOCKBREAK_NOSWING:
|
||||||
return noSwingCheck;
|
return noSwingCheck;
|
||||||
case BLOCKBREAK_REACH:
|
case BLOCKBREAK_REACH:
|
||||||
|
@ -69,6 +69,7 @@ public class BlockBreakData extends ACheckData {
|
|||||||
// Violation levels.
|
// Violation levels.
|
||||||
public double directionVL;
|
public double directionVL;
|
||||||
public double fastBreakVL;
|
public double fastBreakVL;
|
||||||
|
public double frequencyVL;
|
||||||
public double noSwingVL;
|
public double noSwingVL;
|
||||||
public double reachVL;
|
public double reachVL;
|
||||||
public final ActionFrequency wrongBlockVL;
|
public final ActionFrequency wrongBlockVL;
|
||||||
@ -84,9 +85,11 @@ public class BlockBreakData extends ACheckData {
|
|||||||
public final ActionFrequency fastBreakPenalties;
|
public final ActionFrequency fastBreakPenalties;
|
||||||
public int fastBreakBuffer;
|
public int fastBreakBuffer;
|
||||||
public long fastBreakBreakTime = System.currentTimeMillis() - 1000L;
|
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 long fastBreakDamageTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
public final ActionFrequency frequencyBuckets;
|
||||||
|
|
||||||
// Data of the no swing check.
|
// Data of the no swing check.
|
||||||
public boolean noSwingArmSwung = true;
|
public boolean noSwingArmSwung = true;
|
||||||
|
|
||||||
@ -94,11 +97,11 @@ public class BlockBreakData extends ACheckData {
|
|||||||
public double reachDistance;
|
public double reachDistance;
|
||||||
|
|
||||||
|
|
||||||
public BlockBreakData(BlockBreakConfig cc) {
|
public BlockBreakData(final BlockBreakConfig cc) {
|
||||||
fastBreakBuffer = cc.fastBreakBuffer;
|
|
||||||
fastBreakPenalties = new ActionFrequency(cc.fastBreakBuckets, cc.fastBreakBucketDur);
|
|
||||||
wrongBlockVL = new ActionFrequency(6, 20000);
|
|
||||||
stats = cc.fastBreakDebug?(new Stats("NCP/FASTBREAK")):null;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,9 +37,12 @@ public class BlockBreakListener implements Listener {
|
|||||||
/** The direction check. */
|
/** The direction check. */
|
||||||
private final Direction direction = new Direction();
|
private final Direction direction = new Direction();
|
||||||
|
|
||||||
/** The fast break check. */
|
/** The fast break check (per block breaking speed). */
|
||||||
private final FastBreak fastBreak = new FastBreak();
|
private final FastBreak fastBreak = new FastBreak();
|
||||||
|
|
||||||
|
/** The frequency check (number of blocks broken) */
|
||||||
|
private final Frequency frequency = new Frequency();
|
||||||
|
|
||||||
/** The no swing check. */
|
/** The no swing check. */
|
||||||
private final NoSwing noSwing = new NoSwing();
|
private final NoSwing noSwing = new NoSwing();
|
||||||
|
|
||||||
@ -77,8 +80,12 @@ public class BlockBreakListener implements Listener {
|
|||||||
if (wrongBlock.isEnabled(player) && wrongBlock.check(player, block))
|
if (wrongBlock.isEnabled(player) && wrongBlock.check(player, block))
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
|
|
||||||
// Has the player broken blocks too quickly?
|
// Has the player broken more blocks per second than allowed?
|
||||||
if (fastBreak.isEnabled(player) && fastBreak.check(player, block))
|
if (!cancelled && frequency.isEnabled(player) && frequency.check(player))
|
||||||
|
cancelled = true;
|
||||||
|
|
||||||
|
// Has the player broken blocks faster than possible?
|
||||||
|
if (!cancelled && fastBreak.isEnabled(player) && fastBreak.check(player, block))
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
|
|
||||||
// Did the arm of the player move before breaking this block?
|
// Did the arm of the player move before breaking this block?
|
||||||
@ -129,7 +136,7 @@ public class BlockBreakListener implements Listener {
|
|||||||
* the event
|
* the event
|
||||||
*/
|
*/
|
||||||
@EventHandler(
|
@EventHandler(
|
||||||
ignoreCancelled = true, priority = EventPriority.MONITOR)
|
ignoreCancelled = false, priority = EventPriority.MONITOR)
|
||||||
public void onPlayerInteract(final PlayerInteractEvent event) {
|
public void onPlayerInteract(final PlayerInteractEvent event) {
|
||||||
/*
|
/*
|
||||||
* ____ _ ___ _ _
|
* ____ _ ___ _ _
|
||||||
@ -140,17 +147,28 @@ public class BlockBreakListener implements Listener {
|
|||||||
* |___/
|
* |___/
|
||||||
*/
|
*/
|
||||||
final Player player = event.getPlayer();
|
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.
|
// 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.
|
// Do not care about null blocks.
|
||||||
final Block block = event.getClickedBlock();
|
final Block block = event.getClickedBlock();
|
||||||
if (block == null)
|
if (block == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
final BlockBreakData data = BlockBreakData.getData(player);
|
if (data.clickedX == block.getX() && data.clickedZ == block.getZ() && data.clickedY == block.getY()) return;
|
||||||
if (!cc.fastBreakOldCheck && data.clickedX == block.getX() && data.clickedZ == block.getZ() && data.clickedY == block.getY()) return;
|
|
||||||
// Only record first damage:
|
// Only record first damage:
|
||||||
data.fastBreakDamageTime = System.currentTimeMillis();
|
data.fastBreakDamageTime = System.currentTimeMillis();
|
||||||
// Also set last clicked blocks position.
|
// Also set last clicked blocks position.
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.blockbreak;
|
package fr.neatmonster.nocheatplus.checks.blockbreak;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -21,16 +20,10 @@ import fr.neatmonster.nocheatplus.utilities.BlockUtils;
|
|||||||
* MMMMMMMMMMMM M#########M
|
* 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 {
|
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.
|
* Instantiates a new fast break check.
|
||||||
*/
|
*/
|
||||||
@ -55,41 +48,10 @@ public class FastBreak extends Check {
|
|||||||
|
|
||||||
boolean cancel = false;
|
boolean cancel = false;
|
||||||
|
|
||||||
if (cc.fastBreakOldCheck){
|
|
||||||
// First, check the game mode of the player and choose the right limit.
|
// First, check the game mode of the player and choose the right limit.
|
||||||
long elapsedTimeLimit = Math.round(cc.fastBreakInterval / 100D * SURVIVAL);
|
long breakingTime = Math.round((double) cc.fastBreakModSurvival / 100D * (double) BlockUtils.getBreakingDuration(block.getTypeId(), player));
|
||||||
if (player.getGameMode() == GameMode.CREATIVE)
|
if (player.getGameMode() == GameMode.CREATIVE)
|
||||||
elapsedTimeLimit = Math.round(cc.fastBreakInterval / 100D * CREATIVE);
|
breakingTime = Math.round((double) cc.fastBreakModCreative / 100D * (double) 95);
|
||||||
// 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 (!).
|
// fastBreakDamageTime is now first interact on block (!).
|
||||||
final long elapsedTime = now - data.fastBreakDamageTime;
|
final long elapsedTime = now - data.fastBreakDamageTime;
|
||||||
@ -106,7 +68,7 @@ public class FastBreak extends Check {
|
|||||||
data.fastBreakPenalties.add(now, (float) missingTime);
|
data.fastBreakPenalties.add(now, (float) missingTime);
|
||||||
|
|
||||||
// Only raise a violation, if the total penalty score exceeds the contention duration (for lag, delay).
|
// Only raise a violation, if the total penalty score exceeds the contention duration (for lag, delay).
|
||||||
if (data.fastBreakPenalties.getScore(cc.fastBreakBucketFactor) > cc.fastBreakContention){
|
if (data.fastBreakPenalties.getScore(cc.fastBreakBucketFactor) > cc.fastBreakBucketContention){
|
||||||
// TODO: maybe add one absolute penalty time for big amounts to stop breaking until then
|
// TODO: maybe add one absolute penalty time for big amounts to stop breaking until then
|
||||||
data.fastBreakVL += missingTime;
|
data.fastBreakVL += missingTime;
|
||||||
cancel = executeActions(player, data.fastBreakVL, missingTime, cc.fastBreakActions);
|
cancel = executeActions(player, data.fastBreakVL, missingTime, cc.fastBreakActions);
|
||||||
@ -125,7 +87,7 @@ public class FastBreak extends Check {
|
|||||||
player.sendMessage(data.stats.getStatsStr(true));
|
player.sendMessage(data.stats.getStatsStr(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remember the block breaking time.
|
// Remember the block breaking time.
|
||||||
data.fastBreakBreakTime = now;
|
data.fastBreakBreakTime = now;
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -13,6 +13,14 @@ public class WrongBlock extends Check {
|
|||||||
super(CheckType.BLOCKBREAK_WRONGBLOCK);
|
super(CheckType.BLOCKBREAK_WRONGBLOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the player destroys another block than interacted with last.<br>
|
||||||
|
* 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){
|
public boolean check(final Player player, final Block block){
|
||||||
final BlockBreakConfig cc = BlockBreakConfig.getConfig(player);
|
final BlockBreakConfig cc = BlockBreakConfig.getConfig(player);
|
||||||
final BlockBreakData data = BlockBreakData.getData(player);
|
final BlockBreakData data = BlockBreakData.getData(player);
|
||||||
|
@ -19,7 +19,7 @@ import fr.neatmonster.nocheatplus.utilities.LagMeasureTask;
|
|||||||
* dP
|
* 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 {
|
public class Speed extends Check {
|
||||||
|
|
||||||
|
@ -66,20 +66,28 @@ public abstract class ConfPaths {
|
|||||||
public static final String BLOCKBREAK_DIRECTION_ACTIONS = BLOCKBREAK_DIRECTION + "actions";
|
public static final String BLOCKBREAK_DIRECTION_ACTIONS = BLOCKBREAK_DIRECTION + "actions";
|
||||||
|
|
||||||
private static final String BLOCKBREAK_FASTBREAK = BLOCKBREAK + "fastbreak.";
|
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_CHECK = BLOCKBREAK_FASTBREAK + "active";
|
||||||
|
public static final String BLOCKBREAK_FASTBREAK_DEBUG = BLOCKBREAK_FASTBREAK + "debug";
|
||||||
private static final String BLOCKBREAK_FASTBREAK_BUCKETS = BLOCKBREAK + "buckets.";
|
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_CONTENTION = BLOCKBREAK_FASTBREAK_BUCKETS + "contention";
|
||||||
public static final String BLOCKBREAK_FASTBREAK_BUCKETS_N = BLOCKBREAK_FASTBREAK_BUCKETS + "number";
|
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_DUR = BLOCKBREAK_FASTBREAK_BUCKETS + "duration";
|
||||||
public static final String BLOCKBREAK_FASTBREAK_BUCKETS_FACTOR = BLOCKBREAK_FASTBREAK_BUCKETS + "factor";
|
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_DELAY = BLOCKBREAK_FASTBREAK + "delay";
|
||||||
public static final String BLOCKBREAK_FASTBREAK_INTERVAL = BLOCKBREAK_FASTBREAK + "interval";
|
public static final String BLOCKBREAK_FASTBREAK_MOD_CREATIVE = BLOCKBREAK_FASTBREAK + "intervalcreative";
|
||||||
public static final String BLOCKBREAK_FASTBREAK_OLDCHECK = BLOCKBREAK_FASTBREAK + "oldcheck";
|
public static final String BLOCKBREAK_FASTBREAK_MOD_SURVIVAL = BLOCKBREAK_FASTBREAK + "intervalsurvival";
|
||||||
public static final String BLOCKBREAK_FASTBREAK_ACTIONS = BLOCKBREAK_FASTBREAK + "actions";
|
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.";
|
private static final String BLOCKBREAK_NOSWING = BLOCKBREAK + "noswing.";
|
||||||
public static final String BLOCKBREAK_NOSWING_CHECK = BLOCKBREAK_NOSWING + "active";
|
public static final String BLOCKBREAK_NOSWING_CHECK = BLOCKBREAK_NOSWING + "active";
|
||||||
public static final String BLOCKBREAK_NOSWING_ACTIONS = BLOCKBREAK_NOSWING + "actions";
|
public static final String BLOCKBREAK_NOSWING_ACTIONS = BLOCKBREAK_NOSWING + "actions";
|
||||||
|
@ -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_DIRECTION_ACTIONS, "cancel vl>10 log:bdirection:0:5:if cancel");
|
||||||
|
|
||||||
set(ConfPaths.BLOCKBREAK_FASTBREAK_CHECK, true);
|
set(ConfPaths.BLOCKBREAK_FASTBREAK_CHECK, true);
|
||||||
set(ConfPaths.BLOCKBREAK_FASTBREAK_BUFFER, 2);
|
set(ConfPaths.BLOCKBREAK_FASTBREAK_DELAY, 50);
|
||||||
set(ConfPaths.BLOCKBREAK_FASTBREAK_INTERVAL, 100);
|
set(ConfPaths.BLOCKBREAK_FASTBREAK_MOD_SURVIVAL, 100);
|
||||||
set(ConfPaths.BLOCKBREAK_FASTBREAK_OLDCHECK, false);
|
set(ConfPaths.BLOCKBREAK_FASTBREAK_ACTIONS, "cancel vl>500 log:fastbreak:3:5:cif cancel");
|
||||||
set(ConfPaths.BLOCKBREAK_FASTBREAK_ACTIONS, "cancel vl>100 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_CHECK, true);
|
||||||
set(ConfPaths.BLOCKBREAK_NOSWING_ACTIONS, "log:noswing:3:2:if cancel");
|
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 + ".angle", start + "tried to hit multiple entities at the same time" + end);
|
||||||
set(ConfPaths.STRINGS + ".ban", "ban [player]");
|
set(ConfPaths.STRINGS + ".ban", "ban [player]");
|
||||||
set(ConfPaths.STRINGS + ".ban-ip", "ban-ip [ip]");
|
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 + ".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 + ".bpspeed", start + "tried to throw projectiles too quickly" + end);
|
||||||
set(ConfPaths.STRINGS + ".breach", start
|
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 + ".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 + ".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 + ".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 + ".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 + ".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);
|
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 + ".kick", "kick [player]");
|
||||||
set(ConfPaths.STRINGS + ".kicknopwnage", "ncp kick [player] You're not allowed to spam this server!");
|
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 + ".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 + ".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 + ".kickselfhit", "ncp kick [player] That must be exhausting!");
|
||||||
set(ConfPaths.STRINGS + ".kickwb", "ncp kick [player] Wrong block!");
|
set(ConfPaths.STRINGS + ".kickwb", "ncp kick [player] Wrong block!");
|
||||||
|
@ -37,10 +37,13 @@ public class Permissions {
|
|||||||
// Debug permission, for player spam (not in plugin.yml, currently).
|
// Debug permission, for player spam (not in plugin.yml, currently).
|
||||||
public static final String ADMINISTRATION_DEBUG = ADMINISTRATION + ".debug";
|
public static final String ADMINISTRATION_DEBUG = ADMINISTRATION + ".debug";
|
||||||
|
|
||||||
|
|
||||||
// Bypasses held extra from command permissions.
|
// Bypasses held extra from command permissions.
|
||||||
private final static String BYPASS = NOCHEATPLUS + ".bypass";
|
private final static String BYPASS = NOCHEATPLUS + ".bypass";
|
||||||
public static final String BYPASS_DENY_LOGIN = BYPASS + "denylogin";
|
public static final String BYPASS_DENY_LOGIN = BYPASS + "denylogin";
|
||||||
|
|
||||||
|
|
||||||
|
// Permissions for the individual checks.
|
||||||
private static final String CHECKS = NOCHEATPLUS + ".checks";
|
private static final String CHECKS = NOCHEATPLUS + ".checks";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -53,6 +56,7 @@ public class Permissions {
|
|||||||
private static final String BLOCKBREAK = CHECKS + ".blockbreak";
|
private static final String BLOCKBREAK = CHECKS + ".blockbreak";
|
||||||
public static final String BLOCKBREAK_DIRECTION = BLOCKBREAK + ".direction";
|
public static final String BLOCKBREAK_DIRECTION = BLOCKBREAK + ".direction";
|
||||||
public static final String BLOCKBREAK_FASTBREAK = BLOCKBREAK + ".fastbreak";
|
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_NOSWING = BLOCKBREAK + ".noswing";
|
||||||
public static final String BLOCKBREAK_REACH = BLOCKBREAK + ".reach";
|
public static final String BLOCKBREAK_REACH = BLOCKBREAK + ".reach";
|
||||||
public static final String BLOCKBREAK_WRONGBLOCK = BLOCKBREAK + ".wrongblock";
|
public static final String BLOCKBREAK_WRONGBLOCK = BLOCKBREAK + ".wrongblock";
|
||||||
|
Loading…
Reference in New Issue
Block a user