mirror of
https://github.com/essentials/Essentials.git
synced 2025-09-25 05:41:36 +02:00
Finish up the speed check.
This commit is contained in:
@@ -22,11 +22,13 @@ public class BlockPlaceConfig implements ConfigItem
|
||||
public final long directionPenaltyTime;
|
||||
public final double directionPrecision;
|
||||
public final boolean speedCheck;
|
||||
public final int speedTime;
|
||||
public final ActionList speedActions;
|
||||
|
||||
public BlockPlaceConfig(NoCheatConfiguration data)
|
||||
{
|
||||
speedCheck = data.getBoolean(ConfPaths.BLOCKPLACE_SPEED_CHECK);
|
||||
speedTime = data.getInt(ConfPaths.BLOCKPLACE_SPEED_TIME);
|
||||
speedActions = data.getActionList(ConfPaths.BLOCKPLACE_SPEED_ACTIONS, Permissions.BLOCKPLACE_SPEED);
|
||||
|
||||
reachCheck = data.getBoolean(ConfPaths.BLOCKPLACE_REACH_CHECK);
|
||||
|
@@ -10,11 +10,13 @@ import com.earth2me.essentials.anticheat.data.SimpleLocation;
|
||||
*/
|
||||
public class BlockPlaceData implements DataItem
|
||||
{
|
||||
// Keep track of violation levels for the two checks
|
||||
// Keep track of violation levels for the three checks
|
||||
public double reachVL = 0.0D;
|
||||
public double directionVL = 0.0D;
|
||||
public double speedVL = 0.0D;
|
||||
// Used for the penalty time feature of the direction check
|
||||
public long directionLastViolationTime = 0;
|
||||
public long lastPlace = 0;
|
||||
// Have a nicer/simpler way to work with block locations instead of
|
||||
// Bukkits own "Location" class
|
||||
public final SimpleLocation blockPlacedAgainst = new SimpleLocation();
|
||||
|
@@ -2,6 +2,9 @@ package com.earth2me.essentials.anticheat.checks.blockplace;
|
||||
|
||||
import com.earth2me.essentials.anticheat.NoCheat;
|
||||
import com.earth2me.essentials.anticheat.NoCheatPlayer;
|
||||
import com.earth2me.essentials.anticheat.actions.ParameterName;
|
||||
import com.earth2me.essentials.anticheat.data.Statistics.Id;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
public class SpeedCheck extends BlockPlaceCheck
|
||||
@@ -13,6 +16,39 @@ public class SpeedCheck extends BlockPlaceCheck
|
||||
|
||||
public boolean check(NoCheatPlayer player, BlockPlaceData data, BlockPlaceConfig cc)
|
||||
{
|
||||
return false;
|
||||
boolean cancel = false;
|
||||
|
||||
if (data.lastPlace != 0 && System.currentTimeMillis() - data.lastPlace < cc.speedTime)
|
||||
{
|
||||
// He failed, increase vl and statistics
|
||||
data.speedVL += cc.speedTime - System.currentTimeMillis() + data.lastPlace;
|
||||
incrementStatistics(player, Id.BP_SPEED, cc.speedTime - System.currentTimeMillis() + data.lastPlace);
|
||||
|
||||
// Execute whatever actions are associated with this check and the
|
||||
// violation level and find out if we should cancel the event
|
||||
cancel = executeActions(player, cc.speedActions, data.speedVL);
|
||||
}
|
||||
else
|
||||
// Reward with lowering of the violation level
|
||||
{
|
||||
data.speedVL *= 0.90D;
|
||||
}
|
||||
|
||||
data.lastPlace = System.currentTimeMillis();
|
||||
|
||||
return cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParameter(final ParameterName wildcard, final NoCheatPlayer player)
|
||||
{
|
||||
if (wildcard == ParameterName.VIOLATIONS)
|
||||
{
|
||||
return String.format(Locale.US, "%d", (int)getData(player).speedVL);
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.getParameter(wildcard, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -86,7 +86,8 @@ public abstract class ConfPaths
|
||||
|
||||
public final static String BLOCKPLACE_SPEED = BLOCKPLACE + "speed.";
|
||||
public final static String BLOCKPLACE_SPEED_CHECK = BLOCKPLACE_SPEED + "active";
|
||||
public final static String BLOCKPLACE_SPEED_ACTIONS = BLOCKPLACE_SPEED + "actions";
|
||||
public final static String BLOCKPLACE_SPEED_ACTIONS = BLOCKPLACE_SPEED + "actions";
|
||||
public final static String BLOCKPLACE_SPEED_TIME = BLOCKPLACE_SPEED + "speed";
|
||||
private final static String BLOCKPLACE_REACH = BLOCKPLACE + "reach.";
|
||||
public final static String BLOCKPLACE_REACH_CHECK = BLOCKPLACE_REACH + "active";
|
||||
public final static String BLOCKPLACE_REACH_ACTIONS = BLOCKPLACE_REACH + "actions";
|
||||
|
@@ -11,7 +11,7 @@ public class Statistics
|
||||
public enum Id
|
||||
{
|
||||
BB_DIRECTION("blockbreak.direction"), BB_NOSWING("blockbreak.noswing"),
|
||||
BB_REACH("blockbreak.reach"), BP_DIRECTION("blockplace.direction"),
|
||||
BB_REACH("blockbreak.reach"), BP_DIRECTION("blockplace.direction"), BP_SPEED("blockplace.speed"),
|
||||
BP_REACH("blockplace.reach"), CHAT_COLOR("chat.color"),
|
||||
CHAT_SPAM("chat.spam"), FI_DIRECTION("fight.direction"),
|
||||
FI_NOSWING("fight.noswing"), FI_REACH("fight.reach"),
|
||||
|
@@ -55,7 +55,8 @@ checks:
|
||||
blockplace:
|
||||
speed:
|
||||
active: true
|
||||
actions: TODO
|
||||
actions: cancel vl>1000 log:bpspeed:3:5:cif cancel vl>4000
|
||||
speed: 145
|
||||
reach:
|
||||
active: true
|
||||
actions: cancel vl>5 log:bpreach:0:2:if cancel
|
||||
|
Reference in New Issue
Block a user