Set an absolute maximum flight height for players.

This commit is contained in:
Evenprime 2011-12-23 14:57:13 +01:00
parent 91f730d731
commit dc03c84025
5 changed files with 20 additions and 4 deletions

View File

@ -34,6 +34,17 @@ public class FlyingCheck extends MovingCheck {
setBack.set(from);
}
PreciseLocation newToLocation = null;
// Before doing anything, do a basic height check
// This is silent for now, will log messages later
if(to.y - data.vertFreedom > ccmoving.flyingHeightLimit) {
newToLocation = new PreciseLocation();
newToLocation.set(setBack);
newToLocation.y = ccmoving.flyingHeightLimit - 5;
return newToLocation;
}
final double yDistance = to.y - from.y;
// Calculate some distances
@ -44,7 +55,6 @@ public class FlyingCheck extends MovingCheck {
double resultHoriz = 0;
double resultVert = 0;
double result = 0;
PreciseLocation newToLocation = null;
// In case of creative gamemode, give at least 0.60 speed limit
// horizontal

View File

@ -56,6 +56,7 @@ public abstract class Configuration {
public final static OptionNode MOVING_RUNFLY_ALLOWLIMITEDFLYING = new OptionNode("allowlimitedflying", MOVING_RUNFLY, DataType.BOOLEAN);
public final static OptionNode MOVING_RUNFLY_FLYINGSPEEDLIMITVERTICAL = new OptionNode("flyingspeedlimitvertical", MOVING_RUNFLY, DataType.INTEGER);
public final static OptionNode MOVING_RUNFLY_FLYINGSPEEDLIMITHORIZONTAL = new OptionNode("flyingspeedlimithorizontal", MOVING_RUNFLY, DataType.INTEGER);
public final static OptionNode MOVING_RUNFLY_FLYINGHEIGHTLIMIT = new OptionNode("flyingheightlimit", MOVING_RUNFLY, DataType.INTEGER);
public final static OptionNode MOVING_RUNFLY_FLYINGACTIONS = new OptionNode("flyingactions", MOVING_RUNFLY, DataType.ACTIONLIST);
private final static OptionNode MOVING_MOREPACKETS = new OptionNode("morepackets", MOVING, DataType.PARENT);

View File

@ -39,7 +39,7 @@ public class DefaultConfiguration extends Configuration {
{
setValue(INVENTORY_CLOSEOBEFORETELEPORTS, true);
}
/*** MOVING ***/
{
setValue(MOVING_CHECK, true);
@ -74,6 +74,7 @@ public class DefaultConfiguration extends Configuration {
setValue(MOVING_RUNFLY_ALLOWLIMITEDFLYING, false);
setValue(MOVING_RUNFLY_FLYINGSPEEDLIMITVERTICAL, 100);
setValue(MOVING_RUNFLY_FLYINGSPEEDLIMITHORIZONTAL, 60);
setValue(MOVING_RUNFLY_FLYINGHEIGHTLIMIT, 500);
ActionList flyingActionList = new ActionList();
flyingActionList.setActions(0, action.getActions("moveLogLowShort moveCancel".split(" ")));

View File

@ -6,8 +6,8 @@ import java.util.Map;
import cc.co.evenprime.bukkit.nocheat.config.util.OptionNode;
/**
* Textual explainations of options, will be displayed in the gui tool and the
* descriptions.txt file.
* Textual explainations of options, will be displayed at the end of the
* config.txt file
*
*/
public class Explainations {
@ -50,6 +50,7 @@ public class Explainations {
set(Configuration.MOVING_RUNFLY_ALLOWLIMITEDFLYING, "If true, instead of doing the above checks for walking/sprinting/swimming/sneaking,\nallow flying and only limit the flying speed.");
set(Configuration.MOVING_RUNFLY_FLYINGSPEEDLIMITVERTICAL, "Set the speed limit for moving vertical while flying.\nUnit is 1/100 of a block, default is 100.");
set(Configuration.MOVING_RUNFLY_FLYINGSPEEDLIMITHORIZONTAL, "Set the speed limit for moving horizontal while flying.\nUnit is 1/100 of a block, default is 60.");
set(Configuration.MOVING_RUNFLY_FLYINGHEIGHTLIMIT, "Set the absolute height limit that a player may go to when flying.\nUnit is number of blocks, default is 500");
set(Configuration.MOVING_RUNFLY_FLYINGACTIONS, "What should be done if a player flies faster than the speed limit(s). \nUnits are in 1/100 of a block above the speedlimit.");
set(Configuration.MOVING_MOREPACKETS_CHECK, "If true, check if a player is sending too many 'move-packets' per second. In a normal game, the player won't send more than 22 packets per second.");

View File

@ -35,6 +35,8 @@ public class CCMoving {
public final boolean morePacketsCheck;
public final ActionList morePacketsActions;
public final double flyingHeightLimit;
public CCMoving(Configuration data) {
check = data.getBoolean(Configuration.MOVING_CHECK);
@ -55,6 +57,7 @@ public class CCMoving {
allowFlying = data.getBoolean(Configuration.MOVING_RUNFLY_ALLOWLIMITEDFLYING);
flyingSpeedLimitVertical = ((double) data.getInteger(Configuration.MOVING_RUNFLY_FLYINGSPEEDLIMITVERTICAL)) / 100D;
flyingSpeedLimitHorizontal = ((double) data.getInteger(Configuration.MOVING_RUNFLY_FLYINGSPEEDLIMITHORIZONTAL)) / 100D;
flyingHeightLimit = data.getInteger(Configuration.MOVING_RUNFLY_FLYINGHEIGHTLIMIT);
flyingActions = data.getActionList(Configuration.MOVING_RUNFLY_FLYINGACTIONS);
nofallCheck = data.getBoolean(Configuration.MOVING_RUNFLY_CHECKNOFALL);