From c7b85f9faad2ffe8305af6bba2f2c61a68bc5126 Mon Sep 17 00:00:00 2001 From: asofold Date: Tue, 16 Jul 2013 00:22:45 +0200 Subject: [PATCH] Flying permissions: survivalfly is now child of creativefly. --- .../checks/moving/MovingListener.java | 58 +++++-------------- NCPPlugin/src/main/resources/plugin.yml | 2 + 2 files changed, 17 insertions(+), 43 deletions(-) diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java index ed80ebb4..f5848bdb 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java @@ -100,19 +100,15 @@ import fr.neatmonster.nocheatplus.utilities.build.BuildParameters; public class MovingListener extends CheckListener implements TickListener, IRemoveData, IHaveCheckType, INotifyReload, INeedConfig, JoinLeaveListener{ /** - * Heavier check, but convenient for seldom events (not for use in the player-move check). + * Check if the player is to be checked by the survivalfly check. * @param player * @param data * @param cc * @return */ public static final boolean shouldCheckSurvivalFly(final Player player, final MovingData data, final MovingConfig cc){ - if (player.hasPermission(Permissions.MOVING_CREATIVEFLY)) return false; - else if (!cc.survivalFlyCheck || NCPExemptionManager.isExempted(player, CheckType.MOVING_SURVIVALFLY) || player.hasPermission(Permissions.MOVING_SURVIVALFLY)) return false; - else if ((cc.ignoreCreative || player.getGameMode() != GameMode.CREATIVE) && !player.isFlying() && (cc.ignoreAllowFlight || !player.getAllowFlight())){ - return true; - } - else return false; + return cc.survivalFlyCheck && !NCPExemptionManager.isExempted(player, CheckType.MOVING_SURVIVALFLY) && !player.hasPermission(Permissions.MOVING_SURVIVALFLY) && + (cc.ignoreCreative || player.getGameMode() != GameMode.CREATIVE) && !player.isFlying() && (cc.ignoreAllowFlight || !player.getAllowFlight()); } /** @@ -518,22 +514,6 @@ public class MovingListener extends CheckListener implements TickListener, IRemo // TODO: Rework to queued velocity entries: activation + invalidation data.removeInvalidVelocity(TickTask.getTick() - cc.velocityActivationTicks); data.velocityTick(); -// // Horizontal velocity. -// if (data.horizontalVelocityCounter > 0D){ -// data.horizontalVelocityUsed ++; -// data.horizontalVelocityCounter--; -// data.horizontalFreedom = Math.max(0.0, data.horizontalFreedom - 0.09); -// } -// else if (data.horizontalFreedom > 0.001D){ -// if (data.verticalVelocityUsed == 1 && data.verticalVelocity > 0.5){ -// data.horizontalVelocityUsed = 0; -// data.horizontalFreedom = 0; -// } -// else{ -// data.horizontalVelocityUsed ++; -// data.horizontalFreedom *= 0.90D; -// } -// } // Vertical velocity. if (data.verticalVelocity <= 0.09D){ data.verticalVelocityUsed ++; @@ -575,28 +555,20 @@ public class MovingListener extends CheckListener implements TickListener, IRemo } } - // Check which fly check to check. + // Check which fly check to use. final boolean checkCf; final boolean checkSf; - if (player.hasPermission(Permissions.MOVING_CREATIVEFLY)){ - // TODO: Handle this by setting sf perm as child! - checkCf = checkSf = false; - } - else{ - if ((cc.ignoreCreative || player.getGameMode() != GameMode.CREATIVE) && !player.isFlying() && (cc.ignoreAllowFlight || !player.getAllowFlight()) - && cc.survivalFlyCheck && !NCPExemptionManager.isExempted(player, CheckType.MOVING_SURVIVALFLY) && !player.hasPermission(Permissions.MOVING_SURVIVALFLY)){ - checkCf = false; - checkSf = true; - } - else if (cc.creativeFlyCheck && !NCPExemptionManager.isExempted(player, CheckType.MOVING_CREATIVEFLY)){ - checkCf = true; - checkSf = false; - } - else{ - checkCf = checkSf = false; - } - - } + if (shouldCheckSurvivalFly(player, data, cc)){ + checkCf = false; + checkSf = true; + } + else if (cc.creativeFlyCheck && !NCPExemptionManager.isExempted(player, CheckType.MOVING_CREATIVEFLY) && !player.hasPermission(Permissions.MOVING_CREATIVEFLY)){ + checkCf = true; + checkSf = false; + } + else{ + checkCf = checkSf = false; + } // Flying checks. if (checkSf){ diff --git a/NCPPlugin/src/main/resources/plugin.yml b/NCPPlugin/src/main/resources/plugin.yml index 58a8c59a..fd7414dc 100644 --- a/NCPPlugin/src/main/resources/plugin.yml +++ b/NCPPlugin/src/main/resources/plugin.yml @@ -207,6 +207,8 @@ permissions: children: nocheatplus.checks.moving.creativefly: description: Allow the player to bypass the CreativeFly check. + children: + nocheatplus.checks.moving.survivalfly: true nocheatplus.checks.moving.morepackets: description: Allow the player to bypass the MorePackets check. nocheatplus.checks.moving.morepacketsvehicle: