Allow syntax: /fly <player> <on/off>

This commit is contained in:
KHobbits 2012-06-10 19:11:45 +01:00
parent 24ec242ecf
commit c958bc78dd

View File

@ -24,7 +24,7 @@ public class Commandfly extends EssentialsCommand
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
flyOtherPlayers(server, sender, args[0]); flyOtherPlayers(server, sender, args);
} }
@Override @Override
@ -32,7 +32,7 @@ public class Commandfly extends EssentialsCommand
{ {
if (args.length > 0 && args[0].trim().length() > 2 && user.isAuthorized("essentials.fly.others")) if (args.length > 0 && args[0].trim().length() > 2 && user.isAuthorized("essentials.fly.others"))
{ {
flyOtherPlayers(server, user, args[0]); flyOtherPlayers(server, user, args);
return; return;
} }
user.setAllowFlight(!user.getAllowFlight()); user.setAllowFlight(!user.getAllowFlight());
@ -43,16 +43,32 @@ public class Commandfly extends EssentialsCommand
user.sendMessage(_("flyMode", _(user.getAllowFlight() ? "enabled" : "disabled"), user.getDisplayName())); user.sendMessage(_("flyMode", _(user.getAllowFlight() ? "enabled" : "disabled"), user.getDisplayName()));
} }
private void flyOtherPlayers(final Server server, final CommandSender sender, final String name) private void flyOtherPlayers(final Server server, final CommandSender sender, final String[] args)
{ {
for (Player matchPlayer : server.matchPlayer(name)) for (Player matchPlayer : server.matchPlayer(args[0]))
{ {
final User player = ess.getUser(matchPlayer); final User player = ess.getUser(matchPlayer);
if (player.isHidden()) if (player.isHidden())
{ {
continue; continue;
}
if (args.length > 1)
{
if (args[1].contains("on") || args[1].contains("ena") || args[1].equalsIgnoreCase("1"))
{
player.setAllowFlight(!player.getAllowFlight());
}
else
{
player.setAllowFlight(false);
}
} }
player.setAllowFlight(!player.getAllowFlight()); else
{
player.setAllowFlight(!player.getAllowFlight());
}
if (!player.getAllowFlight()) if (!player.getAllowFlight())
{ {
player.setFlying(false); player.setFlying(false);