mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 04:20:41 +00:00
[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:
parent
61b115ceac
commit
1d6ac42311
2 changed files with 20 additions and 4 deletions
|
@ -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"))
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue