mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-02 13:57:49 +01:00
Simpler access to isSprinting() and getGameMode()
This commit is contained in:
parent
c5806da644
commit
fb5225fac5
@ -15,6 +15,8 @@ public interface NoCheatPlayer {
|
|||||||
|
|
||||||
public BaseData getData();
|
public BaseData getData();
|
||||||
|
|
||||||
|
public boolean isSprinting();
|
||||||
|
|
||||||
public int getTicksLived();
|
public int getTicksLived();
|
||||||
|
|
||||||
public void increaseAge(int ticks);
|
public void increaseAge(int ticks);
|
||||||
@ -22,4 +24,6 @@ public interface NoCheatPlayer {
|
|||||||
public ConfigurationCache getConfiguration();
|
public ConfigurationCache getConfiguration();
|
||||||
|
|
||||||
public float getSpeedAmplifier();
|
public float getSpeedAmplifier();
|
||||||
|
|
||||||
|
public boolean isCreative();
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import net.minecraft.server.Block;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
||||||
@ -108,11 +107,6 @@ public class CheckUtil {
|
|||||||
types[Material.TRAP_DOOR.getId()] |= SOLID | NONSOLID;
|
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"
|
* Check if certain coordinates are considered "on ground"
|
||||||
*
|
*
|
||||||
|
@ -2,8 +2,6 @@ package cc.co.evenprime.bukkit.nocheat.checks.blockbreak;
|
|||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
||||||
import cc.co.evenprime.bukkit.nocheat.actions.types.ActionWithParameters.WildCard;
|
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 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) {
|
if(distance > 0D) {
|
||||||
// Player failed the check
|
// Player failed the check
|
||||||
|
@ -2,8 +2,6 @@ package cc.co.evenprime.bukkit.nocheat.checks.moving;
|
|||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
||||||
import cc.co.evenprime.bukkit.nocheat.actions.types.ActionWithParameters.WildCard;
|
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
|
// In case of creative gamemode, give at least 0.60 speed limit
|
||||||
// horizontal
|
// 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();
|
speedLimitHorizontal *= player.getSpeedAmplifier();
|
||||||
|
|
||||||
result += Math.max(0.0D, horizontalDistance - moving.horizFreedom - speedLimitHorizontal);
|
result += Math.max(0.0D, horizontalDistance - moving.horizFreedom - speedLimitHorizontal);
|
||||||
|
|
||||||
boolean sprinting = player.getPlayer().isSprinting();
|
boolean sprinting = player.isSprinting();
|
||||||
|
|
||||||
moving.bunnyhopdelay--;
|
moving.bunnyhopdelay--;
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.checks.moving;
|
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.NoCheat;
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
||||||
import cc.co.evenprime.bukkit.nocheat.checks.MovingCheck;
|
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) {
|
public PreciseLocation check(NoCheatPlayer player, MovingData data, CCMoving cc) {
|
||||||
|
|
||||||
final boolean runflyCheck = cc.runflyCheck && !player.hasPermission(Permissions.MOVING_RUNFLY);
|
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 ********************/
|
/********************* EXECUTE THE FLY/JUMP/RUNNING CHECK ********************/
|
||||||
// If the player is not allowed to fly and not allowed to run
|
// If the player is not allowed to fly and not allowed to run
|
||||||
|
@ -125,7 +125,7 @@ public class RunningCheck extends MovingCheck {
|
|||||||
// How much further did the player move than expected??
|
// How much further did the player move than expected??
|
||||||
double distanceAboveLimit = 0.0D;
|
double distanceAboveLimit = 0.0D;
|
||||||
|
|
||||||
final boolean sprinting = player.getPlayer().isSprinting();
|
final boolean sprinting = player.isSprinting();
|
||||||
|
|
||||||
double limit = 0.0D;
|
double limit = 0.0D;
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import net.minecraft.server.EntityPlayer;
|
|||||||
import net.minecraft.server.MobEffectList;
|
import net.minecraft.server.MobEffectList;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
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) {
|
public void setLastUsedTime(long currentTimeInMilliseconds) {
|
||||||
this.lastUsedTime = System.currentTimeMillis();
|
this.lastUsedTime = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
@ -77,4 +82,8 @@ public class NoCheatPlayerImpl implements NoCheatPlayer {
|
|||||||
public boolean shouldBeRemoved(long currentTimeInMilliseconds) {
|
public boolean shouldBeRemoved(long currentTimeInMilliseconds) {
|
||||||
return lastUsedTime + 60000L < currentTimeInMilliseconds;
|
return lastUsedTime + 60000L < currentTimeInMilliseconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCreative() {
|
||||||
|
return player.getGameMode().equals(GameMode.CREATIVE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user