From 29c95cb1b67de6f8a5353f3087284b72956dcb8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AD=B1=E5=82=91?= Date: Mon, 2 May 2022 02:22:29 +0800 Subject: [PATCH] Add `/setstats mhp` to set Max HP (#407) * Fixed `/setstats hp` without changing the max hp. The Max HP should be modified. * Add `/setstats mhp` to set Max HP --- .../command/commands/SetStatsCommand.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/command/commands/SetStatsCommand.java b/src/main/java/emu/grasscutter/command/commands/SetStatsCommand.java index 6e18573bb..0ca3f07ce 100644 --- a/src/main/java/emu/grasscutter/command/commands/SetStatsCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/SetStatsCommand.java @@ -28,9 +28,21 @@ public final class SetStatsCommand implements CommandHandler { String stat = args.get(0); switch (stat) { default: - CommandHandler.sendMessage(sender, "Usage: /setstats|stats for basic stats"); + CommandHandler.sendMessage(sender, "Usage: /setstats|stats for basic stats"); CommandHandler.sendMessage(sender, "Usage: /stats for elemental bonus"); return; + case "mhp": + try { + int health = Integer.parseInt(args.get(1)); + EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity(); + entity.setFightProperty(FightProperty.FIGHT_PROP_MAX_HP, health); + entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_MAX_HP)); + CommandHandler.sendMessage(sender, "MAX HP set to " + health + "."); + } catch (NumberFormatException ignored) { + CommandHandler.sendMessage(sender, "Invalid Max HP value."); + return; + } + break; case "hp": try { int health = Integer.parseInt(args.get(1));