Keep track of moving event count. Re-introduce morepackets-set-back-age.
Configurable, default to 40 moving events for now. Later to be adjusted ~ e.g. with force-fall set-back policy.
This commit is contained in:
parent
90d6ab97c5
commit
442634793c
|
@ -146,6 +146,8 @@ public class BlockInteractData extends ACheckData {
|
|||
* @param action
|
||||
*/
|
||||
public void setLastBlock(final Block block, final Action action) {
|
||||
lastTick = TickTask.getTick();
|
||||
lastAction = action;
|
||||
lastX = block.getX();
|
||||
lastY = block.getY();
|
||||
lastZ = block.getZ();
|
||||
|
@ -153,8 +155,6 @@ public class BlockInteractData extends ACheckData {
|
|||
if (lastType == Material.AIR) {
|
||||
lastType = null;
|
||||
}
|
||||
lastTick = TickTask.getTick();
|
||||
lastAction = action;
|
||||
resetPassedChecks();
|
||||
resetConsumedChecks();
|
||||
}
|
||||
|
@ -190,14 +190,17 @@ public class BlockInteractData extends ACheckData {
|
|||
|
||||
/**
|
||||
* Full state comparison.
|
||||
*
|
||||
* @param material
|
||||
* null is treated as Material.AIR.
|
||||
* @param action
|
||||
* @param tick
|
||||
* @param block
|
||||
* @return
|
||||
*/
|
||||
public boolean matchesLastBlock(final Material material, final Action action, final int tick, final Block block) {
|
||||
return lastX != Integer.MAX_VALUE && material == lastType && matchesLastBlock(action, tick, block);
|
||||
return lastX != Integer.MAX_VALUE && (material == lastType || material == null && lastType == Material.AIR)
|
||||
&& matchesLastBlock(action, tick, block);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -234,7 +237,6 @@ public class BlockInteractData extends ACheckData {
|
|||
return lastX != Integer.MAX_VALUE && tick == lastTick && matchesLastBlock(block);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compare the block coordinates.
|
||||
*
|
||||
|
|
|
@ -124,6 +124,7 @@ public class MovingConfig extends ACheckConfig {
|
|||
public final float morePacketsBurstPackets;
|
||||
public final double morePacketsBurstDirect;
|
||||
public final double morePacketsBurstEPM;
|
||||
public final int morePacketsSetBackAge;
|
||||
public final ActionList morePacketsActions;
|
||||
|
||||
public final boolean noFallCheck;
|
||||
|
@ -268,6 +269,7 @@ public class MovingConfig extends ACheckConfig {
|
|||
morePacketsBurstPackets = config.getInt(ConfPaths.MOVING_MOREPACKETS_BURST_EPM);
|
||||
morePacketsBurstDirect = config.getInt(ConfPaths.MOVING_MOREPACKETS_BURST_DIRECT);
|
||||
morePacketsBurstEPM = config.getInt(ConfPaths.MOVING_MOREPACKETS_BURST_EPM);
|
||||
morePacketsSetBackAge = config.getInt(ConfPaths.MOVING_MOREPACKETS_SETBACKAGE);
|
||||
morePacketsActions = config.getOptimizedActionList(ConfPaths.MOVING_MOREPACKETS_ACTIONS, Permissions.MOVING_MOREPACKETS);
|
||||
|
||||
noFallCheck = config.getBoolean(ConfPaths.MOVING_NOFALL_CHECK);
|
||||
|
|
|
@ -187,7 +187,7 @@ public class MovingData extends ACheckData implements IRemoveSubCheckData {
|
|||
public float flySpeed = 0.0f;
|
||||
|
||||
/** Count set back (re-) setting. */
|
||||
private int setBackResetCount = 0;
|
||||
private int playerMoveCount = 0;
|
||||
/**
|
||||
* setBackResetCount (incremented) at the time of (re-) setting the ordinary
|
||||
* set back.
|
||||
|
@ -704,7 +704,7 @@ public class MovingData extends ACheckData implements IRemoveSubCheckData {
|
|||
LocUtil.set(setBack, loc);
|
||||
}
|
||||
// TODO: Consider adjusting the set back-y here. Problem: Need to take into account for bounding box (collect max-ground-height needed).
|
||||
setBackResetTime = ++setBackResetCount;
|
||||
setBackResetTime = playerMoveCount;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -718,7 +718,7 @@ public class MovingData extends ACheckData implements IRemoveSubCheckData {
|
|||
else{
|
||||
LocUtil.set(setBack, loc);
|
||||
}
|
||||
setBackResetTime = ++setBackResetCount;
|
||||
setBackResetTime = playerMoveCount;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -857,7 +857,7 @@ public class MovingData extends ACheckData implements IRemoveSubCheckData {
|
|||
else {
|
||||
LocUtil.set(morePacketsSetback, loc);
|
||||
}
|
||||
morePacketsSetBackResetTime = ++setBackResetCount;
|
||||
morePacketsSetBackResetTime = playerMoveCount;
|
||||
}
|
||||
|
||||
public final void setMorePacketsSetBack(final Location loc) {
|
||||
|
@ -867,7 +867,7 @@ public class MovingData extends ACheckData implements IRemoveSubCheckData {
|
|||
else {
|
||||
LocUtil.set(morePacketsSetback, loc);
|
||||
}
|
||||
morePacketsSetBackResetTime = ++setBackResetCount;
|
||||
morePacketsSetBackResetTime = playerMoveCount;
|
||||
}
|
||||
|
||||
public Location getMorePacketsSetBack() {
|
||||
|
@ -1351,4 +1351,33 @@ public class MovingData extends ACheckData implements IRemoveSubCheckData {
|
|||
return verVel;
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of move events received.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getPlayerMoveCount() {
|
||||
return playerMoveCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called with player move events.
|
||||
*/
|
||||
public void increasePlayerMoveCount() {
|
||||
playerMoveCount++;
|
||||
if (playerMoveCount == Integer.MAX_VALUE) {
|
||||
playerMoveCount = 0;
|
||||
morePacketsSetBackResetTime = 0;
|
||||
setBackResetTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Age in move events.
|
||||
* @return
|
||||
*/
|
||||
public int getMorePacketsSetBackAge() {
|
||||
return playerMoveCount - morePacketsSetBackResetTime;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -333,6 +333,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
|||
|
||||
final MovingConfig cc = MovingConfig.getConfig(player);
|
||||
final MovingData data = MovingData.getData(player);
|
||||
data.increasePlayerMoveCount();
|
||||
|
||||
/*
|
||||
* TODO: Check if teleportation is set, verify if scheduled (tick task).
|
||||
|
|
|
@ -103,10 +103,13 @@ public class MorePackets extends Check {
|
|||
return data.hasMorePacketsSetBack() ? data.getMorePacketsSetBack() : data.getSetBack(to);
|
||||
}
|
||||
}
|
||||
else if (allowSetSetBack) {
|
||||
else if (allowSetSetBack && data.getMorePacketsSetBackAge() > cc.morePacketsSetBackAge) {
|
||||
// Update the set back location. (CHANGED to only update, if not a violation.)
|
||||
// (Might update whenever newTo == null)
|
||||
data.setMorePacketsSetBack(from);
|
||||
if (data.debug) {
|
||||
debug(player, "Update set back (morepackets) to from.");
|
||||
}
|
||||
}
|
||||
|
||||
// No set back.
|
||||
|
|
|
@ -587,6 +587,7 @@ public abstract class ConfPaths {
|
|||
public static final String MOVING_MOREPACKETS_BURST_PACKETS = MOVING_MOREPACKETS_BURST + "packets";
|
||||
public static final String MOVING_MOREPACKETS_BURST_DIRECT = MOVING_MOREPACKETS_BURST + "directviolation";
|
||||
public static final String MOVING_MOREPACKETS_BURST_EPM = MOVING_MOREPACKETS_BURST + "epmviolation";
|
||||
public static final String MOVING_MOREPACKETS_SETBACKAGE = MOVING_MOREPACKETS + "setbackage";
|
||||
public static final String MOVING_MOREPACKETS_ACTIONS = MOVING_MOREPACKETS + "actions";
|
||||
|
||||
private static final String MOVING_NOFALL = MOVING + "nofall.";
|
||||
|
|
|
@ -408,6 +408,7 @@ public class DefaultConfig extends ConfigFile {
|
|||
set(ConfPaths.MOVING_MOREPACKETS_BURST_PACKETS, 40, 785);
|
||||
set(ConfPaths.MOVING_MOREPACKETS_BURST_DIRECT, 60, 785);
|
||||
set(ConfPaths.MOVING_MOREPACKETS_BURST_EPM, 180, 785);
|
||||
set(ConfPaths.MOVING_MOREPACKETS_SETBACKAGE, 40, 1091);
|
||||
set(ConfPaths.MOVING_MOREPACKETS_ACTIONS, "cancel vl>10 log:morepackets:0:2:if cancel vl>100 log:morepackets:0:2:if cancel cmd:kickpackets", 785);
|
||||
|
||||
set(ConfPaths.MOVING_NOFALL_CHECK, true, 785);
|
||||
|
|
Loading…
Reference in New Issue