Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
fc45d081
Commit
fc45d081
authored
Apr 21, 2022
by
Magix
Committed by
GitHub
Apr 21, 2022
Browse files
Merge pull request #93 from fengyuecanzhu/development
add heal command
parents
b09d8a2a
b31dab04
Changes
2
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/command/commands/HealCommand.java
0 → 100644
View file @
fc45d081
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
=
"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
<
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 characters are healed."
);
}
}
src/main/java/emu/grasscutter/command/commands/ReviveCommand.java
deleted
100644 → 0
View file @
b09d8a2a
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
<
String
>
args
)
{
for
(
EntityAvatar
entity2
:
player
.
getTeamManager
().
getActiveTeam
())
{
entity2
.
setFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
,
entity2
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_MAX_HP
)
*
.
4
f
);
player
.
sendPacket
(
new
PacketAvatarFightPropUpdateNotify
(
entity2
.
getAvatar
(),
FightProperty
.
FIGHT_PROP_CUR_HP
));
player
.
sendPacket
(
new
PacketAvatarLifeStateChangeNotify
(
entity2
.
getAvatar
()));
}
player
.
dropMessage
(
"Character revived."
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment