From cc94a21ca90cc0c7b5489519ab6a351384e8ec3f Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Wed, 17 May 2023 00:57:01 -0400 Subject: [PATCH] Fix player level up not displaying on the client properly --- .../emu/grasscutter/game/player/Player.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/player/Player.java b/src/main/java/emu/grasscutter/game/player/Player.java index b1846a50e..a2f46d394 100644 --- a/src/main/java/emu/grasscutter/game/player/Player.java +++ b/src/main/java/emu/grasscutter/game/player/Player.java @@ -1481,14 +1481,19 @@ public class Player implements PlayerHook { int currentValue = this.properties.get(prop.getId()); this.properties.put(prop.getId(), value); if (sendPacket) { - // Update player with packet + // Send property change reasons if needed. + switch (prop) { + case PROP_PLAYER_EXP -> this.sendPacket(new PacketPlayerPropChangeReasonNotify(this, prop, currentValue, value, + PropChangeReason.PROP_CHANGE_REASON_PLAYER_ADD_EXP)); + case PROP_PLAYER_LEVEL -> this.sendPacket(new PacketPlayerPropChangeReasonNotify(this, prop, currentValue, value, + PropChangeReason.PROP_CHANGE_REASON_LEVELUP)); + case PROP_PLAYER_WORLD_LEVEL -> this.sendPacket(new PacketPlayerPropChangeReasonNotify(this, prop, currentValue, value, + PropChangeReason.PROP_CHANGE_REASON_MANUAL_ADJUST_WORLD_LEVEL)); + } + + // Update player with packet. this.sendPacket(new PacketPlayerPropNotify(this, prop)); this.sendPacket(new PacketPlayerPropChangeNotify(this, prop, value - currentValue)); - - // Make the Adventure EXP pop-up show on screen. - if (prop == PlayerProperty.PROP_PLAYER_EXP) { - this.sendPacket(new PacketPlayerPropChangeReasonNotify(this, prop, currentValue, value, PropChangeReason.PROP_CHANGE_REASON_PLAYER_ADD_EXP)); - } } return true; } else {