diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/FlyingCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/FlyingCheck.java index 2f068e8c..f0df1df6 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/FlyingCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/FlyingCheck.java @@ -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 diff --git a/src/cc/co/evenprime/bukkit/nocheat/config/Configuration.java b/src/cc/co/evenprime/bukkit/nocheat/config/Configuration.java index c00ca9e5..53e857c3 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/config/Configuration.java +++ b/src/cc/co/evenprime/bukkit/nocheat/config/Configuration.java @@ -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); diff --git a/src/cc/co/evenprime/bukkit/nocheat/config/DefaultConfiguration.java b/src/cc/co/evenprime/bukkit/nocheat/config/DefaultConfiguration.java index 668bfc42..bbf5f6f4 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/config/DefaultConfiguration.java +++ b/src/cc/co/evenprime/bukkit/nocheat/config/DefaultConfiguration.java @@ -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(" "))); diff --git a/src/cc/co/evenprime/bukkit/nocheat/config/Explainations.java b/src/cc/co/evenprime/bukkit/nocheat/config/Explainations.java index 5f8699a6..554d6a31 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/config/Explainations.java +++ b/src/cc/co/evenprime/bukkit/nocheat/config/Explainations.java @@ -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."); diff --git a/src/cc/co/evenprime/bukkit/nocheat/config/cache/CCMoving.java b/src/cc/co/evenprime/bukkit/nocheat/config/cache/CCMoving.java index e6b4c13d..c4421f32 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/config/cache/CCMoving.java +++ b/src/cc/co/evenprime/bukkit/nocheat/config/cache/CCMoving.java @@ -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);