Adding toggle feature to "nostamina" command similar to "godmode" command (#1152)

* stamina command enhancement

* added "ns" as command aliases for NoStaminaCommand
This commit is contained in:
tamilpp25 2022-06-02 16:03:46 +05:30 committed by GitHub
parent e1688c866f
commit 71b53e0be4

View File

@ -9,26 +9,26 @@ import java.util.List;
import static emu.grasscutter.utils.Language.translate; import static emu.grasscutter.utils.Language.translate;
@Command(label = "nostamina", usage = "nostamina [on|off]", permission = "player.nostamina", permissionTargeted = "player.nostamina.others", description = "commands.nostamina.description") @Command(label = "nostamina", usage = "nostamina [on|off|toggle]",aliases = {"ns"},permission = "player.nostamina", permissionTargeted = "player.nostamina.others", description = "commands.nostamina.description")
public final class NoStaminaCommand implements CommandHandler { public final class NoStaminaCommand implements CommandHandler {
public static boolean StaminaState = false;
//Temp Value
@Override @Override
public void execute(Player sender, Player targetPlayer, List<String> args) { public void execute(Player sender, Player targetPlayer, List<String> args) {
boolean stamina = !targetPlayer.getStamina();
if (args.size() == 1) { if (args.size() == 1) {
switch (args.get(0).toLowerCase()) { switch (args.get(0).toLowerCase()) {
case "on": case "on":
StaminaState = true; stamina = true;
break; break;
case "off": case "off":
StaminaState = false; stamina = false;
break; break;
default: default:
//toggled
break; break;
} }
} }
targetPlayer.setStamina(StaminaState);//Set targetPlayer.setStamina(stamina);//Set
CommandHandler.sendMessage(sender, translate(sender, "commands.nostamina.success", (StaminaState ? translate(sender, "commands.status.enabled") : translate(sender, "commands.status.disabled")), targetPlayer.getNickname())); CommandHandler.sendMessage(sender, translate(sender, "commands.nostamina.success", (stamina ? translate(sender, "commands.status.enabled") : translate(sender, "commands.status.disabled")), targetPlayer.getNickname()));
} }
} }