From 34c0c6b01b69d3ed300cef9a0c91cd39e9f04de2 Mon Sep 17 00:00:00 2001 From: Yazawazi <47273265+Yazawazi@users.noreply.github.com> Date: Fri, 22 Apr 2022 23:46:24 +0800 Subject: [PATCH] setfetterlevel command --- .../commands/SetFetterLevelCommand.java | 41 +++++++++++++++++++ .../game/managers/InventoryManager.java | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/main/java/emu/grasscutter/command/commands/SetFetterLevelCommand.java diff --git a/src/main/java/emu/grasscutter/command/commands/SetFetterLevelCommand.java b/src/main/java/emu/grasscutter/command/commands/SetFetterLevelCommand.java new file mode 100644 index 000000000..60a7e4796 --- /dev/null +++ b/src/main/java/emu/grasscutter/command/commands/SetFetterLevelCommand.java @@ -0,0 +1,41 @@ +package emu.grasscutter.command.commands; + +import java.util.List; + +import emu.grasscutter.command.Command; +import emu.grasscutter.command.CommandHandler; +import emu.grasscutter.game.GenshinPlayer; +import emu.grasscutter.game.entity.EntityAvatar; + +@Command(label = "setfetterlevel", usage = "setfetterlevel ", + description = "Sets your fetter level for your current active character", + aliases = {"setfetterlvl"}, permission = "player.setfetterlevel") +public final class SetFetterLevelCommand implements CommandHandler { + + @Override + public void execute(GenshinPlayer sender, List args) { + if (sender == null) { + CommandHandler.sendMessage(null, "Run this command in-game."); + return; + } + + if (args.size() < 1) { + CommandHandler.sendMessage(sender, "Usage: setfetterlevel "); + return; + } + + try { + int fetterLevel = Integer.parseInt(args.get(0)); + if (fetterLevel < 0 || fetterLevel > 10) { + CommandHandler.sendMessage(sender, "Fetter level must be between 0 and 10."); + return; + } + EntityAvatar avatar = sender.getTeamManager().getCurrentAvatarEntity(); + avatar.getAvatar().setFetterLevel(fetterLevel); + CommandHandler.sendMessage(sender, "Fetter level set to " + fetterLevel); + } catch (NumberFormatException ignored) { + CommandHandler.sendMessage(null, "Invalid fetter level."); + } + } + +} diff --git a/src/main/java/emu/grasscutter/game/managers/InventoryManager.java b/src/main/java/emu/grasscutter/game/managers/InventoryManager.java index 96ab032b8..4ea9e6bc1 100644 --- a/src/main/java/emu/grasscutter/game/managers/InventoryManager.java +++ b/src/main/java/emu/grasscutter/game/managers/InventoryManager.java @@ -713,7 +713,7 @@ public class InventoryManager { public void upgradeAvatarFetterLevel(GenshinPlayer player, GenshinAvatar avatar, int expGain) { // May work. Not test. - int maxLevel = GenshinData.getAvatarFetterLevelDataMap().get(GenshinData.getAvatarFetterLevelDataMap().size() - 1).getLevel(); + int maxLevel = 10; // Keep it until I think of a more "elegant" way int level = avatar.getFetterLevel(); int exp = avatar.getFetterExp(); int reqExp = GenshinData.getAvatarFetterLevelExpRequired(level);