diff options
author | KHobbits <rob@khobbits.co.uk> | 2013-03-19 22:55:00 +0000 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2013-03-19 22:55:00 +0000 |
commit | c3979b1c282c66ce2524e5b63fcd9d4ed1f5b17f (patch) | |
tree | a47a44d331f41d5ab0d084d689c00308a4d69078 /Essentials/src/com/earth2me/essentials/commands/Commandspeed.java | |
parent | 76f49e1247ca7abdc1803ddea9f5e182c8a107cd (diff) | |
download | Essentials-c3979b1c282c66ce2524e5b63fcd9d4ed1f5b17f.tar Essentials-c3979b1c282c66ce2524e5b63fcd9d4ed1f5b17f.tar.gz Essentials-c3979b1c282c66ce2524e5b63fcd9d4ed1f5b17f.tar.lz Essentials-c3979b1c282c66ce2524e5b63fcd9d4ed1f5b17f.tar.xz Essentials-c3979b1c282c66ce2524e5b63fcd9d4ed1f5b17f.zip |
[Fix] Reset walk/fly speed on login.
[Permission] essentials.speed.<fly|walk> - If a player only has one of these, they will only be able to toggle the given state.
Diffstat (limited to 'Essentials/src/com/earth2me/essentials/commands/Commandspeed.java')
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandspeed.java | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspeed.java b/Essentials/src/com/earth2me/essentials/commands/Commandspeed.java index c7b44dc68..f95caeafb 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandspeed.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspeed.java @@ -39,12 +39,12 @@ public class Commandspeed extends EssentialsCommand boolean isBypass = user.isAuthorized("essentials.speed.bypass"); if (args.length == 1) { - isFly = user.isFlying(); + isFly = flyPermCheck(user, user.isFlying()); speed = getMoveSpeed(args[0]); } else { - isFly = isFlyMode(args[0]); + isFly = flyPermCheck(user, isFlyMode(args[0])); speed = getMoveSpeed(args[1]); if (args.length > 2 && user.isAuthorized("essentials.speed.others")) { @@ -52,7 +52,7 @@ public class Commandspeed extends EssentialsCommand return; } } - + if (isFly) { user.setFlySpeed(getRealMoveSpeed(speed, isFly, isBypass)); @@ -81,6 +81,19 @@ public class Commandspeed extends EssentialsCommand } } } + + private Boolean flyPermCheck(User user, boolean input) throws Exception + { + boolean canFly = user.isAuthorized("essentials.speed.fly"); + boolean canWalk = user.isAuthorized("essentials.speed.walk"); + if (input && canFly || !input && canWalk || !canFly && !canWalk) { + return input; + } + else if (canWalk) { + return false; + } + return true; + } private boolean isFlyMode(final String modeString) throws NotEnoughArgumentsException { |