mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-29 03:48:50 +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;
|
||||
@ -72,6 +76,8 @@ public class MovingCheck extends Check {
|
||||
|
||||
private static final double magic = 0.30000001192092896D;
|
||||
private static final double magic2 = 0.69999998807907103D;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The actual check.
|
||||
@ -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 ***********/
|
||||
@ -519,6 +525,10 @@ public class MovingCheck extends Check {
|
||||
setActive(config.getBooleanValue("active.moving"));
|
||||
|
||||
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);
|
||||
|
@ -6,34 +6,30 @@ 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;
|
||||
|
||||
|
||||
// First calculate the distance the player has moved horizontally
|
||||
final double xDistance = from.getX()-to.getX();
|
||||
final double zDistance = from.getZ()-to.getZ();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class NoCheatConfiguration {
|
||||
|
||||
// Setup the configuration tree
|
||||
config(configurationFile, descriptionsFile);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -157,7 +157,7 @@ public class NoCheatConfiguration {
|
||||
|
||||
movingNode.add(new LongStringOption("summarymessage",
|
||||
SimpleYaml.getString("moving.summarymessage", "Moving summary of last ~[timeframe] seconds: [player] total Violations: [violations]", yamlContent)));
|
||||
|
||||
|
||||
movingNode.add(new IntegerOption("summaryafter",
|
||||
SimpleYaml.getInt("moving.summaryafter", 15, yamlContent)));
|
||||
|
||||
@ -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);
|
||||
@ -235,13 +249,13 @@ public class NoCheatConfiguration {
|
||||
bogusitemsNode.add(new BooleanOption("checkops",
|
||||
SimpleYaml.getBoolean("bogusitems.checkops", false, yamlContent)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*** NUKE section ***/
|
||||
{
|
||||
ParentOption nukeNode = new ParentOption("nuke", false);
|
||||
root.add(nukeNode);
|
||||
|
||||
|
||||
nukeNode.add(new BooleanOption("checkops",
|
||||
SimpleYaml.getBoolean("nuke.checkops", false, yamlContent)));
|
||||
nukeNode.add(new LongStringOption("logmessage",
|
||||
@ -250,7 +264,7 @@ public class NoCheatConfiguration {
|
||||
SimpleYaml.getString("nuke.kickmessage", "No nuking allowed", yamlContent)));
|
||||
nukeNode.add(new BooleanOption("limitreach",
|
||||
SimpleYaml.getBoolean("nuke.limitreach", true, yamlContent)));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*** CUSTOMACTIONS section ***/
|
||||
@ -418,7 +432,7 @@ public class NoCheatConfiguration {
|
||||
public boolean getBooleanValue(String optionName) throws ConfigurationException {
|
||||
return getBooleanOption(optionName).getBooleanValue();
|
||||
}
|
||||
|
||||
|
||||
private BooleanOption getBooleanOption(String optionName) throws ConfigurationException {
|
||||
|
||||
Option o = getOption(optionName);
|
||||
|
@ -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