diff --git a/src/cc/co/evenprime/bukkit/nocheat/NoCheatPlayer.java b/src/cc/co/evenprime/bukkit/nocheat/NoCheatPlayer.java index 0cd73747..0e72e0dd 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/NoCheatPlayer.java +++ b/src/cc/co/evenprime/bukkit/nocheat/NoCheatPlayer.java @@ -15,6 +15,8 @@ public interface NoCheatPlayer { public BaseData getData(); + public boolean isSprinting(); + public int getTicksLived(); public void increaseAge(int ticks); @@ -22,4 +24,6 @@ public interface NoCheatPlayer { public ConfigurationCache getConfiguration(); public float getSpeedAmplifier(); + + public boolean isCreative(); } diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/CheckUtil.java b/src/cc/co/evenprime/bukkit/nocheat/checks/CheckUtil.java index d9e50513..91c29e46 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/CheckUtil.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/CheckUtil.java @@ -5,7 +5,6 @@ import net.minecraft.server.Block; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; -import org.bukkit.entity.Player; import org.bukkit.util.Vector; import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer; @@ -108,11 +107,6 @@ public class CheckUtil { types[Material.TRAP_DOOR.getId()] |= SOLID | NONSOLID; } - public static final boolean isSprinting(final Player player) { - - return !(player.isSprinting() && player.getFoodLevel() > 5); - } - /** * Check if certain coordinates are considered "on ground" * diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/ReachCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/ReachCheck.java index 29ba485d..5817d6f2 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/ReachCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/ReachCheck.java @@ -2,8 +2,6 @@ package cc.co.evenprime.bukkit.nocheat.checks.blockbreak; import java.util.Locale; -import org.bukkit.GameMode; - import cc.co.evenprime.bukkit.nocheat.NoCheat; import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer; import cc.co.evenprime.bukkit.nocheat.actions.types.ActionWithParameters.WildCard; @@ -31,7 +29,7 @@ public class ReachCheck extends BlockBreakCheck { final SimpleLocation brokenBlock = data.brokenBlockLocation; - final double distance = CheckUtil.reachCheck(player, brokenBlock.x + 0.5D, brokenBlock.y + 0.5D, brokenBlock.z + 0.5D, player.getPlayer().getGameMode() == GameMode.CREATIVE ? cc.reachDistance + 2 : cc.reachDistance); + final double distance = CheckUtil.reachCheck(player, brokenBlock.x + 0.5D, brokenBlock.y + 0.5D, brokenBlock.z + 0.5D, player.isCreative() ? cc.reachDistance + 2 : cc.reachDistance); if(distance > 0D) { // Player failed the check 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 339dd404..a548bd59 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/FlyingCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/FlyingCheck.java @@ -2,8 +2,6 @@ package cc.co.evenprime.bukkit.nocheat.checks.moving; import java.util.Locale; -import org.bukkit.GameMode; - import cc.co.evenprime.bukkit.nocheat.NoCheat; import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer; import cc.co.evenprime.bukkit.nocheat.actions.types.ActionWithParameters.WildCard; @@ -48,14 +46,14 @@ public class FlyingCheck extends MovingCheck { // In case of creative gamemode, give at least 0.60 speed limit // horizontal - double speedLimitHorizontal = player.getPlayer().getGameMode() == GameMode.CREATIVE ? Math.max(creativeSpeed, ccmoving.flyingSpeedLimitHorizontal) : ccmoving.flyingSpeedLimitHorizontal; + double speedLimitHorizontal = player.isCreative() ? Math.max(creativeSpeed, ccmoving.flyingSpeedLimitHorizontal) : ccmoving.flyingSpeedLimitHorizontal; speedLimitHorizontal *= player.getSpeedAmplifier(); result += Math.max(0.0D, horizontalDistance - moving.horizFreedom - speedLimitHorizontal); - boolean sprinting = player.getPlayer().isSprinting(); + boolean sprinting = player.isSprinting(); moving.bunnyhopdelay--; diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/RunflyCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/RunflyCheck.java index caf0fedc..cc75c6f1 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/RunflyCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/RunflyCheck.java @@ -1,7 +1,5 @@ package cc.co.evenprime.bukkit.nocheat.checks.moving; -import org.bukkit.GameMode; - import cc.co.evenprime.bukkit.nocheat.NoCheat; import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer; import cc.co.evenprime.bukkit.nocheat.checks.MovingCheck; @@ -26,7 +24,7 @@ public class RunflyCheck extends MovingCheck { public PreciseLocation check(NoCheatPlayer player, MovingData data, CCMoving cc) { final boolean runflyCheck = cc.runflyCheck && !player.hasPermission(Permissions.MOVING_RUNFLY); - final boolean flyAllowed = cc.allowFlying || player.hasPermission(Permissions.MOVING_FLYING) || (player.getPlayer().getGameMode() == GameMode.CREATIVE && cc.identifyCreativeMode); + final boolean flyAllowed = cc.allowFlying || player.hasPermission(Permissions.MOVING_FLYING) || (player.isCreative() && cc.identifyCreativeMode); /********************* EXECUTE THE FLY/JUMP/RUNNING CHECK ********************/ // If the player is not allowed to fly and not allowed to run diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/RunningCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/RunningCheck.java index 4fd5afcc..20f20b82 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/RunningCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/RunningCheck.java @@ -125,7 +125,7 @@ public class RunningCheck extends MovingCheck { // How much further did the player move than expected?? double distanceAboveLimit = 0.0D; - final boolean sprinting = player.getPlayer().isSprinting(); + final boolean sprinting = player.isSprinting(); double limit = 0.0D; diff --git a/src/cc/co/evenprime/bukkit/nocheat/player/NoCheatPlayerImpl.java b/src/cc/co/evenprime/bukkit/nocheat/player/NoCheatPlayerImpl.java index c76eeb48..92adb880 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/player/NoCheatPlayerImpl.java +++ b/src/cc/co/evenprime/bukkit/nocheat/player/NoCheatPlayerImpl.java @@ -4,6 +4,7 @@ import net.minecraft.server.EntityPlayer; import net.minecraft.server.MobEffectList; import org.bukkit.Bukkit; +import org.bukkit.GameMode; import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -70,6 +71,10 @@ public class NoCheatPlayerImpl implements NoCheatPlayer { } } + public boolean isSprinting() { + return player.isSprinting() && player.getFoodLevel() > 5; + } + public void setLastUsedTime(long currentTimeInMilliseconds) { this.lastUsedTime = System.currentTimeMillis(); } @@ -77,4 +82,8 @@ public class NoCheatPlayerImpl implements NoCheatPlayer { public boolean shouldBeRemoved(long currentTimeInMilliseconds) { return lastUsedTime + 60000L < currentTimeInMilliseconds; } + + public boolean isCreative() { + return player.getGameMode().equals(GameMode.CREATIVE); + } }