mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-30 20:37:52 +01:00
Option to set movement speed limits
This commit is contained in:
parent
ee1ae892eb
commit
c438eee164
@ -3,7 +3,7 @@ name: NoCheat
|
||||
author: Evenprime
|
||||
|
||||
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
||||
version: 1.09f
|
||||
version: 1.10a
|
||||
|
||||
softdepend: [ Permissions, CraftIRC ]
|
||||
|
||||
|
@ -53,6 +53,10 @@ public class MovingCheck extends Check {
|
||||
public boolean allowFakeSneak;
|
||||
public boolean allowFastSwim;
|
||||
|
||||
public double stepWidth;
|
||||
public double sneakWidth;
|
||||
public double swimWidth;
|
||||
|
||||
private boolean waterElevators;
|
||||
|
||||
private String logMessage;
|
||||
@ -73,6 +77,8 @@ public class MovingCheck extends Check {
|
||||
private static final double magic = 0.30000001192092896D;
|
||||
private static final double magic2 = 0.69999998807907103D;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The actual check.
|
||||
* First find out if the event needs to be handled at all
|
||||
@ -118,7 +124,7 @@ public class MovingCheck extends Check {
|
||||
|
||||
if(runCheck) {
|
||||
result += Math.max(0D, runningCheck.check(from, to,
|
||||
!allowFakeSneak && player.isSneaking(), !allowFastSwim && (fromType & toType & MovingEventHelper.LIQUID) > 0, data));
|
||||
!allowFakeSneak && player.isSneaking(), !allowFastSwim && (fromType & toType & MovingEventHelper.LIQUID) > 0, data, this));
|
||||
}
|
||||
|
||||
/********* HANDLE/COMBINE THE RESULTS OF THE CHECKS ***********/
|
||||
@ -520,6 +526,10 @@ public class MovingCheck extends Check {
|
||||
|
||||
enforceTeleport = config.getBooleanValue("moving.enforceteleport");
|
||||
|
||||
stepWidth = ((double)config.getIntegerValue("moving.limits.walking")) /100D;
|
||||
sneakWidth = ((double)config.getIntegerValue("moving.limits.sneaking"))/100D;
|
||||
swimWidth = ((double)config.getIntegerValue("moving.limits.swimming"))/100D;
|
||||
|
||||
} catch (ConfigurationException e) {
|
||||
setActive(false);
|
||||
e.printStackTrace();
|
||||
|
@ -6,13 +6,10 @@ import cc.co.evenprime.bukkit.nocheat.data.MovingData;
|
||||
|
||||
public class RunningCheck {
|
||||
|
||||
public final static double stepWidth = 0.22D;
|
||||
public final static double sneakWidth = 0.14D;
|
||||
public final static double swimWidth = 0.18D;
|
||||
|
||||
public RunningCheck() { }
|
||||
|
||||
public double check(final Location from, final Location to, final boolean isSneaking, final boolean isSwimming, final MovingData data) {
|
||||
public double check(final Location from, final Location to, final boolean isSneaking, final boolean isSwimming, final MovingData data, MovingCheck check) {
|
||||
|
||||
// How much further did the player move than expected??
|
||||
double distanceAboveLimit = 0.0D;
|
||||
@ -23,15 +20,14 @@ public class RunningCheck {
|
||||
|
||||
final double totalDistance = Math.sqrt((xDistance*xDistance + zDistance*zDistance));
|
||||
|
||||
// TODO: Also ask cc which to apply
|
||||
if(isSneaking) {
|
||||
distanceAboveLimit = totalDistance - sneakWidth;
|
||||
distanceAboveLimit = totalDistance - check.sneakWidth;
|
||||
}
|
||||
else if(isSwimming) {
|
||||
distanceAboveLimit = totalDistance - swimWidth;
|
||||
distanceAboveLimit = totalDistance - check.swimWidth;
|
||||
}
|
||||
else {
|
||||
distanceAboveLimit = totalDistance - stepWidth;
|
||||
distanceAboveLimit = totalDistance - check.stepWidth;
|
||||
}
|
||||
|
||||
return distanceAboveLimit - data.horizFreedom;
|
||||
|
@ -176,6 +176,20 @@ public class NoCheatConfiguration {
|
||||
movingNode.add(new BooleanOption("enforceteleport",
|
||||
SimpleYaml.getBoolean("moving.enforceteleport", false, yamlContent)));
|
||||
|
||||
|
||||
/*** MOVING LIMITS section ***/
|
||||
{
|
||||
ParentOption movingLimitsNode = new ParentOption("limits", false);
|
||||
movingNode.add(movingLimitsNode);
|
||||
|
||||
movingLimitsNode.add(new IntegerOption("walking",
|
||||
SimpleYaml.getInt("moving.limits.walking", 22, yamlContent)));
|
||||
movingLimitsNode.add(new IntegerOption("sneaking",
|
||||
SimpleYaml.getInt("moving.limits.sneaking", 14, yamlContent)));
|
||||
movingLimitsNode.add(new IntegerOption("swimming",
|
||||
SimpleYaml.getInt("moving.limits.swimming", 18, yamlContent)));
|
||||
}
|
||||
|
||||
/*** MOVING ACTION section ***/
|
||||
{
|
||||
ParentOption movingActionNode = new ParentOption("action", false);
|
||||
|
@ -135,6 +135,22 @@ public class Explainations {
|
||||
"of other plugins to prevent/cancel the teleport. This is usually a 'not-so-nice' thing to do,\n" +
|
||||
"but sometimes the only way to get the plugin to work properly in combination with others.");
|
||||
|
||||
set("moving.limits.walking", "How far can a player move with one step. The value doesn't represent any\n" +
|
||||
"real distance units, it's just an indicator. 22 is about the normal walking speed of players.\n" +
|
||||
"If you want to let them move faster, increase that number. If you decrease that number, players\n" +
|
||||
"will have to move slower, but that will only work if they have a client mod that allows them to\n" +
|
||||
"move slower than normal.");
|
||||
set("moving.limits.sneaking", "How far can a player move while sneaking in one step. The value doesn't represent any\n" +
|
||||
"real distance units, it's just an indicator. 14 is about the normal sneaking speed of players.\n" +
|
||||
"If you want to let them sneak faster, increase that number. If you decrease that number, players\n" +
|
||||
"will have to move even slower, but that will only work if they have a client mod that allows them to\n" +
|
||||
"move slower than normal. If you have set \"allowfakesneak\" to true, this value is meaningless.");
|
||||
set("moving.limits.swimming", "How far can a player move while swimming in one step. The value doesn't represent any\n" +
|
||||
"real distance units, it's just an indicator. 18 is about the normal swimming speed of players.\n" +
|
||||
"If you want to let them swim faster, increase that number. If you decrease that number, players\n" +
|
||||
"will have to move even slower, but that will only work if they have a client mod that allows them to\n" +
|
||||
"move slower than normal. If you have set \"allowfastswim\" to true, this value is meaningless.");
|
||||
|
||||
set("moving.action.low", "Execute these actions when a player moves further/higher in one step than the\n" +
|
||||
"limits defined by this plugin allow.\n" +
|
||||
"Actions are executed in order. Available actions are loglow = log a message with low severeness,\n" +
|
||||
|
Loading…
Reference in New Issue
Block a user