mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-24 02:31:27 +00:00
command fix
This commit is contained in:
parent
34c0c6b01b
commit
f9b5c8a9ee
@ -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.");
|
||||
|
@ -0,0 +1,38 @@
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user