mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-09-06 21:18:03 +02:00
Optional second param to /gm to force gamemode on other players.
This commit is contained in:
parent
0e0a96b6d8
commit
767703bfc9
@ -24,7 +24,7 @@ public class Commandgamemode extends EssentialsCommand
|
|||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
gamemodeOtherPlayers(server, sender, args[0]);
|
gamemodeOtherPlayers(server, sender, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -32,7 +32,7 @@ public class Commandgamemode extends EssentialsCommand
|
|||||||
{
|
{
|
||||||
if (args.length > 0 && !args[0].trim().isEmpty() && user.isAuthorized("essentials.gamemode.others"))
|
if (args.length > 0 && !args[0].trim().isEmpty() && user.isAuthorized("essentials.gamemode.others"))
|
||||||
{
|
{
|
||||||
gamemodeOtherPlayers(server, user, args[0]);
|
gamemodeOtherPlayers(server, user, args);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,9 +40,9 @@ public class Commandgamemode extends EssentialsCommand
|
|||||||
user.sendMessage(_("gameMode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName()));
|
user.sendMessage(_("gameMode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void gamemodeOtherPlayers(final Server server, final CommandSender sender, final String name)
|
private void gamemodeOtherPlayers(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())
|
||||||
@ -50,7 +50,21 @@ public class Commandgamemode extends EssentialsCommand
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
|
if (args.length > 1)
|
||||||
|
{
|
||||||
|
if (args[1].contains("creat") || args[1].equalsIgnoreCase("1"))
|
||||||
|
{
|
||||||
|
player.setGameMode(GameMode.CREATIVE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
|
||||||
|
}
|
||||||
sender.sendMessage(_("gameMode", _(player.getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName()));
|
sender.sendMessage(_("gameMode", _(player.getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user