mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-14 13:13:24 +00:00
Add support for /gamemode toggle | /gamemode t and /gmt to toggle between the 3 gamemodes.
This commit is contained in:
parent
e919897f1b
commit
6fd82480a3
2 changed files with 10 additions and 2 deletions
|
@ -52,6 +52,9 @@ public class Commandgamemode extends EssentialsCommand
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (gameMode == null) {
|
||||
gameMode = user.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : user.getGameMode() == GameMode.CREATIVE ? GameMode.ADVENTURE : GameMode.SURVIVAL;
|
||||
}
|
||||
user.setGameMode(gameMode);
|
||||
user.sendMessage(_("gameMode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName()));
|
||||
}
|
||||
|
@ -59,7 +62,7 @@ public class Commandgamemode extends EssentialsCommand
|
|||
private void gamemodeOtherPlayers(final Server server, final CommandSender sender, final GameMode gameMode, final String player) throws NotEnoughArgumentsException
|
||||
{
|
||||
//TODO: TL this
|
||||
if (player.trim().length() < 2)
|
||||
if (player.trim().length() < 2 || gameMode == null)
|
||||
{
|
||||
throw new NotEnoughArgumentsException("You need to specify a valid player/mode.");
|
||||
}
|
||||
|
@ -100,6 +103,11 @@ public class Commandgamemode extends EssentialsCommand
|
|||
{
|
||||
mode = GameMode.ADVENTURE;
|
||||
}
|
||||
else if (modeString.equalsIgnoreCase("gmt") || modeString.equalsIgnoreCase("egmt")
|
||||
|| modeString.contains("toggle") || modeString.contains("cycle") || modeString.equalsIgnoreCase("t"))
|
||||
{
|
||||
mode = null;
|
||||
}
|
||||
else {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ commands:
|
|||
gamemode:
|
||||
description: Change player gamemode.
|
||||
usage: /<command> <survival|creative|adventure> [player]
|
||||
aliases: [gm,creative,creativemode,survival,survivalmode,adventure,adventuremode,gmc,gma,gms,egamemod,eecreative,ecreativemode,esurvival,esurvivalmode,eadventure,eadventuremode,egmc,egma,egms,egm]
|
||||
aliases: [gm,creative,creativemode,survival,survivalmode,adventure,adventuremode,gmc,gma,gms,gmt,egamemod,eecreative,ecreativemode,esurvival,esurvivalmode,eadventure,eadventuremode,egmc,egma,egms,egm,egmt]
|
||||
getpos:
|
||||
description: Get your current coordinates or those of a player.
|
||||
usage: /<command> [player]
|
||||
|
|
Loading…
Reference in a new issue