Commit 48db6446 authored by Yazawazi's avatar Yazawazi Committed by GitHub
Browse files

command fix

parent eb709046
...@@ -4,8 +4,10 @@ import java.util.List; ...@@ -4,8 +4,10 @@ import java.util.List;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.data.GenshinData;
import emu.grasscutter.game.GenshinPlayer; 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>", @Command(label = "setfetterlevel", usage = "setfetterlevel <level>",
description = "Sets your fetter level for your current active character", description = "Sets your fetter level for your current active character",
...@@ -30,8 +32,13 @@ public final class SetFetterLevelCommand implements CommandHandler { ...@@ -30,8 +32,13 @@ public final class SetFetterLevelCommand implements CommandHandler {
CommandHandler.sendMessage(sender, "Fetter level must be between 0 and 10."); CommandHandler.sendMessage(sender, "Fetter level must be between 0 and 10.");
return; return;
} }
EntityAvatar avatar = sender.getTeamManager().getCurrentAvatarEntity(); GenshinAvatar avatar = sender.getTeamManager().getCurrentAvatarEntity().getAvatar();
avatar.getAvatar().setFetterLevel(fetterLevel);
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); CommandHandler.sendMessage(sender, "Fetter level set to " + fetterLevel);
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(null, "Invalid fetter level."); CommandHandler.sendMessage(null, "Invalid fetter level.");
......
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);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment