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
48db6446
Commit
48db6446
authored
Apr 23, 2022
by
Yazawazi
Committed by
GitHub
Apr 23, 2022
Browse files
command fix
parent
eb709046
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/command/commands/SetFetterLevelCommand.java
View file @
48db6446
...
...
@@ -4,8 +4,10 @@ import java.util.List;
import
emu.grasscutter.command.Command
;
import
emu.grasscutter.command.CommandHandler
;
import
emu.grasscutter.data.GenshinData
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.avatar.GenshinAvatar
;
import
emu.grasscutter.server.packet.send.PacketAvatarFetterDataNotify
;
@Command
(
label
=
"setfetterlevel"
,
usage
=
"setfetterlevel <level>"
,
description
=
"Sets your fetter level for your current active character"
,
...
...
@@ -30,8 +32,13 @@ public final class SetFetterLevelCommand implements CommandHandler {
CommandHandler
.
sendMessage
(
sender
,
"Fetter level must be between 0 and 10."
);
return
;
}
EntityAvatar
avatar
=
sender
.
getTeamManager
().
getCurrentAvatarEntity
();
avatar
.
getAvatar
().
setFetterLevel
(
fetterLevel
);
GenshinAvatar
avatar
=
sender
.
getTeamManager
().
getCurrentAvatarEntity
().
getAvatar
();
avatar
.
setFetterLevel
(
fetterLevel
);
avatar
.
setFetterExp
(
GenshinData
.
getAvatarFetterLevelDataMap
().
get
(
fetterLevel
).
getExp
());
avatar
.
save
();
sender
.
sendPacket
(
new
PacketAvatarFetterDataNotify
(
avatar
));
CommandHandler
.
sendMessage
(
sender
,
"Fetter level set to "
+
fetterLevel
);
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
null
,
"Invalid fetter level."
);
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketAvatarFetterDataNotify.java
0 → 100644
View file @
48db6446
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.game.avatar.GenshinAvatar
;
import
emu.grasscutter.game.props.FetterState
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.AvatarFetterDataNotifyOuterClass.AvatarFetterDataNotify
;
import
emu.grasscutter.net.proto.AvatarFetterInfoOuterClass.AvatarFetterInfo
;
import
emu.grasscutter.net.proto.FetterDataOuterClass.FetterData
;
public
class
PacketAvatarFetterDataNotify
extends
GenshinPacket
{
public
PacketAvatarFetterDataNotify
(
GenshinAvatar
avatar
)
{
super
(
PacketOpcodes
.
AvatarFetterDataNotify
);
AvatarFetterInfo
.
Builder
avatarFetter
=
AvatarFetterInfo
.
newBuilder
()
.
setExpLevel
(
avatar
.
getFetterLevel
())
.
setExpNumber
(
avatar
.
getFetterExp
());
if
(
avatar
.
getFetterList
()
!=
null
)
{
for
(
int
i
=
0
;
i
<
avatar
.
getFetterList
().
size
();
i
++)
{
avatarFetter
.
addFetterList
(
FetterData
.
newBuilder
()
.
setFetterId
(
avatar
.
getFetterList
().
get
(
i
))
.
setFetterState
(
FetterState
.
FINISH
.
getValue
())
);
}
}
AvatarFetterInfo
avatarFetterInfo
=
avatarFetter
.
build
();
AvatarFetterDataNotify
proto
=
AvatarFetterDataNotify
.
newBuilder
()
.
putFetterInfoMap
(
avatar
.
getGuid
(),
avatarFetterInfo
)
.
build
();
this
.
setData
(
proto
);
}
}
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