mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-22 14:23:09 +02:00
Allow syntax: /fly <player> <on/off>
This commit is contained in:
@@ -18,16 +18,15 @@ public class Commandfly extends EssentialsCommand
|
|||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
flyOtherPlayers(server, sender, args[0]);
|
flyOtherPlayers(server, sender, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||||
{
|
{
|
||||||
//todo permissions
|
|
||||||
if (args.length > 0 && args[0].trim().length() > 2 && Permissions.FLY_OTHERS.isAuthorized(user))
|
if (args.length > 0 && args[0].trim().length() > 2 && Permissions.FLY_OTHERS.isAuthorized(user))
|
||||||
{
|
{
|
||||||
flyOtherPlayers(server, user, args[0]);
|
flyOtherPlayers(server, user, args);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
user.setAllowFlight(!user.getAllowFlight());
|
user.setAllowFlight(!user.getAllowFlight());
|
||||||
@@ -38,16 +37,31 @@ 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 IUser player = ess.getUser(matchPlayer);
|
final IUser player = ess.getUser(matchPlayer);
|
||||||
if (player.isHidden())
|
if (player.isHidden())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
player.setAllowFlight(!player.getAllowFlight());
|
if (args.length > 1)
|
||||||
|
{
|
||||||
|
if (args[1].contains("on") || args[1].contains("ena") || args[1].equalsIgnoreCase("1"))
|
||||||
|
{
|
||||||
|
player.setAllowFlight(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.setAllowFlight(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.setAllowFlight(!player.getAllowFlight());
|
||||||
|
}
|
||||||
|
|
||||||
if (!player.getAllowFlight())
|
if (!player.getAllowFlight())
|
||||||
{
|
{
|
||||||
player.setFlying(false);
|
player.setFlying(false);
|
||||||
|
Reference in New Issue
Block a user