mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-29 03:48:50 +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.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -25,6 +26,8 @@ public class FlyingCheck {
|
|||||||
|
|
||||||
private final ActionExecutor action;
|
private final ActionExecutor action;
|
||||||
|
|
||||||
|
private static final double creativeSpeed = 0.60D;
|
||||||
|
|
||||||
public FlyingCheck(NoCheat plugin) {
|
public FlyingCheck(NoCheat plugin) {
|
||||||
this.action = new ActionExecutorWithHistory(plugin);
|
this.action = new ActionExecutorWithHistory(plugin);
|
||||||
}
|
}
|
||||||
@ -45,9 +48,12 @@ public class FlyingCheck {
|
|||||||
double result = 0;
|
double result = 0;
|
||||||
Location newToLocation = null;
|
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
|
// 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, 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;
|
result = result * 100;
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.checks.moving;
|
package cc.co.evenprime.bukkit.nocheat.checks.moving;
|
||||||
|
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -69,7 +70,7 @@ public class MovingCheck {
|
|||||||
|
|
||||||
/************* DECIDE WHICH CHECKS NEED TO BE RUN *************/
|
/************* DECIDE WHICH CHECKS NEED TO BE RUN *************/
|
||||||
final boolean flyCheck = cc.moving.flyingCheck && !player.hasPermission(Permissions.MOVE_FLY);
|
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 morepacketsCheck = cc.moving.morePacketsCheck && !player.hasPermission(Permissions.MOVE_MOREPACKETS);
|
||||||
final boolean noclipCheck = cc.moving.noclipCheck && !player.hasPermission(Permissions.MOVE_NOCLIP);
|
final boolean noclipCheck = cc.moving.noclipCheck && !player.hasPermission(Permissions.MOVE_NOCLIP);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user