mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-03 06:57:39 +01:00
Updating gamemode to allow essentials.gamemode.other.
This commit is contained in:
parent
37bd9bc9b5
commit
a9b77b3486
@ -16,28 +16,43 @@ public class Commandgamemode extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
Player player;
|
||||
if (args.length == 0)
|
||||
if (args.length < 1)
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
player = ess.getUser(sender); }
|
||||
else
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
else
|
||||
{
|
||||
player = server.getPlayer(args[0]);
|
||||
if (player == null)
|
||||
{
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
}
|
||||
player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
|
||||
sender.sendMessage(Util.format("gameMode", Util.i18n(player.getGameMode().toString().toLowerCase()), player.getDisplayName()));
|
||||
|
||||
gamemodeOtherPlayers(server, sender, args[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && user.isAuthorized("essentials.gamemode.others"))
|
||||
{
|
||||
gamemodeOtherPlayers(server, user, args[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
user.setGameMode(user.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
|
||||
user.sendMessage(Util.format("gameMode", Util.i18n(user.getGameMode().toString().toLowerCase()), user.getDisplayName()));
|
||||
}
|
||||
|
||||
private void gamemodeOtherPlayers(final Server server, final CommandSender sender, final String name)
|
||||
{
|
||||
for (Player matchPlayer : server.matchPlayer(name))
|
||||
{
|
||||
final User player = ess.getUser(matchPlayer);
|
||||
if (player.isHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
|
||||
sender.sendMessage(Util.format("gameMode", Util.i18n(player.getGameMode().toString().toLowerCase()), player.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user