Players that are in creative mode are always allowed to fly with

default "creative-mode-speed".
This commit is contained in:
Evenprime 2011-09-16 16:05:42 +02:00
parent 3943812b8c
commit 3e344be924
2 changed files with 10 additions and 3 deletions

View File

@ -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;
@ -25,6 +26,8 @@ public class FlyingCheck {
private final ActionExecutor action;
private static final double creativeSpeed = 0.60D;
public FlyingCheck(NoCheat plugin) {
this.action = new ActionExecutorWithHistory(plugin);
}
@ -45,9 +48,12 @@ 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;

View File

@ -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);