Commit 5b3c05a9 authored by tiantian520's avatar tiantian520 Committed by GitHub
Browse files

Add a new command "nostamina" (#877)

* Add a new command " nostamina\

* Fix

* Fix 2

* Renamed some names.

* Update zh-CN.json

Fix an existing language expression error.
parent 5c3d9980
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<String> 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()));
}
}
...@@ -2,6 +2,7 @@ package emu.grasscutter.game.managers.StaminaManager; ...@@ -2,6 +2,7 @@ package emu.grasscutter.game.managers.StaminaManager;
import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.Logger;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.commands.NoStaminaCommand;
import emu.grasscutter.data.GameData; import emu.grasscutter.data.GameData;
import emu.grasscutter.game.entity.EntityAvatar; import emu.grasscutter.game.entity.EntityAvatar;
import emu.grasscutter.game.entity.GameEntity; import emu.grasscutter.game.entity.GameEntity;
...@@ -297,9 +298,11 @@ public class StaminaManager { ...@@ -297,9 +298,11 @@ public class StaminaManager {
// Returns new stamina and sends PlayerPropNotify or VehicleStaminaNotify // Returns new stamina and sends PlayerPropNotify or VehicleStaminaNotify
public int setStamina(GameSession session, String reason, int newStamina, boolean isCharacterStamina) { 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(); newStamina = getMaxCharacterStamina();
} }
// set stamina if is character stamina // set stamina if is character stamina
if (isCharacterStamina) { if (isCharacterStamina) {
player.setProperty(PlayerProperty.PROP_CUR_PERSIST_STAMINA, newStamina); player.setProperty(PlayerProperty.PROP_CUR_PERSIST_STAMINA, newStamina);
......
...@@ -121,6 +121,7 @@ public class Player { ...@@ -121,6 +121,7 @@ public class Player {
private int mainCharacterId; private int mainCharacterId;
private boolean godmode; private boolean godmode;
private boolean stamina;
private boolean moonCard; private boolean moonCard;
private Date moonCardStartTime; private Date moonCardStartTime;
private int moonCardDuration; private int moonCardDuration;
...@@ -781,7 +782,14 @@ public class Player { ...@@ -781,7 +782,14 @@ public class Player {
} }
this.save(); this.save();
} }
public boolean getStamina() {
// Get Stamina
return stamina;
}
public void setStamina(boolean stamina) {
// Set Stamina
this.stamina = stamina;
}
public boolean inGodmode() { public boolean inGodmode() {
return godmode; return godmode;
} }
......
...@@ -173,6 +173,10 @@ ...@@ -173,6 +173,10 @@
"success": "Godmode is now %s for %s.", "success": "Godmode is now %s for %s.",
"description": "Prevents you from taking damage. Defaults to toggle." "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": { "heal": {
"success": "All characters have been healed.", "success": "All characters have been healed.",
"description": "Heal all characters in your current team." "description": "Heal all characters in your current team."
......
...@@ -145,6 +145,10 @@ ...@@ -145,6 +145,10 @@
"invalid_amount_or_playerId": "无效的数量/玩家ID。", "invalid_amount_or_playerId": "无效的数量/玩家ID。",
"description": "给予所有物品" "description": "给予所有物品"
}, },
"nostamina": {
"success": "NoStamina %s 对于 %s.",
"description": "保持你的体力处于最高状态。"
},
"giveArtifact": { "giveArtifact": {
"usage": "用法:giveart|gart [玩家] <圣遗物ID> <主词条ID> [<副词条ID>[,<强化次数>]]... [等级]", "usage": "用法:giveart|gart [玩家] <圣遗物ID> <主词条ID> [<副词条ID>[,<强化次数>]]... [等级]",
"id_error": "无效的圣遗物ID。", "id_error": "无效的圣遗物ID。",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment