[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.
This commit is contained in:
KHobbits 2013-03-19 22:55:00 +00:00
parent 61b115ceac
commit 1d6ac42311
2 changed files with 20 additions and 4 deletions

View File

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

View File

@ -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
{