From f0df78a81a23274cfce1ef9bd5c0a854b017a2a8 Mon Sep 17 00:00:00 2001 From: Kengxxiao <11478651+Kengxxiao@users.noreply.github.com> Date: Thu, 28 Apr 2022 21:33:50 +0800 Subject: [PATCH] fix companionship exp my IDEA lint is not happy on my change --- .../grasscutter/game/inventory/Inventory.java | 3 +++ .../game/managers/InventoryManager.java | 27 +++++-------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/inventory/Inventory.java b/src/main/java/emu/grasscutter/game/inventory/Inventory.java index 240296003..e72bd3eed 100644 --- a/src/main/java/emu/grasscutter/game/inventory/Inventory.java +++ b/src/main/java/emu/grasscutter/game/inventory/Inventory.java @@ -242,6 +242,9 @@ public class Inventory implements Iterable { case 102: // Adventure exp getPlayer().addExpDirectly(count); break; + case 105: // Companionship exp + getPlayer().getServer().getInventoryManager().upgradeAvatarFetterLevel(player, getPlayer().getTeamManager().getCurrentAvatarEntity().getAvatar(), count); + break; case 201: // Primogem getPlayer().setPrimogems(player.getPrimogems() + count); break; diff --git a/src/main/java/emu/grasscutter/game/managers/InventoryManager.java b/src/main/java/emu/grasscutter/game/managers/InventoryManager.java index 055d3da6d..1e028c38c 100644 --- a/src/main/java/emu/grasscutter/game/managers/InventoryManager.java +++ b/src/main/java/emu/grasscutter/game/managers/InventoryManager.java @@ -23,23 +23,7 @@ import emu.grasscutter.game.player.Player; import emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam; import emu.grasscutter.net.proto.MaterialInfoOuterClass.MaterialInfo; import emu.grasscutter.server.game.GameServer; -import emu.grasscutter.server.packet.send.PacketAbilityChangeNotify; -import emu.grasscutter.server.packet.send.PacketAvatarPromoteRsp; -import emu.grasscutter.server.packet.send.PacketAvatarPropNotify; -import emu.grasscutter.server.packet.send.PacketAvatarSkillChangeNotify; -import emu.grasscutter.server.packet.send.PacketAvatarSkillUpgradeRsp; -import emu.grasscutter.server.packet.send.PacketAvatarUnlockTalentNotify; -import emu.grasscutter.server.packet.send.PacketAvatarUpgradeRsp; -import emu.grasscutter.server.packet.send.PacketDestroyMaterialRsp; -import emu.grasscutter.server.packet.send.PacketProudSkillChangeNotify; -import emu.grasscutter.server.packet.send.PacketProudSkillExtraLevelNotify; -import emu.grasscutter.server.packet.send.PacketReliquaryUpgradeRsp; -import emu.grasscutter.server.packet.send.PacketSetEquipLockStateRsp; -import emu.grasscutter.server.packet.send.PacketStoreItemChangeNotify; -import emu.grasscutter.server.packet.send.PacketUnlockAvatarTalentRsp; -import emu.grasscutter.server.packet.send.PacketWeaponAwakenRsp; -import emu.grasscutter.server.packet.send.PacketWeaponPromoteRsp; -import emu.grasscutter.server.packet.send.PacketWeaponUpgradeRsp; +import emu.grasscutter.server.packet.send.*; import emu.grasscutter.utils.Utils; import it.unimi.dsi.fastutil.ints.Int2IntMap; import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; @@ -659,7 +643,7 @@ public class InventoryManager { // Level up upgradeAvatar(player, avatar, promoteData, expGain); } - + public void upgradeAvatar(Player player, Avatar avatar, int expGain) { AvatarPromoteData promoteData = GameData.getAvatarPromoteData(avatar.getAvatarData().getAvatarPromoteId(), avatar.getPromoteLevel()); if (promoteData == null) { @@ -668,14 +652,14 @@ public class InventoryManager { upgradeAvatar(player, avatar, promoteData, expGain); } - + public void upgradeAvatar(Player player, Avatar avatar, AvatarPromoteData promoteData, int expGain) { int maxLevel = promoteData.getUnlockMaxLevel(); int level = avatar.getLevel(); int oldLevel = level; int exp = avatar.getExp(); int reqExp = GameData.getAvatarLevelExpRequired(level); - + while (expGain > 0 && reqExp > 0 && level < maxLevel) { // Do calculations int toGain = Math.min(expGain, reqExp - exp); @@ -690,7 +674,7 @@ public class InventoryManager { reqExp = GameData.getAvatarLevelExpRequired(level); } } - + // Old map for packet Map oldPropMap = avatar.getFightProperties(); if (oldLevel != level) { @@ -734,6 +718,7 @@ public class InventoryManager { avatar.save(); player.sendPacket(new PacketAvatarPropNotify(avatar)); + player.sendPacket(new PacketAvatarFetterDataNotify(avatar)); } public void upgradeAvatarSkill(Player player, long guid, int skillId) {