forked from Grasscutters/Grasscutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
fengyuecanzhu
committed
Apr 22, 2022
1 parent
f248aa5
commit a47655d
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/main/java/emu/grasscutter/command/commands/FullHpCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> 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."); | ||
} | ||
} |