diff --git a/src/main/java/emu/grasscutter/game/systems/InventorySystem.java b/src/main/java/emu/grasscutter/game/systems/InventorySystem.java index 86210bb0c..4cb875b8c 100644 --- a/src/main/java/emu/grasscutter/game/systems/InventorySystem.java +++ b/src/main/java/emu/grasscutter/game/systems/InventorySystem.java @@ -4,31 +4,24 @@ import emu.grasscutter.Grasscutter; import emu.grasscutter.data.GameData; import emu.grasscutter.data.common.ItemParamData; import emu.grasscutter.data.excels.ItemData; -import emu.grasscutter.data.excels.avatar.AvatarPromoteData; -import emu.grasscutter.data.excels.avatar.AvatarSkillDepotData; +import emu.grasscutter.data.excels.avatar.*; import emu.grasscutter.data.excels.weapon.WeaponPromoteData; import emu.grasscutter.game.avatar.Avatar; -import emu.grasscutter.game.inventory.GameItem; -import emu.grasscutter.game.inventory.ItemType; -import emu.grasscutter.game.inventory.MaterialType; +import emu.grasscutter.game.inventory.*; import emu.grasscutter.game.player.Player; -import emu.grasscutter.game.props.FightProperty; -import emu.grasscutter.game.props.ItemUseAction.ItemUseAddExp; -import emu.grasscutter.game.props.ItemUseAction.ItemUseAddReliquaryExp; -import emu.grasscutter.game.props.ItemUseAction.ItemUseAddWeaponExp; -import emu.grasscutter.game.props.ItemUseAction.UseItemParams; -import emu.grasscutter.game.props.ItemUseOp; +import emu.grasscutter.game.props.*; +import emu.grasscutter.game.props.ItemUseAction.*; import emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam; import emu.grasscutter.net.proto.MaterialInfoOuterClass.MaterialInfo; -import emu.grasscutter.server.event.player.PlayerUseFoodEvent; -import emu.grasscutter.server.game.BaseGameSystem; -import emu.grasscutter.server.game.GameServer; +import emu.grasscutter.server.event.player.*; +import emu.grasscutter.server.game.*; import emu.grasscutter.server.packet.send.*; import emu.grasscutter.utils.Utils; import it.unimi.dsi.fastutil.ints.*; +import lombok.val; + import java.util.*; import java.util.stream.Stream; -import lombok.val; public class InventorySystem extends BaseGameSystem { private static final Int2IntMap weaponRefundMaterials = new Int2IntArrayMap(); @@ -743,6 +736,9 @@ public class InventorySystem extends BaseGameSystem { // Packets player.sendPacket(new PacketAvatarPropNotify(avatar)); player.sendPacket(new PacketAvatarUpgradeRsp(avatar, oldLevel, oldPropMap)); + + // Call PlayerLevelAvatarEvent. + new PlayerLevelAvatarEvent(player, oldLevel, avatar).call(); } public void upgradeAvatarFetterLevel(Player player, Avatar avatar, int expGain) { diff --git a/src/main/java/emu/grasscutter/server/event/player/PlayerLevelAvatarEvent.java b/src/main/java/emu/grasscutter/server/event/player/PlayerLevelAvatarEvent.java new file mode 100644 index 000000000..617f2830f --- /dev/null +++ b/src/main/java/emu/grasscutter/server/event/player/PlayerLevelAvatarEvent.java @@ -0,0 +1,26 @@ +package emu.grasscutter.server.event.player; + +import emu.grasscutter.game.avatar.Avatar; +import emu.grasscutter.game.player.Player; +import emu.grasscutter.server.event.types.PlayerEvent; +import lombok.Getter; + +@Getter +public final class PlayerLevelAvatarEvent extends PlayerEvent { + private final int oldLevel; + private final Avatar avatar; + + public PlayerLevelAvatarEvent(Player player, int oldLevel, Avatar avatar) { + super(player); + + this.oldLevel = oldLevel; + this.avatar = avatar; + } + + /** + * @return The avatar's new level. + */ + public int getNewLevel() { + return this.getAvatar().getLevel(); + } +}