+ rudimentary support for sprinting players

This commit is contained in:
Evenprime 2011-09-15 13:28:58 +02:00
parent d280bc4f7d
commit 248a4867a6
6 changed files with 18 additions and 7 deletions

View File

@ -3,7 +3,7 @@ name: NoCheat
author: Evenprime
main: cc.co.evenprime.bukkit.nocheat.NoCheat
version: 2.03c
version: 2.04
permissions:

View File

@ -83,8 +83,9 @@ public class DefaultConfiguration {
movingNode.add(runningNode);
runningNode.add(new BooleanOption("check", true, true));
runningNode.add(new IntegerOption("speedlimit", 22));
runningNode.add(new IntegerOption("walkingspeedlimit", 22));
runningNode.add(new IntegerOption("sprintingspeedlimit", 44));
/**** MOVING.RUNNING.SWIMMING ****/
{
ParentOption swimmingNode = new ParentOption("swimming");

View File

@ -33,7 +33,8 @@ public class Explainations {
set("moving.flying.actions", "What should be done if a player flies faster than the speed limit(s). \nUnits are in 1/100 of a block above the limit.");
set("moving.running.check", "If true, check if a player is running too fast/jumping too high.\nIf this is true, 'flying.check' is ignored.");
set("moving.running.speedlimit", "Set the speed limit for moving horizontal under 'normal' conditions.\nUnit is 1/100 of a block, default is 22.");
set("moving.running.walkingspeedlimit", "Set the speed limit for moving horizontal under 'normal' conditions.\nUnit is 1/100 of a block, default is 22.");
set("moving.running.sprintingspeedlimit", "Set the speed limit for moving horizontal while sprinting.\nUnit is 1/100 of a block, default is 44.");
set("moving.running.swimming.check", "If 'running.check' and this are active, use a seperate speed limit for swimming players.");
set("moving.running.swimming.speedlimit", "Set the speed limit for moving horizontal while in water.\nUnit is 1/100 of a block, default is 18");
set("moving.running.sneaking.check", "If 'running.check' and this are active, use a seperate speed limit for sneaking players.");

View File

@ -70,6 +70,10 @@ public class NoCheat extends JavaPlugin {
// First set up logging
this.log = new LogManager(this);
log.logToConsole(LogLevel.MED, "[NoCheat] This version is EXPERIMENTAL and built specifically for CB #1118. It may break at any time and for any other version.");
this.data = new DataManager();
this.action = new ActionManager(log);

View File

@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.Locale;
import org.bukkit.Location;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Player;
import cc.co.evenprime.bukkit.nocheat.NoCheat;
@ -129,8 +130,10 @@ public class RunningCheck {
distanceAboveLimit = totalDistance - cc.moving.sneakingSpeedLimit - data.horizFreedom;
} else if(cc.moving.swimmingCheck && isSwimming && !player.hasPermission(Permissions.MOVE_SWIM)) {
distanceAboveLimit = totalDistance - cc.moving.swimmingSpeedLimit - data.horizFreedom;
} else if(player instanceof CraftPlayer && !((CraftPlayer)player).getHandle().at()){
distanceAboveLimit = totalDistance - cc.moving.walkingSpeedLimit - data.horizFreedom;
} else {
distanceAboveLimit = totalDistance - cc.moving.runningSpeedLimit - data.horizFreedom;
distanceAboveLimit = totalDistance - cc.moving.sprintingSpeedLimit - data.horizFreedom;
}
// Did he go too far?

View File

@ -21,7 +21,8 @@ public class CCMoving {
public final ActionList flyingActions;
public final boolean runningCheck;
public final double runningSpeedLimit;
public final double walkingSpeedLimit;
public final double sprintingSpeedLimit;
public final ActionList runningActions;
@ -46,7 +47,8 @@ public class CCMoving {
flyingActions = data.getActionList("moving.flying.actions");
runningCheck = data.getBoolean("moving.running.check");
runningSpeedLimit = ((double) data.getInteger("moving.running.speedlimit")) / 100D;
walkingSpeedLimit = ((double) data.getInteger("moving.running.walkingspeedlimit")) / 100D;
sprintingSpeedLimit = ((double) data.getInteger("moving.running.sprintingspeedlimit")) / 100D;
runningActions = data.getActionList("moving.running.actions");
swimmingCheck = data.getBoolean("moving.running.swimming.check");
swimmingSpeedLimit = ((double) data.getInteger("moving.running.swimming.speedlimit")) / 100D;