mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-28 03:17:53 +01:00
Players that are in creative mode are always allowed to fly with
default "creative-mode-speed".
This commit is contained in:
parent
3943812b8c
commit
3e344be924
@ -3,6 +3,7 @@ package cc.co.evenprime.bukkit.nocheat.checks.moving;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -24,6 +25,8 @@ import cc.co.evenprime.bukkit.nocheat.data.MovingData;
|
||||
public class FlyingCheck {
|
||||
|
||||
private final ActionExecutor action;
|
||||
|
||||
private static final double creativeSpeed = 0.60D;
|
||||
|
||||
public FlyingCheck(NoCheat plugin) {
|
||||
this.action = new ActionExecutorWithHistory(plugin);
|
||||
@ -44,11 +47,14 @@ public class FlyingCheck {
|
||||
|
||||
double result = 0;
|
||||
Location newToLocation = null;
|
||||
|
||||
// In case of creative gamemode, give at least 0.60 speed limit horizontal
|
||||
final double speedLimitHorizontal = player.getGameMode() == GameMode.CREATIVE ? Math.max(creativeSpeed, cc.moving.flyingSpeedLimitHorizontal) : cc.moving.flyingSpeedLimitHorizontal;
|
||||
|
||||
// super simple, just check distance compared to max distance
|
||||
result += Math.max(0.0D, yDistance - data.vertFreedom - cc.moving.flyingSpeedLimitVertical);
|
||||
result += Math.max(0.0D, horizontalDistance - data.horizFreedom - cc.moving.flyingSpeedLimitHorizontal);
|
||||
|
||||
result += Math.max(0.0D, horizontalDistance - data.horizFreedom - speedLimitHorizontal);
|
||||
|
||||
result = result * 100;
|
||||
|
||||
if(result > 0) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.checks.moving;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -69,7 +70,7 @@ public class MovingCheck {
|
||||
|
||||
/************* DECIDE WHICH CHECKS NEED TO BE RUN *************/
|
||||
final boolean flyCheck = cc.moving.flyingCheck && !player.hasPermission(Permissions.MOVE_FLY);
|
||||
final boolean runCheck = cc.moving.runningCheck && !player.hasPermission(Permissions.MOVE_RUN);
|
||||
final boolean runCheck = cc.moving.runningCheck && !player.hasPermission(Permissions.MOVE_RUN) && player.getGameMode() != GameMode.CREATIVE;
|
||||
final boolean morepacketsCheck = cc.moving.morePacketsCheck && !player.hasPermission(Permissions.MOVE_MOREPACKETS);
|
||||
final boolean noclipCheck = cc.moving.noclipCheck && !player.hasPermission(Permissions.MOVE_NOCLIP);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user