From a7e0069595e181880efce8d1bca0854384ed3118 Mon Sep 17 00:00:00 2001 From: asofold Date: Mon, 1 Oct 2012 03:51:56 +0200 Subject: [PATCH] Hack for cobwebs. Add permission for placing blocks against fluids. --- plugin.yml | 5 +++++ .../checks/moving/MovingConfig.java | 2 ++ .../nocheatplus/checks/moving/MovingData.java | 2 ++ .../checks/moving/MovingListener.java | 2 +- .../checks/moving/SurvivalFly.java | 22 +++++++++++++++---- .../nocheatplus/config/ConfPaths.java | 1 + .../nocheatplus/players/Permissions.java | 4 +++- 7 files changed, 32 insertions(+), 6 deletions(-) diff --git a/plugin.yml b/plugin.yml index f297cd02..16327524 100644 --- a/plugin.yml +++ b/plugin.yml @@ -94,6 +94,11 @@ permissions: nocheatplus.checks.blockplace: description: Allow the player to bypass all BlockPlace checks. children: + nocheatplus.checks.blockplace.against: + description: Allow the player to place blocks against other blocks. + children: + nocheatplus.checks.blockplace.against.liquids: + description: Allow the player to place blocks against liquids. nocheatplus.checks.blockplace.direction: description: Allow the player to bypass to Direction check. nocheatplus.checks.blockplace.fastplace: diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java b/src/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java index 3cb43f0a..3482bf1b 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java @@ -91,6 +91,7 @@ public class MovingConfig extends ACheckConfig { public final int survivalFlySprintingSpeed; public final int survivalFlySwimmingSpeed; public final int survivalFlyWalkingSpeed; + public final boolean survivalFlyCobwebHack; public final ActionList survivalFlyActions; // Special tolerance values: @@ -136,6 +137,7 @@ public class MovingConfig extends ACheckConfig { survivalFlySprintingSpeed = data.getInt(ConfPaths.MOVING_SURVIVALFLY_SPRINTINGSPEED, 100); survivalFlySwimmingSpeed = data.getInt(ConfPaths.MOVING_SURVIVALFLY_SWIMMINGSPEED, 100); survivalFlyWalkingSpeed = data.getInt(ConfPaths.MOVING_SURVIVALFLY_WALKINGSPEED, 100); + survivalFlyCobwebHack = data.getBoolean(ConfPaths.MOVING_SURVIVALFLY_COBWEBHACK, true); survivalFlyActions = data.getActionList(ConfPaths.MOVING_SURVIVALFLY_ACTIONS, Permissions.MOVING_SURVIVALFLY); yOnGround = data.getDouble(ConfPaths.MOVING_YONGROUND, 0.001, 2.0, 0.001); diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/MovingData.java b/src/fr/neatmonster/nocheatplus/checks/moving/MovingData.java index d31abdf0..658dc6e6 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/MovingData.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/MovingData.java @@ -113,6 +113,8 @@ public class MovingData extends ACheckData { public double survivalFlyLastFromY; public int survivalFlyOnIce; public boolean survivalFlyWasInBed; + public long survivalFlyCobwebTime; + public double survivalFlyCobwebVL; // Locations shared between all checks. public final PlayerLocation from = new PlayerLocation(); diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java b/src/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java index d340a3bf..3a5416fb 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java @@ -113,7 +113,7 @@ public class MovingListener implements Listener { final Material mat = block.getType(); if (BlockProperties.isLiquid(event.getBlockAgainst().getTypeId()) - && mat != Material.WATER_LILY) + && mat != Material.WATER_LILY && !player.hasPermission(Permissions.BLOCKPLACE_AGAINST_LIQUIDS)) // The block was placed against a liquid block, cancel its // placement. event.setCancelled(true); diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java b/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java index d9f9905e..ebbd5fab 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java @@ -42,7 +42,7 @@ public class SurvivalFly extends Check { public static final double blockingSpeed = 0.16D; public static final double swimmingSpeed = 0.11D; - public static final double webSpeed = walkingSpeed * 0.15D; + public static final double webSpeed = 0.105D; // TODO: walkingSpeed * 0.15D; <- does not work public static final double modIce = 2.5D; @@ -223,10 +223,22 @@ public class SurvivalFly extends Check { double vAllowedDistance, vDistanceAboveLimit; if (from.isInWeb()){ // Very simple: force players to descend or stay. - vAllowedDistance = 0; + vAllowedDistance = from.isOnGround() ? 0.1D : 0; data.jumpAmplifier = 0; - final double vy = player.getVelocity().getY(); - vDistanceAboveLimit = vy; + vDistanceAboveLimit = to.getY() - from.getY(); + if (cc.survivalFlyCobwebHack && vDistanceAboveLimit > 0 && hDistanceAboveLimit <= 0){ + final long now = System.currentTimeMillis(); + if (now - data.survivalFlyCobwebTime > 3000){ + data.survivalFlyCobwebTime = now; + data.survivalFlyCobwebVL = vDistanceAboveLimit * 100D; + } + else data.survivalFlyCobwebVL += vDistanceAboveLimit * 100D; + if (data.survivalFlyCobwebVL < 325) { // Totally random ! + if (data.setBack == null) data.setBack = player.getLocation(); + data.survivalFlyJumpPhase = 0; + return data.setBack; + } + } } else{ vAllowedDistance = (!fromOnGround && !toOnGround ? 1.45D : 1.35D) + data.verticalFreedom; @@ -257,6 +269,8 @@ public class SurvivalFly extends Check { data.survivalFlyVL *= 0.95D; // System.out.println("vertical freedom: " + data.verticalFreedom + " ("+data.verticalVelocity+"/"+data.verticalVelocityCounter+")"); // Did the player move in unexpected ways? +// System.out.println("hDist: " + hDistance + " / " + hAllowedDistance + " , vDist: " + (to.getY() - from.getY()) + " ("+player.getVelocity().getY()+")" + " / " + vAllowedDistance + " / from passable: " + BlockProperties.isPassable(from)); +// System.out.println(from.getY() +"(" + player.getLocation().getY() + ") -> " + to.getY()) ; if (result > 0D) { // Increment violation counter. data.survivalFlyVL += result; diff --git a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java index 8362ed99..ceb047a6 100644 --- a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java +++ b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java @@ -463,6 +463,7 @@ public abstract class ConfPaths { public static final String MOVING_SURVIVALFLY_SPRINTINGSPEED = MOVING_SURVIVALFLY + "sprintingspeed"; public static final String MOVING_SURVIVALFLY_SWIMMINGSPEED = MOVING_SURVIVALFLY + "swimmingspeed"; public static final String MOVING_SURVIVALFLY_WALKINGSPEED = MOVING_SURVIVALFLY + "walkingspeed"; + public static final String MOVING_SURVIVALFLY_COBWEBHACK = MOVING_SURVIVALFLY + "cobwebhack"; public static final String MOVING_SURVIVALFLY_ACTIONS = MOVING_SURVIVALFLY + "actions"; // Special (to be sorted in or factored out). diff --git a/src/fr/neatmonster/nocheatplus/players/Permissions.java b/src/fr/neatmonster/nocheatplus/players/Permissions.java index fa1c7711..67a780fa 100644 --- a/src/fr/neatmonster/nocheatplus/players/Permissions.java +++ b/src/fr/neatmonster/nocheatplus/players/Permissions.java @@ -88,6 +88,8 @@ public class Permissions { * 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_AGAINST = BLOCKPLACE + ".against"; + public static final String BLOCKPLACE_AGAINST_LIQUIDS = BLOCKPLACE_AGAINST + ".liquids"; public static final String BLOCKPLACE_DIRECTION = BLOCKPLACE + ".direction"; public static final String BLOCKPLACE_FASTPLACE = BLOCKPLACE + ".fastplace"; public static final String BLOCKPLACE_NOSWING = BLOCKPLACE + ".noswing"; @@ -211,5 +213,5 @@ public class Permissions { public static final String ZOMBE_FLY = ZOMBE + ".fly"; public static final String ZOMBE_NOCLIP = ZOMBE + ".noclip"; public static final String ZOMBE_CHEAT = ZOMBE + ".cheat"; - + }