From 76b27df622f297cab0406fb4059c06f20afd91a2 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Sun, 27 Aug 2023 23:26:51 -0400 Subject: [PATCH] Add `PlayerLevelItemEvent` --- .../game/systems/InventorySystem.java | 3 +++ .../event/player/PlayerLevelItemEvent.java | 26 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/main/java/emu/grasscutter/server/event/player/PlayerLevelItemEvent.java diff --git a/src/main/java/emu/grasscutter/game/systems/InventorySystem.java b/src/main/java/emu/grasscutter/game/systems/InventorySystem.java index 4cb875b8c..04f990d82 100644 --- a/src/main/java/emu/grasscutter/game/systems/InventorySystem.java +++ b/src/main/java/emu/grasscutter/game/systems/InventorySystem.java @@ -441,6 +441,9 @@ public class InventorySystem extends BaseGameSystem { // Packets player.sendPacket(new PacketStoreItemChangeNotify(weapon)); player.sendPacket(new PacketWeaponUpgradeRsp(weapon, oldLevel, leftovers)); + + // Call PlayerLevelItemEvent. + new PlayerLevelItemEvent(player, oldLevel, weapon); } private List getLeftoverOres(int leftover) { diff --git a/src/main/java/emu/grasscutter/server/event/player/PlayerLevelItemEvent.java b/src/main/java/emu/grasscutter/server/event/player/PlayerLevelItemEvent.java new file mode 100644 index 000000000..ad4939291 --- /dev/null +++ b/src/main/java/emu/grasscutter/server/event/player/PlayerLevelItemEvent.java @@ -0,0 +1,26 @@ +package emu.grasscutter.server.event.player; + +import emu.grasscutter.game.inventory.GameItem; +import emu.grasscutter.game.player.Player; +import emu.grasscutter.server.event.types.PlayerEvent; +import lombok.Getter; + +@Getter +public final class PlayerLevelItemEvent extends PlayerEvent { + private final int oldLevel; + private final GameItem item; + + public PlayerLevelItemEvent(Player player, int oldLevel, GameItem item) { + super(player); + + this.oldLevel = oldLevel; + this.item = item; + } + + /** + * @return The item's new level. + */ + public int getNewLevel() { + return this.getItem().getLevel(); + } +}