1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-09-09 06:00:45 +02:00

Hopefully get the basis of a speed check. This whole idea of checks needs to be cleaned up.

This commit is contained in:
md_5
2012-04-05 20:37:20 +10:00
parent 530c2c4c11
commit 3d3b57cb1b
6 changed files with 41 additions and 1 deletions

View File

@@ -21,6 +21,7 @@ public class BlockPlaceCheckListener implements Listener, EventManager
{
private final ReachCheck reachCheck;
private final DirectionCheck directionCheck;
private final SpeedCheck speedCheck;
private final NoCheat plugin;
public BlockPlaceCheckListener(NoCheat plugin)
@@ -28,6 +29,7 @@ public class BlockPlaceCheckListener implements Listener, EventManager
this.plugin = plugin;
speedCheck = new SpeedCheck(plugin);
reachCheck = new ReachCheck(plugin);
directionCheck = new DirectionCheck(plugin);
}
@@ -69,6 +71,11 @@ public class BlockPlaceCheckListener implements Listener, EventManager
cancelled = directionCheck.check(player, data, cc);
}
// Third the speed
if (!cancelled && cc.speedCheck && !player.hasPermission(Permissions.BLOCKPLACE_SPEED))
{
cancelled = speedCheck.check(player, data, cc);
}
// If one of the checks requested to cancel the event, do so
if (cancelled)
{
@@ -76,6 +83,7 @@ public class BlockPlaceCheckListener implements Listener, EventManager
}
}
@Override
public List<String> getActiveChecks(ConfigurationCacheStore cc)
{
LinkedList<String> s = new LinkedList<String>();
@@ -90,7 +98,10 @@ public class BlockPlaceCheckListener implements Listener, EventManager
{
s.add("blockplace.direction");
}
if (bp.speedCheck)
{
s.add("blockplace.speed");
}
return s;
}
}

View File

@@ -21,9 +21,13 @@ public class BlockPlaceConfig implements ConfigItem
public final ActionList directionActions;
public final long directionPenaltyTime;
public final double directionPrecision;
public final boolean speedCheck;
public final ActionList speedActions;
public BlockPlaceConfig(NoCheatConfiguration data)
{
speedCheck = data.getBoolean(ConfPaths.BLOCKPLACE_SPEED_CHECK);
speedActions = data.getActionList(ConfPaths.BLOCKPLACE_SPEED_ACTIONS, Permissions.BLOCKPLACE_SPEED);
reachCheck = data.getBoolean(ConfPaths.BLOCKPLACE_REACH_CHECK);
reachDistance = 535D / 100D;

View File

@@ -0,0 +1,18 @@
package com.earth2me.essentials.anticheat.checks.blockplace;
import com.earth2me.essentials.anticheat.NoCheat;
import com.earth2me.essentials.anticheat.NoCheatPlayer;
public class SpeedCheck extends BlockPlaceCheck
{
public SpeedCheck(NoCheat plugin)
{
super(plugin, "blockplace.speed");
}
public boolean check(NoCheatPlayer player, BlockPlaceData data, BlockPlaceConfig cc)
{
return false;
}
}

View File

@@ -84,6 +84,9 @@ public abstract class ConfPaths
private final static String BLOCKPLACE = CHECKS + "blockplace.";
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";
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";

View File

@@ -25,6 +25,7 @@ public class Permissions
public static final String BLOCKPLACE = CHECKS + ".blockplace";
public static final String BLOCKPLACE_REACH = BLOCKPLACE + ".reach";
public static final String BLOCKPLACE_DIRECTION = BLOCKPLACE + ".direction";
public static final String BLOCKPLACE_SPEED = BLOCKPLACE + ".speed";
public static final String CHAT = CHECKS + ".chat";
public static final String CHAT_SPAM = CHAT + ".spam";
public static final String CHAT_COLOR = CHAT + ".color";

View File

@@ -53,6 +53,9 @@ checks:
active: true
actions: log:bbnoswing:3:2:if cancel
blockplace:
speed:
active: true
actions: TODO
reach:
active: true
actions: cancel vl>5 log:bpreach:0:2:if cancel