diff --git a/pom.xml b/pom.xml index e29d91b2..3dc3f329 100644 --- a/pom.xml +++ b/pom.xml @@ -42,7 +42,7 @@ org.bukkit craftbukkit - 1.3.1-R0.1-SNAPSHOT + 1.3.1-R1.0 jar compile diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakConfig.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakConfig.java index 7e09b67d..b58d51d8 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakConfig.java @@ -63,6 +63,7 @@ public class BlockBreakConfig { public final ActionList directionActions; public final boolean fastBreakCheck; + public final int fastBreakBuffer; public final boolean fastBreakExperimental; public final int fastBreakInterval; public final ActionList fastBreakActions; @@ -84,6 +85,7 @@ public class BlockBreakConfig { directionActions = data.getActionList(ConfPaths.BLOCKBREAK_DIRECTION_ACTIONS, Permissions.BLOCKBREAK_DIRECTION); fastBreakCheck = data.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_CHECK); + fastBreakBuffer = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_BUFFER); fastBreakExperimental = data.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_EXPERIMENTAL); fastBreakInterval = data.getInt(ConfPaths.BLOCKBREAK_FASTBREAK_INTERVAL); fastBreakActions = data.getActionList(ConfPaths.BLOCKBREAK_FASTBREAK_ACTIONS, Permissions.BLOCKBREAK_FASTBREAK); diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakData.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakData.java index 03efdcb5..2e057977 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakData.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakData.java @@ -50,7 +50,7 @@ public class BlockBreakData { public double reachVL; // Data of the fast break check. - public int fastBreakBuffer = 3; + public int fastBreakBuffer = 5; public long fastBreakBreakTime = System.currentTimeMillis() - 1000L; public long fastBreakDamageTime = System.currentTimeMillis(); diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java index a8fb3eab..86e1f6a4 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java @@ -95,7 +95,7 @@ public class FastBreak extends Check { data.fastBreakBuffer--; } else { // If the buffer isn't full. - if (data.fastBreakBuffer < 3) + if (data.fastBreakBuffer < data.fastBreakBuffer) // Add one to the buffer. data.fastBreakBuffer++; diff --git a/src/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractConfig.java b/src/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractConfig.java index 5e37974f..0a76c1f2 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractConfig.java @@ -62,10 +62,6 @@ public class BlockInteractConfig { public final boolean directionCheck; public final ActionList directionActions; - public final boolean fastInteractCheck; - public final long fastInteractInterval; - public final ActionList fastInteractActions; - public final boolean noSwingCheck; public final ActionList noSwingActions; @@ -83,11 +79,6 @@ public class BlockInteractConfig { directionActions = data.getActionList(ConfPaths.BLOCKINTERACT_DIRECTION_ACTIONS, Permissions.BLOCKINTERACT_DIRECTION); - fastInteractCheck = data.getBoolean(ConfPaths.BLOCKINTERACT_FASTINTERACT_CHECK); - fastInteractInterval = data.getLong(ConfPaths.BLOCKINTERACT_FASTINTERACT_INTERVAL); - fastInteractActions = data.getActionList(ConfPaths.BLOCKINTERACT_FASTINTERACT_ACTIONS, - Permissions.BLOCKINTERACT_FASTINTERACT); - noSwingCheck = data.getBoolean(ConfPaths.BLOCKINTERACT_NOSWING_CHECK); noSwingActions = data.getActionList(ConfPaths.BLOCKINTERACT_NOSWING_ACTIONS, Permissions.BLOCKINTERACT_NOSWING); diff --git a/src/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractData.java b/src/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractData.java index 4b36e3f4..c6a866e8 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractData.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractData.java @@ -45,16 +45,12 @@ public class BlockInteractData { // Violation levels. public double directionVL; - public double fastInteractVL; public double noSwingVL; public double reachVL; - // Data of the fast interact check. - public boolean fastInteractLastRefused; - public double fastInteractLastTime; - // Data of the no swing check. public boolean noSwingArmSwung; + public long noSwingLastTime; // Data of the reach check. public double reachDistance; diff --git a/src/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractListener.java b/src/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractListener.java index 1e58c167..cf2d9a87 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractListener.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockinteract/BlockInteractListener.java @@ -1,5 +1,8 @@ package fr.neatmonster.nocheatplus.checks.blockinteract; +import java.util.Arrays; + +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -32,10 +35,15 @@ import org.bukkit.event.player.PlayerInteractEvent; * @see BlockInteractEvent */ public class BlockInteractListener implements Listener { - private final Direction direction = new Direction(); - private final FastInteract fastInteract = new FastInteract(); - private final NoSwing noSwing = new NoSwing(); - private final Reach reach = new Reach(); + private final Direction direction = new Direction(); + private final NoSwing noSwing = new NoSwing(); + private final Reach reach = new Reach(); + + private final Material[] materials = new Material[] {Material.BED_BLOCK, Material.BURNING_FURNACE, + Material.BREWING_STAND, Material.CAKE_BLOCK, Material.CAULDRON, Material.CHEST, Material.DIODE_BLOCK_OFF, + Material.DIODE_BLOCK_ON, Material.DISPENSER, Material.DRAGON_EGG, Material.ENCHANTMENT_TABLE, + Material.ENDER_CHEST, Material.FENCE_GATE, Material.FURNACE, Material.IRON_DOOR_BLOCK, Material.LEVER, + Material.NOTE_BLOCK, Material.STONE_BUTTON, Material.TRAP_DOOR, Material.WOODEN_DOOR, Material.WORKBENCH}; /** * We listen to PlayerAnimation events because it is (currently) equivalent to "player swings arm" and we want to @@ -60,7 +68,7 @@ public class BlockInteractListener implements Listener { } /** - * We listen to PlayerInteractEvent events for obvious reasons + * We listen to PlayerInteractEvent events for obvious reasons. * * @param event * the event @@ -86,19 +94,19 @@ public class BlockInteractListener implements Listener { boolean cancelled = false; - // Do the actual checks, first the fast interact check. - if (fastInteract.isEnabled(player) && fastInteract.check(player)) - cancelled = true; + // First the no swing check. + if (event.getAction() != Action.RIGHT_CLICK_BLOCK + || Arrays.asList(materials).contains(event.getClickedBlock().getType())) { + if (noSwing.isEnabled(player) && noSwing.check(player)) + cancelled = true; + } else + BlockInteractData.getData(player).noSwingArmSwung = false; - // Second the no swing check. - if (!cancelled && noSwing.isEnabled(player) && noSwing.check(player)) - cancelled = true; - - // Third the reach check + // Second the reach check. if (!cancelled && reach.isEnabled(player) && reach.check(player, block.getLocation())) cancelled = true; - // Fourth the direction check + // Third the direction check if (!cancelled && direction.isEnabled(player) && direction.check(player, block.getLocation())) cancelled = true; diff --git a/src/fr/neatmonster/nocheatplus/checks/blockinteract/FastInteract.java b/src/fr/neatmonster/nocheatplus/checks/blockinteract/FastInteract.java deleted file mode 100644 index 8fef919b..00000000 --- a/src/fr/neatmonster/nocheatplus/checks/blockinteract/FastInteract.java +++ /dev/null @@ -1,105 +0,0 @@ -package fr.neatmonster.nocheatplus.checks.blockinteract; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import fr.neatmonster.nocheatplus.actions.ParameterName; -import fr.neatmonster.nocheatplus.checks.Check; -import fr.neatmonster.nocheatplus.checks.CheckEvent; -import fr.neatmonster.nocheatplus.players.Permissions; -import fr.neatmonster.nocheatplus.utilities.LagMeasureTask; - -/* - * MM""""""""`M dP M""M dP dP -MM mmmmmmmM 88 M M 88 88 -M' MMMM .d8888b. .d8888b. d8888P M M 88d888b. d8888P .d8888b. 88d888b. .d8888b. .d8888b. d8888P -MM MMMMMMMM 88' `88 Y8ooooo. 88 M M 88' `88 88 88ooood8 88' `88 88' `88 88' `"" 88 -MM MMMMMMMM 88. .88 88 88 M M 88 88 88 88. ... 88 88. .88 88. ... 88 -MM MMMMMMMM `88888P8 `88888P' dP M M dP dP dP `88888P' dP `88888P8 `88888P' dP -MMMMMMMMMMMM MMMM - */ -/** - * A check used to verify if the player isn't interacting with blocks too quickly. - */ -public class FastInteract extends Check { - - /** - * The event triggered by this check. - */ - public class FastInteractEvent extends CheckEvent { - - /** - * Instantiates a new fast interact event. - * - * @param player - * the player - */ - public FastInteractEvent(final Player player) { - super(player); - } - } - - /** - * Checks a player. - * - * @param player - * the player - * @return true, if successful - */ - public boolean check(final Player player) { - final BlockInteractConfig cc = BlockInteractConfig.getConfig(player); - final BlockInteractData data = BlockInteractData.getData(player); - - boolean cancel = false; - - // Has the player interacted with blocks too quickly? - if (data.fastInteractLastTime != 0 - && System.currentTimeMillis() - data.fastInteractLastTime < cc.fastInteractInterval) { - if (!LagMeasureTask.skipCheck()) { - if (data.fastInteractLastRefused) { - // He failed, increase his violation level. - data.fastInteractVL += cc.fastInteractInterval - System.currentTimeMillis() - + data.fastInteractLastTime; - - // Distance a fast interact event (API). - final FastInteractEvent e = new FastInteractEvent(player); - Bukkit.getPluginManager().callEvent(e); - - // Execute whatever actions are associated with this check and the violation level and find out if - // we should cancel the event. - cancel = !e.isCancelled() && executeActions(player, cc.fastInteractActions, data.fastInteractVL); - } - - data.fastInteractLastRefused = true; - } - } else { - // Reward him by lowering his violation level. - data.fastInteractVL *= 0.9D; - data.fastInteractLastRefused = false; - } - - data.fastInteractLastTime = System.currentTimeMillis(); - - return cancel; - } - - /* (non-Javadoc) - * @see fr.neatmonster.nocheatplus.checks.Check#getParameter(fr.neatmonster.nocheatplus.actions.ParameterName, org.bukkit.entity.Player) - */ - @Override - public String getParameter(final ParameterName wildcard, final Player player) { - if (wildcard == ParameterName.VIOLATIONS) - return String.valueOf(Math.round(BlockInteractData.getData(player).fastInteractVL)); - else - return super.getParameter(wildcard, player); - } - - /* (non-Javadoc) - * @see fr.neatmonster.nocheatplus.checks.Check#isEnabled(org.bukkit.entity.Player) - */ - @Override - protected boolean isEnabled(final Player player) { - return !player.hasPermission(Permissions.BLOCKINTERACT_FASTINTERACT) - && BlockInteractConfig.getConfig(player).fastInteractCheck; - } -} diff --git a/src/fr/neatmonster/nocheatplus/checks/blockinteract/NoSwing.java b/src/fr/neatmonster/nocheatplus/checks/blockinteract/NoSwing.java index ea849d51..b7d07b29 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockinteract/NoSwing.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockinteract/NoSwing.java @@ -52,24 +52,28 @@ public class NoSwing extends Check { boolean cancel = false; - // Did he swing his arm before? - if (data.noSwingArmSwung) { - // "Consume" the flag. - data.noSwingArmSwung = false; - // Reward with lowering of the violation level. - data.noSwingVL *= 0.9D; - } else { - // He failed, increase violation level. - data.noSwingVL += 1D; + if (System.currentTimeMillis() - data.noSwingLastTime > 3L) + // Did he swing his arm before? + if (data.noSwingArmSwung) { + // "Consume" the flag. + data.noSwingArmSwung = false; + // Reward with lowering of the violation level. + data.noSwingVL *= 0.9D; + } else { + // He failed, increase violation level. + data.noSwingVL += 1D; - // Dispatch a no swing event (API). - final NoSwingEvent e = new NoSwingEvent(player); - Bukkit.getPluginManager().callEvent(e); + // Dispatch a no swing event (API). + final NoSwingEvent e = new NoSwingEvent(player); + Bukkit.getPluginManager().callEvent(e); - // Execute whatever actions are associated with this check and the violation level and find out if we should - // cancel the event. - cancel = !e.isCancelled() && executeActions(player, cc.noSwingActions, data.noSwingVL); - } + // Execute whatever actions are associated with this check and the violation level and find out if we + // should + // cancel the event. + cancel = !e.isCancelled() && executeActions(player, cc.noSwingActions, data.noSwingVL); + } + + data.noSwingLastTime = System.currentTimeMillis(); return cancel; diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/CreativeFly.java b/src/fr/neatmonster/nocheatplus/checks/moving/CreativeFly.java index 44daf74d..addcdc95 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/CreativeFly.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/CreativeFly.java @@ -69,7 +69,8 @@ public class CreativeFly extends Check { final MovingData data = MovingData.getData(player); // If we have no setback, define one now. - data.setBack = data.setBack == null ? from.getLocation() : data.setBack; + if (data.setBack == null) + data.setBack = from.getLocation(); // Before doing anything, do a basic height check to determine if players are flying too high. final int maximumHeight = cc.creativeFlyMaxHeight + player.getWorld().getMaxHeight(); @@ -135,21 +136,27 @@ public class CreativeFly extends Check { // The player went to far, either horizontal or vertical. if (result > 0D) { - // Increment violation level. - data.creativeFlyVL += result; + if (data.creativeFlyPreviousRefused) { + // Increment violation level. + data.creativeFlyVL += result; - // Dispatch a creative fly event (API). - final CreativeFlyEvent e = new CreativeFlyEvent(player); - Bukkit.getPluginManager().callEvent(e); + // Dispatch a creative fly event (API). + final CreativeFlyEvent e = new CreativeFlyEvent(player); + Bukkit.getPluginManager().callEvent(e); - // Execute whatever actions are associated with this check and the violation level and find out if we should - // cancel the event. - if (!e.isCancelled() && executeActions(player, cc.creativeFlyActions, data.creativeFlyVL)) - // Compose a new location based on coordinates of "newTo" and viewing direction of "event.getTo()" to - // allow the player to look somewhere else despite getting pulled back by NoCheatPlus. - return new Location(player.getWorld(), data.setBack.getX(), data.setBack.getY(), data.setBack.getZ(), - to.getYaw(), to.getPitch()); - } + // Execute whatever actions are associated with this check and the violation level and find out if we + // should + // cancel the event. + if (!e.isCancelled() && executeActions(player, cc.creativeFlyActions, data.creativeFlyVL)) + // Compose a new location based on coordinates of "newTo" and viewing direction of "event.getTo()" + // to + // allow the player to look somewhere else despite getting pulled back by NoCheatPlus. + return new Location(player.getWorld(), data.setBack.getX(), data.setBack.getY(), + data.setBack.getZ(), to.getYaw(), to.getPitch()); + } else + data.creativeFlyPreviousRefused = true; + } else + data.creativeFlyPreviousRefused = false; // Slowly reduce the violation level with each event. data.creativeFlyVL *= 0.97D; diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/MovingData.java b/src/fr/neatmonster/nocheatplus/checks/moving/MovingData.java index 565c1d70..a9a3b598 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/MovingData.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/MovingData.java @@ -56,6 +56,9 @@ public class MovingData { public Location[] lastSafeLocations = new Location[] {null, null}; + // Data of the creative check. + public boolean creativeFlyPreviousRefused; + // Data of the more packets check. public int morePacketsBuffer = 50; public long morePacketsLastTime; @@ -75,9 +78,9 @@ public class MovingData { // Data of the survival fly check. public int survivalFlyJumpPhase; public int survivalFlyOnIce; - public long survivalInLavaSince; - public long survivalInWaterSince; - public long survivalOnLadderSince; + public long survivalFlyInLavaSince; + public long survivalFlyInWaterSince; + public long survivalFlyOnLadderSince; // Locations shared between all checks. public Location from; diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/NoFall.java b/src/fr/neatmonster/nocheatplus/checks/moving/NoFall.java index 24235f17..82a8276e 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/NoFall.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/NoFall.java @@ -66,8 +66,7 @@ public class NoFall extends Check { } // This check is pretty much always a step behind for technical reasons. - if (from.isInLiquid() || to.isInLiquid() || from.isOnGround() || to.isOnGround() || from.isOnLadder() - || to.isOnLadder()) + if (from.isInLiquid() || from.isOnGround() || from.isOnLadder()) // Start with zero fall distance. data.noFallDistance = 0F; diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java b/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java index 1087e67d..2ad43c80 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java @@ -62,13 +62,13 @@ public class SurvivalFly extends Check { private static final double COBWEB_DESCEND = 0.062D + MARGIN; /** The horizontal speed limit when moving into web. */ - private static final double COBWEB_MOVE = 0.08D; + private static final double COBWEB_MOVE = 0.11D; /** The horizontal speed amplifier when being on ice. */ private static final double ICE_AMPLIFIER = 2.5D; /** The number of events contained in a jump phase. */ - private static final int JUMP_PHASE = 7; + private static final int JUMP_PHASE = 6; /** The distance removed after each jumping event. */ private static final double JUMP_STEP = 0.15D; @@ -95,10 +95,10 @@ public class SurvivalFly extends Check { private static final double SNEAKING_MOVE = 0.14D; /** The horizontal speed limit when moving on soul sand. */ - private static final double SOULSAND_MOVE = 0.11D; + private static final double SOULSAND_MOVE = 0.13D; /** The horizontal speed limit when sprinting on soul sand. */ - private static final double SOULSAND_SPRINTING_MOVE = 0.14D; + private static final double SOULSAND_SPRINTING_MOVE = 0.18D; /** The horizontal speed limit when sprinting. */ private static final double SPRINTING_MOVE = 0.37D; @@ -130,7 +130,8 @@ public class SurvivalFly extends Check { final MovingConfig cc = MovingConfig.getConfig(player); final MovingData data = MovingData.getData(player); - data.setBack = data.setBack == null ? from.getLocation() : data.setBack; + if (data.setBack == null) + data.setBack = from.getLocation(); // Player on ice? Give him higher max speed. if (from.isOnIce() || to.isOnIce()) @@ -220,30 +221,30 @@ public class SurvivalFly extends Check { // Remember since when the player is in lava/in water/on ladder. if (from.isInLava() && !to.isInLava()) - data.survivalInLavaSince = 0L; + data.survivalFlyInLavaSince = 0L; else if (!from.isInLava() && to.isInLava()) - data.survivalInLavaSince = System.currentTimeMillis(); + data.survivalFlyInLavaSince = System.currentTimeMillis(); if (from.isInWater() && !to.isInWater()) - data.survivalInWaterSince = 0L; + data.survivalFlyInWaterSince = 0L; else if (!from.isInWater() && to.isInWater()) - data.survivalInWaterSince = System.currentTimeMillis(); + data.survivalFlyInWaterSince = System.currentTimeMillis(); if (from.isOnLadder() && !to.isOnLadder()) - data.survivalOnLadderSince = 0L; + data.survivalFlyOnLadderSince = 0L; else if (!from.isOnLadder() && to.isOnLadder()) - data.survivalOnLadderSince = System.currentTimeMillis(); + data.survivalFlyOnLadderSince = System.currentTimeMillis(); double vDistance = to.getY() - from.getY(); // Handle all the special cases. double vDistanceAboveLimit = 0D; - if (from.isInLava() && to.isInLava() && data.survivalInLavaSince > 0L - && System.currentTimeMillis() - data.survivalInLavaSince > 1000L) { + if (from.isInLava() && to.isInLava() && data.survivalFlyInLavaSince > 0L + && System.currentTimeMillis() - data.survivalFlyInLavaSince > 1000L) { if (vDistance > cc.survivalFlyLavaSpeed / 100D * LAVA_ASCEND) vDistanceAboveLimit = vDistance - cc.survivalFlyLavaSpeed / 100D * LAVA_ASCEND; else if (vDistance < cc.survivalFlyLavaSpeed / 100D * -LAVA_DESCEND) vDistanceAboveLimit = cc.survivalFlyLavaSpeed / 100D * -LAVA_DESCEND - vDistance; - } else if (from.isInWater() && to.isInWater() && data.survivalInWaterSince > 0L - && System.currentTimeMillis() - data.survivalInWaterSince > 1000L) { + } else if (from.isInWater() && to.isInWater() && data.survivalFlyInWaterSince > 0L + && System.currentTimeMillis() - data.survivalFlyInWaterSince > 1000L) { if (vDistance > cc.survivalFlyWaterSpeed / 100D * WATER_ASCEND) vDistanceAboveLimit = vDistance - cc.survivalFlyWaterSpeed / 100D * WATER_ASCEND; else if (vDistance < cc.survivalFlyWaterSpeed / 100D * -WATER_DESCEND) @@ -253,14 +254,16 @@ public class SurvivalFly extends Check { vDistanceAboveLimit = vDistance - cc.survivalFlyCobWebSpeed / 100D * COBWEB_ASCEND; else if (vDistance < cc.survivalFlyCobWebSpeed / 100D * -COBWEB_DESCEND) vDistanceAboveLimit = cc.survivalFlyCobWebSpeed / 100D * -COBWEB_DESCEND - vDistance; - } else if (from.isOnLadder(true) && to.isOnLadder(true) && data.survivalOnLadderSince > 0L - && System.currentTimeMillis() - data.survivalOnLadderSince > 1000L) { + } else if (from.isOnLadder(true) && to.isOnLadder(true) && data.survivalFlyOnLadderSince > 0L + && System.currentTimeMillis() - data.survivalFlyOnLadderSince > 1000L) { if (vDistance > cc.survivalFlyLadderSpeed / 100D * LADDER_ASCEND) vDistanceAboveLimit = vDistance - cc.survivalFlyLadderSpeed / 100D * LADDER_ASCEND; else if (vDistance < cc.survivalFlyLadderSpeed / 100D * -LADDER_DESCEND) vDistanceAboveLimit = cc.survivalFlyLadderSpeed / 100D * -LADDER_DESCEND - vDistance; } else { vDistance = to.getY() - data.setBack.getY(); + if (vDistance <= 0D) + data.survivalFlyJumpPhase = 0; double vAllowedDistance = (data.verticalFreedom + 1.35D) * data.jumpAmplifier; if (data.survivalFlyJumpPhase > JUMP_PHASE + data.jumpAmplifier) @@ -269,6 +272,13 @@ public class SurvivalFly extends Check { vDistanceAboveLimit = Math.max(0D, vDistance - vAllowedDistance); } + // Handle slabs placed into a liquid. + if (from.isInLiquid() + && to.isInLiquid() + && (to.isOnGround() && to.getY() - from.getY() == 0.5D || !from.isOnGround() && to.isOnGround() || from + .isOnGround() && !to.isOnGround())) + vDistanceAboveLimit = 0D; + if (from.isOnGround() || to.isOnGround()) data.jumpAmplifier = 0D; @@ -309,16 +319,20 @@ public class SurvivalFly extends Check { data.setBack = to.getLocation(); data.setBack.setY(Math.ceil(data.setBack.getY())); data.survivalFlyJumpPhase = 0; - } else if (to.isInWeb() || to.isOnLadder() || to.isOnGround() + } else if ((to.isInWeb() || to.isOnLadder() || to.isOnGround()) && (from.getY() >= to.getY() || data.setBack.getY() <= Math.floor(to.getY()))) { // If the player moved down "onto" the ground and the new setback point is higher up than the old or at // least at the same height, or if the player is in web or on a ladder. data.setBack = to.getLocation(); data.survivalFlyJumpPhase = 0; - } else if (from.isInLiquid() || to.isInLiquid() || from.isInWeb() || to.isInWeb() || from.isOnGround() - || to.isOnGround() || from.isOnLadder() || to.isOnLadder()) - // The player at least touched the ground somehow. - data.survivalFlyJumpPhase = 0; + } else { + if (from.isInLiquid() || from.isOnGround() || from.isInWeb() || from.isOnGround()) + data.setBack = from.getLocation(); + if (from.isInLiquid() || to.isInLiquid() || from.isInWeb() || to.isInWeb() || from.isOnGround() + || to.isOnGround() || from.isOnLadder() || to.isOnLadder()) + // The player at least touched the ground somehow. + data.survivalFlyJumpPhase = 0; + } if (noFall.isEnabled(player)) // Execute the NoFall check. diff --git a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java index 893f5026..1aa8b6a9 100644 --- a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java +++ b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java @@ -58,6 +58,7 @@ public abstract class ConfPaths { private static final String BLOCKBREAK_FASTBREAK = BLOCKBREAK + "fastbreak."; public static final String BLOCKBREAK_FASTBREAK_CHECK = BLOCKBREAK_FASTBREAK + "active"; + public static final String BLOCKBREAK_FASTBREAK_BUFFER = BLOCKBREAK_FASTBREAK + "buffer"; public static final String BLOCKBREAK_FASTBREAK_EXPERIMENTAL = BLOCKBREAK_FASTBREAK + "experimental"; public static final String BLOCKBREAK_FASTBREAK_INTERVAL = BLOCKBREAK_FASTBREAK + "interval"; public static final String BLOCKBREAK_FASTBREAK_ACTIONS = BLOCKBREAK_FASTBREAK + "actions"; @@ -83,11 +84,6 @@ public abstract class ConfPaths { public static final String BLOCKINTERACT_DIRECTION_CHECK = BLOCKINTERACT_DIRECTION + "active"; public static final String BLOCKINTERACT_DIRECTION_ACTIONS = BLOCKINTERACT_DIRECTION + "actions"; - private static final String BLOCKINTERACT_FASTINTERACT = BLOCKINTERACT + "fastinteract."; - public static final String BLOCKINTERACT_FASTINTERACT_CHECK = BLOCKINTERACT_FASTINTERACT + "active"; - public static final String BLOCKINTERACT_FASTINTERACT_INTERVAL = BLOCKINTERACT_FASTINTERACT + "interval"; - public static final String BLOCKINTERACT_FASTINTERACT_ACTIONS = BLOCKINTERACT_FASTINTERACT + "actions"; - private static final String BLOCKINTERACT_NOSWING = BLOCKINTERACT + "noswing."; public static final String BLOCKINTERACT_NOSWING_CHECK = BLOCKINTERACT_NOSWING + "active"; public static final String BLOCKINTERACT_NOSWING_ACTIONS = BLOCKINTERACT_NOSWING + "actions"; diff --git a/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java b/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java index 447af9ae..0b8b1c0c 100644 --- a/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java +++ b/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java @@ -60,6 +60,7 @@ public class DefaultConfig extends ConfigFile { set(ConfPaths.BLOCKBREAK_DIRECTION_ACTIONS, "cancel vl>10 log:bdirection:0:5:if cancel"); set(ConfPaths.BLOCKBREAK_FASTBREAK_CHECK, true); + set(ConfPaths.BLOCKBREAK_FASTBREAK_BUFFER, 5); set(ConfPaths.BLOCKBREAK_FASTBREAK_EXPERIMENTAL, true); set(ConfPaths.BLOCKBREAK_FASTBREAK_INTERVAL, 100); set(ConfPaths.BLOCKBREAK_FASTBREAK_ACTIONS, "cancel vl>100 log:fastinteract:3:5:cif cancel"); @@ -80,10 +81,6 @@ public class DefaultConfig extends ConfigFile { set(ConfPaths.BLOCKINTERACT_DIRECTION_CHECK, true); set(ConfPaths.BLOCKINTERACT_DIRECTION_ACTIONS, "cancel vl>10 log:bdirection:0:3:if cancel"); - set(ConfPaths.BLOCKINTERACT_FASTINTERACT_CHECK, true); - set(ConfPaths.BLOCKINTERACT_FASTINTERACT_INTERVAL, 95L); - set(ConfPaths.BLOCKINTERACT_FASTINTERACT_ACTIONS, "cancel vl>100 log:fastplace:3:5:cif cancel"); - set(ConfPaths.BLOCKINTERACT_NOSWING_CHECK, true); set(ConfPaths.BLOCKINTERACT_NOSWING_ACTIONS, "log:noswing:3:2:if cancel"); @@ -319,7 +316,6 @@ public class DefaultConfig extends ConfigFile { set(ConfPaths.STRINGS + ".critical", start + "tried to do a critical hit but wasn't technically jumping" + end); set(ConfPaths.STRINGS + ".drop", start + "tried to drop more items than allowed" + end); set(ConfPaths.STRINGS + ".fastbreak", start + "tried to break too much blocks" + end); - set(ConfPaths.STRINGS + ".fastinteract", start + "tried to interact with too much blocks" + end); set(ConfPaths.STRINGS + ".fastplace", start + "tried to place too much blocks" + end); set(ConfPaths.STRINGS + ".fdirection", start + "tried to hit an entity out of line of sight" + end); set(ConfPaths.STRINGS + ".flyshort", start + "tried to move unexpectedly" + end); diff --git a/src/fr/neatmonster/nocheatplus/players/Permissions.java b/src/fr/neatmonster/nocheatplus/players/Permissions.java index 55470fe0..7601322a 100644 --- a/src/fr/neatmonster/nocheatplus/players/Permissions.java +++ b/src/fr/neatmonster/nocheatplus/players/Permissions.java @@ -13,7 +13,7 @@ package fr.neatmonster.nocheatplus.players; * The various permission nodes used by NoCheatPlus. */ public class Permissions { - private static final String NOCHEATPLUS = "nocheatplus"; + private static final String NOCHEATPLUS = "nocheatplus"; /* * e Y8b 888 ,e, ,e, d8 d8 ,e, @@ -22,10 +22,10 @@ public class Permissions { * d888888888b Y888 888 888 888 888 888 888 888 888 Y88D 888 888 ,ee 888 888 888 Y888 888P 888 888 * d8888888b Y8b "88 888 888 888 888 888 888 888 888 d,dP 888 888 "88 888 888 888 "88 88" 888 888 */ - private static final String ADMINISTRATION = NOCHEATPLUS + ".admin"; - public static final String ADMINISTRATION_NOTIFY = ADMINISTRATION + ".notify"; - public static final String ADMINISTRATION_PLUGINS = ADMINISTRATION + ".plugins"; - public static final String ADMINISTRATION_RELOAD = ADMINISTRATION + ".reload"; + private static final String ADMINISTRATION = NOCHEATPLUS + ".admin"; + public static final String ADMINISTRATION_NOTIFY = ADMINISTRATION + ".notify"; + public static final String ADMINISTRATION_PLUGINS = ADMINISTRATION + ".plugins"; + public static final String ADMINISTRATION_RELOAD = ADMINISTRATION + ".reload"; /* * e e 888 ,e, dP,e, ,e, d8 ,e, @@ -34,36 +34,36 @@ public class Permissions { * d8b Y8b Y8b Y888 888P Y888 888 888 888 888 Y888 , ,ee 888 888 888 Y888 888P 888 888 Y88D * d888b Y8b Y8b "88 88" "88 888 888 888 888 "88,e8' "88 888 888 888 "88 88" 888 888 d,dP */ - private static final String MODS = NOCHEATPLUS + ".mods"; + private static final String MODS = NOCHEATPLUS + ".mods"; - private static final String CJB = MODS + ".cjb"; - public static final String CJB_FLY = CJB + ".fly"; - public static final String CJB_XRAY = CJB + ".xray"; - public static final String CJB_RADAR = CJB + ".radar"; + private static final String CJB = MODS + ".cjb"; + public static final String CJB_FLY = CJB + ".fly"; + public static final String CJB_XRAY = CJB + ".xray"; + public static final String CJB_RADAR = CJB + ".radar"; - private static final String MINECRAFTAUTOMAP = MODS + ".minecraftautomap"; - public static final String MINECRAFTAUTOMAP_ORES = MINECRAFTAUTOMAP + ".ores"; - public static final String MINECRAFTAUTOMAP_CAVE = MINECRAFTAUTOMAP + ".cave"; - public static final String MINECRAFTAUTOMAP_RADAR = MINECRAFTAUTOMAP + ".radar"; + private static final String MINECRAFTAUTOMAP = MODS + ".minecraftautomap"; + public static final String MINECRAFTAUTOMAP_ORES = MINECRAFTAUTOMAP + ".ores"; + public static final String MINECRAFTAUTOMAP_CAVE = MINECRAFTAUTOMAP + ".cave"; + public static final String MINECRAFTAUTOMAP_RADAR = MINECRAFTAUTOMAP + ".radar"; - private static final String REI = MODS + ".rei"; - public static final String REI_CAVE = REI + ".cave"; - public static final String REI_RADAR = REI + ".radar"; + private static final String REI = MODS + ".rei"; + public static final String REI_CAVE = REI + ".cave"; + public static final String REI_RADAR = REI + ".radar"; - private static final String SMARTMOVING = MODS + ".smartmoving"; - public static final String SMARTMOVING_CLIMBING = SMARTMOVING + ".climbing"; - public static final String SMARTMOVING_SWIMMING = SMARTMOVING + ".swimming"; - public static final String SMARTMOVING_CRAWLING = SMARTMOVING + ".crawling"; - public static final String SMARTMOVING_SLIDING = SMARTMOVING + ".sliding"; - public static final String SMARTMOVING_JUMPING = SMARTMOVING + ".jumping"; - public static final String SMARTMOVING_FLYING = SMARTMOVING + ".flying"; + private static final String SMARTMOVING = MODS + ".smartmoving"; + public static final String SMARTMOVING_CLIMBING = SMARTMOVING + ".climbing"; + public static final String SMARTMOVING_SWIMMING = SMARTMOVING + ".swimming"; + public static final String SMARTMOVING_CRAWLING = SMARTMOVING + ".crawling"; + public static final String SMARTMOVING_SLIDING = SMARTMOVING + ".sliding"; + public static final String SMARTMOVING_JUMPING = SMARTMOVING + ".jumping"; + public static final String SMARTMOVING_FLYING = SMARTMOVING + ".flying"; - private static final String ZOMBE = MODS + ".zombe"; - public static final String ZOMBE_FLY = ZOMBE + ".fly"; - public static final String ZOMBE_NOCLIP = ZOMBE + ".noclip"; - public static final String ZOMBE_CHEAT = ZOMBE + ".cheat"; + private static final String ZOMBE = MODS + ".zombe"; + public static final String ZOMBE_FLY = ZOMBE + ".fly"; + public static final String ZOMBE_NOCLIP = ZOMBE + ".noclip"; + public static final String ZOMBE_CHEAT = ZOMBE + ".cheat"; - private static final String CHECKS = NOCHEATPLUS + ".checks"; + private static final String CHECKS = NOCHEATPLUS + ".checks"; /* * 888 88b, 888 888 888 88b, 888 @@ -72,11 +72,11 @@ public class Permissions { * 888 88b, 888 Y888 888P Y888 , 888 b 888 88b, 888 888 , ,ee 888 888 b * 888 88P' 888 "88 88" "88,e8' 888 8b 888 88P' 888 "YeeP" "88 888 888 8b */ - private static final String BLOCKBREAK = CHECKS + ".blockbreak"; - public static final String BLOCKBREAK_DIRECTION = BLOCKBREAK + ".direction"; - public static final String BLOCKBREAK_FASTBREAK = BLOCKBREAK + ".fastbreak"; - public static final String BLOCKBREAK_NOSWING = BLOCKBREAK + ".noswing"; - public static final String BLOCKBREAK_REACH = BLOCKBREAK + ".reach"; + private static final String BLOCKBREAK = CHECKS + ".blockbreak"; + public static final String BLOCKBREAK_DIRECTION = BLOCKBREAK + ".direction"; + public static final String BLOCKBREAK_FASTBREAK = BLOCKBREAK + ".fastbreak"; + public static final String BLOCKBREAK_NOSWING = BLOCKBREAK + ".noswing"; + public static final String BLOCKBREAK_REACH = BLOCKBREAK + ".reach"; /* * 888 88b, 888 888 888 d8 d8 @@ -85,11 +85,10 @@ public class Permissions { * 888 88b, 888 Y888 888P Y888 , 888 b 888 888 888 888 888 , 888 ,ee 888 Y888 , 888 * 888 88P' 888 "88 88" "88,e8' 888 8b 888 888 888 888 "YeeP" 888 "88 888 "88,e8' 888 */ - private static final String BLOCKINTERACT = CHECKS + ".blockinteract"; - public static final String BLOCKINTERACT_DIRECTION = BLOCKINTERACT + ".direction"; - public static final String BLOCKINTERACT_FASTINTERACT = BLOCKINTERACT + ".fastinteract"; - public static final String BLOCKINTERACT_NOSWING = BLOCKINTERACT + ".noswing"; - public static final String BLOCKINTERACT_REACH = BLOCKINTERACT + ".reach"; + private static final String BLOCKINTERACT = CHECKS + ".blockinteract"; + public static final String BLOCKINTERACT_DIRECTION = BLOCKINTERACT + ".direction"; + public static final String BLOCKINTERACT_NOSWING = BLOCKINTERACT + ".noswing"; + public static final String BLOCKINTERACT_REACH = BLOCKINTERACT + ".reach"; /* * 888 88b, 888 888 888 88e 888 @@ -98,12 +97,12 @@ public class Permissions { * 888 88b, 888 Y888 888P Y888 , 888 b 888 888 ,ee 888 Y888 , 888 , * 888 88P' 888 "88 88" "88,e8' 888 8b 888 888 "88 888 "88,e8' "YeeP" */ - private static final String BLOCKPLACE = CHECKS + ".blockplace"; - public static final String BLOCKPLACE_DIRECTION = BLOCKPLACE + ".direction"; - public static final String BLOCKPLACE_FASTPLACE = BLOCKPLACE + ".fastplace"; - public static final String BLOCKPLACE_NOSWING = BLOCKPLACE + ".noswing"; - public static final String BLOCKPLACE_REACH = BLOCKPLACE + ".reach"; - public static final String BLOCKPLACE_SPEED = BLOCKPLACE + ".speed"; + private static final String BLOCKPLACE = CHECKS + ".blockplace"; + public static final String BLOCKPLACE_DIRECTION = BLOCKPLACE + ".direction"; + public static final String BLOCKPLACE_FASTPLACE = BLOCKPLACE + ".fastplace"; + public static final String BLOCKPLACE_NOSWING = BLOCKPLACE + ".noswing"; + public static final String BLOCKPLACE_REACH = BLOCKPLACE + ".reach"; + public static final String BLOCKPLACE_SPEED = BLOCKPLACE + ".speed"; /* * e88'Y88 888 d8 @@ -112,10 +111,10 @@ public class Permissions { * Y888 ,d 888 888 ,ee 888 888 * "88,d88 888 888 "88 888 888 */ - private static final String CHAT = CHECKS + ".chat"; - public static final String CHAT_ARRIVALS = CHAT + ".arrivals"; - public static final String CHAT_COLOR = CHAT + ".color"; - public static final String CHAT_NOPWNAGE = CHAT + ".nopwnage"; + private static final String CHAT = CHECKS + ".chat"; + public static final String CHAT_ARRIVALS = CHAT + ".arrivals"; + public static final String CHAT_COLOR = CHAT + ".color"; + public static final String CHAT_NOPWNAGE = CHAT + ".nopwnage"; /* * 888'Y88 ,e, 888 d8 @@ -126,16 +125,16 @@ public class Permissions { * , 88P * "8",P" */ - private static final String FIGHT = CHECKS + ".fight"; - public static final String FIGHT_ANGLE = FIGHT + ".angle"; - public static final String FIGHT_CRITICAL = FIGHT + ".critical"; - public static final String FIGHT_DIRECTION = FIGHT + ".direction"; - public static final String FIGHT_GODMODE = FIGHT + ".godmode"; - public static final String FIGHT_INSTANTHEAL = FIGHT + ".instantheal"; - public static final String FIGHT_KNOCKBACK = FIGHT + ".knockback"; - public static final String FIGHT_NOSWING = FIGHT + ".noswing"; - public static final String FIGHT_REACH = FIGHT + ".reach"; - public static final String FIGHT_SPEED = FIGHT + ".speed"; + private static final String FIGHT = CHECKS + ".fight"; + public static final String FIGHT_ANGLE = FIGHT + ".angle"; + public static final String FIGHT_CRITICAL = FIGHT + ".critical"; + public static final String FIGHT_DIRECTION = FIGHT + ".direction"; + public static final String FIGHT_GODMODE = FIGHT + ".godmode"; + public static final String FIGHT_INSTANTHEAL = FIGHT + ".instantheal"; + public static final String FIGHT_KNOCKBACK = FIGHT + ".knockback"; + public static final String FIGHT_NOSWING = FIGHT + ".noswing"; + public static final String FIGHT_REACH = FIGHT + ".reach"; + public static final String FIGHT_SPEED = FIGHT + ".speed"; /* * 888 d8 @@ -146,10 +145,10 @@ public class Permissions { * 888 * 888 */ - private static final String INVENTORY = CHECKS + ".inventory"; - public static final String INVENTORY_DROP = INVENTORY + ".drop"; - public static final String INVENTORY_INSTANTBOW = INVENTORY + ".instantbow"; - public static final String INVENTORY_INSTANTEAT = INVENTORY + ".instanteat"; + private static final String INVENTORY = CHECKS + ".inventory"; + public static final String INVENTORY_DROP = INVENTORY + ".drop"; + public static final String INVENTORY_INSTANTBOW = INVENTORY + ".instantbow"; + public static final String INVENTORY_INSTANTEAT = INVENTORY + ".instanteat"; /* * e e ,e, @@ -160,11 +159,11 @@ public class Permissions { * , 88P * "8",P" */ - private static final String MOVING = CHECKS + ".moving"; - public static final String MOVING_BOATSANYWHERE = MOVING + ".boatsanywhere"; - public static final String MOVING_CREATIVEFLY = MOVING + ".creativefly"; - public static final String MOVING_MOREPACKETS = MOVING + ".morepackets"; - public static final String MOVING_MOREPACKETSVEHICLE = MOVING + ".morepacketsvehicle"; - public static final String MOVING_NOFALL = MOVING + ".nofall"; - public static final String MOVING_SURVIVALFLY = MOVING + ".survivalfly"; + private static final String MOVING = CHECKS + ".moving"; + public static final String MOVING_BOATSANYWHERE = MOVING + ".boatsanywhere"; + public static final String MOVING_CREATIVEFLY = MOVING + ".creativefly"; + public static final String MOVING_MOREPACKETS = MOVING + ".morepackets"; + public static final String MOVING_MOREPACKETSVEHICLE = MOVING + ".morepacketsvehicle"; + public static final String MOVING_NOFALL = MOVING + ".nofall"; + public static final String MOVING_SURVIVALFLY = MOVING + ".survivalfly"; } diff --git a/src/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java b/src/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java index 013f482f..257f2ba2 100644 --- a/src/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java +++ b/src/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java @@ -268,7 +268,10 @@ public class PlayerLocation { */ public boolean isOnIce() { if (!onIce.isSet()) - onIce.set(world.getTypeId(x, y - 1, z) == Block.ICE.id); + if (entity.getBukkitEntity().isSneaking() || entity.getBukkitEntity().isBlocking()) + onIce.set(world.getTypeId(x, (int) Math.floor(boundingBox.b - 0.1D), z) == Block.ICE.id); + else + onIce.set(world.getTypeId(x, y - 1, z) == Block.ICE.id); return onIce.get(); }