diff options
author | md_5 <md_5@bigpond.com> | 2012-04-07 21:06:51 +1000 |
---|---|---|
committer | md_5 <md_5@bigpond.com> | 2012-04-07 21:06:51 +1000 |
commit | d8f158ed71a71fcfbcb1b5f27963635927554d27 (patch) | |
tree | 524fa842c8bad9f721ff429dcde98f6fc90b2665 /EssentialsAntiCheat | |
parent | ea5081310779d4fa53bc9a99fb43354ad4d34887 (diff) | |
download | Essentials-d8f158ed71a71fcfbcb1b5f27963635927554d27.tar Essentials-d8f158ed71a71fcfbcb1b5f27963635927554d27.tar.gz Essentials-d8f158ed71a71fcfbcb1b5f27963635927554d27.tar.lz Essentials-d8f158ed71a71fcfbcb1b5f27963635927554d27.tar.xz Essentials-d8f158ed71a71fcfbcb1b5f27963635927554d27.zip |
Finish up the speed check.
Diffstat (limited to 'EssentialsAntiCheat')
6 files changed, 47 insertions, 5 deletions
diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/BlockPlaceConfig.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/BlockPlaceConfig.java index 27f1182dd..b94863d67 100644 --- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/BlockPlaceConfig.java +++ b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/BlockPlaceConfig.java @@ -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); diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/BlockPlaceData.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/BlockPlaceData.java index 47ff9d58a..e465fc4aa 100644 --- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/BlockPlaceData.java +++ b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/BlockPlaceData.java @@ -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(); diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/SpeedCheck.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/SpeedCheck.java index 405de36bd..35ffecce1 100644 --- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/SpeedCheck.java +++ b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/blockplace/SpeedCheck.java @@ -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); + } } } diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/config/ConfPaths.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/config/ConfPaths.java index 747eecad3..9466b4105 100644 --- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/config/ConfPaths.java +++ b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/config/ConfPaths.java @@ -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"; diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/data/Statistics.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/data/Statistics.java index 9c83e97d5..ec711345b 100644 --- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/data/Statistics.java +++ b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/data/Statistics.java @@ -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"), diff --git a/EssentialsAntiCheat/src/config.yml b/EssentialsAntiCheat/src/config.yml index b482daf16..8131701ef 100644 --- a/EssentialsAntiCheat/src/config.yml +++ b/EssentialsAntiCheat/src/config.yml @@ -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 |