From a47655db7a8723e17979f8482ec927d61170751d Mon Sep 17 00:00:00 2001 From: fengyuecanzhu <1021300691@qq.com> Date: Fri, 22 Apr 2022 08:08:47 +0800 Subject: [PATCH 1/3] add fullfp command --- .../command/commands/FullHpCommand.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/main/java/emu/grasscutter/command/commands/FullHpCommand.java diff --git a/src/main/java/emu/grasscutter/command/commands/FullHpCommand.java b/src/main/java/emu/grasscutter/command/commands/FullHpCommand.java new file mode 100644 index 000000000..f27533a8d --- /dev/null +++ b/src/main/java/emu/grasscutter/command/commands/FullHpCommand.java @@ -0,0 +1,36 @@ +package emu.grasscutter.command.commands; + +import emu.grasscutter.command.Command; +import emu.grasscutter.command.CommandHandler; +import emu.grasscutter.game.GenshinPlayer; +import emu.grasscutter.game.props.FightProperty; +import emu.grasscutter.server.packet.send.PacketAvatarFightPropUpdateNotify; +import emu.grasscutter.server.packet.send.PacketAvatarLifeStateChangeNotify; +import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify; +import emu.grasscutter.server.packet.send.PacketLifeStateChangeNotify; + +import java.util.List; + +@Command(label = "fullhp", usage = "fullhp|fhp", + description = "Recover all characters in your current team to full health.", aliases = {"fhp"}, permission = "player.fullhp") +public class FullHpCommand implements CommandHandler { + @Override + public void execute(GenshinPlayer sender, List args) { + if (sender == null) { + CommandHandler.sendMessage(null, "Run this command in-game."); + return; + } + sender.getTeamManager().getActiveTeam().forEach(entity -> { + boolean isAlive = entity.isAlive(); + entity.setFightProperty( + FightProperty.FIGHT_PROP_CUR_HP, + entity.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) + ); + entity.getWorld().broadcastPacket(new PacketAvatarFightPropUpdateNotify(entity.getAvatar(), FightProperty.FIGHT_PROP_CUR_HP)); + if (!isAlive) { + entity.getWorld().broadcastPacket(new PacketAvatarLifeStateChangeNotify(entity.getAvatar())); + } + }); + CommandHandler.sendMessage(sender, "All hp recover to full."); + } +} From 85fd060561254e4ed56d4e814361b0cc2cb7f148 Mon Sep 17 00:00:00 2001 From: fengyuecanzhu <1021300691@qq.com> Date: Fri, 22 Apr 2022 08:26:48 +0800 Subject: [PATCH 2/3] remove revive command --- .../command/commands/ReviveCommand.java | 33 ------------------- 1 file changed, 33 deletions(-) delete mode 100644 src/main/java/emu/grasscutter/command/commands/ReviveCommand.java diff --git a/src/main/java/emu/grasscutter/command/commands/ReviveCommand.java b/src/main/java/emu/grasscutter/command/commands/ReviveCommand.java deleted file mode 100644 index 554af4a50..000000000 --- a/src/main/java/emu/grasscutter/command/commands/ReviveCommand.java +++ /dev/null @@ -1,33 +0,0 @@ -package emu.grasscutter.command.commands; - -import emu.grasscutter.command.Command; -import emu.grasscutter.command.CommandHandler; -import emu.grasscutter.game.GenshinPlayer; -import emu.grasscutter.game.TeamManager; -//import emu.grasscutter.game.avatar.GenshinAvatar; -//import emu.grasscutter.game.TeamInfo; -import emu.grasscutter.game.entity.EntityAvatar; -import emu.grasscutter.game.props.FightProperty; -import emu.grasscutter.server.packet.send.PacketAvatarFightPropUpdateNotify; -import emu.grasscutter.server.packet.send.PacketAvatarLifeStateChangeNotify; - -import java.util.List; - -@Command(label = "revive", aliases = {"rev"}, - usage = "revive|rev", description = "Revive character(s) that died)") -public class ReviveCommand implements CommandHandler { - //private Object teamId; - - @Override - public void execute(GenshinPlayer player, List args) { - for (EntityAvatar entity2 : player.getTeamManager().getActiveTeam()) { - entity2.setFightProperty( - FightProperty.FIGHT_PROP_CUR_HP, - entity2.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) * .4f - ); - player.sendPacket(new PacketAvatarFightPropUpdateNotify(entity2.getAvatar(), FightProperty.FIGHT_PROP_CUR_HP)); - player.sendPacket(new PacketAvatarLifeStateChangeNotify(entity2.getAvatar())); - } - player.dropMessage("Character revived."); - } -} From fd42dd558fa9c4bb67b393dbcb24e763d023688f Mon Sep 17 00:00:00 2001 From: fengyuecanzhu <1021300691@qq.com> Date: Fri, 22 Apr 2022 08:45:46 +0800 Subject: [PATCH 3/3] change fhp to heal --- .../commands/{FullHpCommand.java => HealCommand.java} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename src/main/java/emu/grasscutter/command/commands/{FullHpCommand.java => HealCommand.java} (81%) diff --git a/src/main/java/emu/grasscutter/command/commands/FullHpCommand.java b/src/main/java/emu/grasscutter/command/commands/HealCommand.java similarity index 81% rename from src/main/java/emu/grasscutter/command/commands/FullHpCommand.java rename to src/main/java/emu/grasscutter/command/commands/HealCommand.java index f27533a8d..511e52812 100644 --- a/src/main/java/emu/grasscutter/command/commands/FullHpCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/HealCommand.java @@ -11,9 +11,9 @@ import emu.grasscutter.server.packet.send.PacketLifeStateChangeNotify; import java.util.List; -@Command(label = "fullhp", usage = "fullhp|fhp", - description = "Recover all characters in your current team to full health.", aliases = {"fhp"}, permission = "player.fullhp") -public class FullHpCommand implements CommandHandler { +@Command(label = "heal", usage = "heal|h", + description = "Heal all characters in your current team.", aliases = {"h"}, permission = "player.heal") +public class HealCommand implements CommandHandler { @Override public void execute(GenshinPlayer sender, List args) { if (sender == null) { @@ -31,6 +31,6 @@ public class FullHpCommand implements CommandHandler { entity.getWorld().broadcastPacket(new PacketAvatarLifeStateChangeNotify(entity.getAvatar())); } }); - CommandHandler.sendMessage(sender, "All hp recover to full."); + CommandHandler.sendMessage(sender, "All characters are healed."); } }