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 | 1d6ac42311b1abab8fd683cb3036390634a01bbc (patch) | |
tree | 0b84024efa3023142103bbc62e779acbe45d20a3 | |
parent | 61b115ceac3aa26dfbf07221802469ae492c5552 (diff) | |
download | Essentials-1d6ac42311b1abab8fd683cb3036390634a01bbc.tar Essentials-1d6ac42311b1abab8fd683cb3036390634a01bbc.tar.gz Essentials-1d6ac42311b1abab8fd683cb3036390634a01bbc.tar.lz Essentials-1d6ac42311b1abab8fd683cb3036390634a01bbc.tar.xz Essentials-1d6ac42311b1abab8fd683cb3036390634a01bbc.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.
-rw-r--r-- | Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java | 5 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandspeed.java | 19 |
2 files changed, 20 insertions, 4 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 7280e65e2..c378841b1 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -262,6 +262,9 @@ public class EssentialsPlayerListener implements Listener user.sendMessage(_("flyMode", _("enabled"), user.getDisplayName())); } } + user.setFlySpeed(0.1f); + user.setWalkSpeed(0.2f); + } }); } @@ -397,7 +400,7 @@ public class EssentialsPlayerListener implements Listener } @EventHandler(priority = EventPriority.NORMAL) - public void onPlayerChangedWorldHack(final PlayerChangedWorldEvent event) + public void onPlayerChangedWorldFlyReset(final PlayerChangedWorldEvent event) { final User user = ess.getUser(event.getPlayer()); if (user.getGameMode() != GameMode.CREATIVE && !user.isAuthorized("essentials.fly")) 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 { |