diff --git a/src/main/java/emu/grasscutter/command/commands/NoStaminaCommand.java b/src/main/java/emu/grasscutter/command/commands/NoStaminaCommand.java new file mode 100644 index 000000000..2012bde9f --- /dev/null +++ b/src/main/java/emu/grasscutter/command/commands/NoStaminaCommand.java @@ -0,0 +1,40 @@ +package emu.grasscutter.command.commands; + +import emu.grasscutter.command.Command; +import emu.grasscutter.command.CommandHandler; +import emu.grasscutter.game.player.Player; + +import java.util.List; + +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") +public final class NoStaminaCommand implements CommandHandler { + public static boolean StaminaState = false; + //Temp Value + @Override + public void execute(Player sender, Player targetPlayer, List args) { + if (targetPlayer == null) { + CommandHandler.sendMessage(sender, translate(sender, "commands.execution.need_target")); + return; + } + + + if (args.size() == 1) { + switch (args.get(0).toLowerCase()) { + case "on": + StaminaState = true; + break; + case "off": + StaminaState = false; + break; + default: + break; + } + } + targetPlayer.setStamina(StaminaState);//Set + + CommandHandler.sendMessage(sender, translate(sender, "commands.nostamina.success", (StaminaState ? translate(sender, "commands.status.enabled") : translate(sender, "commands.status.disabled")), targetPlayer.getNickname())); + } +} diff --git a/src/main/java/emu/grasscutter/game/managers/StaminaManager/StaminaManager.java b/src/main/java/emu/grasscutter/game/managers/StaminaManager/StaminaManager.java index 1f452a667..51261ac3f 100644 --- a/src/main/java/emu/grasscutter/game/managers/StaminaManager/StaminaManager.java +++ b/src/main/java/emu/grasscutter/game/managers/StaminaManager/StaminaManager.java @@ -2,6 +2,7 @@ package emu.grasscutter.game.managers.StaminaManager; import ch.qos.logback.classic.Logger; import emu.grasscutter.Grasscutter; +import emu.grasscutter.command.commands.NoStaminaCommand; import emu.grasscutter.data.GameData; import emu.grasscutter.game.entity.EntityAvatar; import emu.grasscutter.game.entity.GameEntity; @@ -297,9 +298,11 @@ public class StaminaManager { // Returns new stamina and sends PlayerPropNotify or VehicleStaminaNotify public int setStamina(GameSession session, String reason, int newStamina, boolean isCharacterStamina) { - if (!GAME_OPTIONS.staminaUsage) { + // Target Player + if (!GAME_OPTIONS.staminaUsage || session.getPlayer().getStamina()) { newStamina = getMaxCharacterStamina(); } + // set stamina if is character stamina if (isCharacterStamina) { player.setProperty(PlayerProperty.PROP_CUR_PERSIST_STAMINA, newStamina); diff --git a/src/main/java/emu/grasscutter/game/player/Player.java b/src/main/java/emu/grasscutter/game/player/Player.java index f86e09370..23b32c70f 100644 --- a/src/main/java/emu/grasscutter/game/player/Player.java +++ b/src/main/java/emu/grasscutter/game/player/Player.java @@ -121,6 +121,7 @@ public class Player { private int mainCharacterId; private boolean godmode; + private boolean stamina; private boolean moonCard; private Date moonCardStartTime; private int moonCardDuration; @@ -781,7 +782,14 @@ public class Player { } this.save(); } - + public boolean getStamina() { + // Get Stamina + return stamina; + } + public void setStamina(boolean stamina) { + // Set Stamina + this.stamina = stamina; + } public boolean inGodmode() { return godmode; } diff --git a/src/main/resources/languages/en-US.json b/src/main/resources/languages/en-US.json index b4dbed789..90db92f4d 100644 --- a/src/main/resources/languages/en-US.json +++ b/src/main/resources/languages/en-US.json @@ -173,6 +173,10 @@ "success": "Godmode is now %s for %s.", "description": "Prevents you from taking damage. Defaults to toggle." }, + "nostamina": { + "success": "NoStamina is now %s for %s.", + "description": "Keep your endurance to the maximum." + }, "heal": { "success": "All characters have been healed.", "description": "Heal all characters in your current team." diff --git a/src/main/resources/languages/zh-CN.json b/src/main/resources/languages/zh-CN.json index 5f379540b..3f927d2ed 100644 --- a/src/main/resources/languages/zh-CN.json +++ b/src/main/resources/languages/zh-CN.json @@ -145,6 +145,10 @@ "invalid_amount_or_playerId": "无效的数量/玩家ID。", "description": "给予所有物品" }, + "nostamina": { + "success": "NoStamina %s 对于 %s.", + "description": "保持你的体力处于最高状态。" + }, "giveArtifact": { "usage": "用法:giveart|gart [玩家] <圣遗物ID> <主词条ID> [<副词条ID>[,<强化次数>]]... [等级]", "id_error": "无效的圣遗物ID。",