From 2b69978327158d3bcb753fe1768ce7ef842b052c Mon Sep 17 00:00:00 2001 From: Melledy <52122272+Melledy@users.noreply.github.com> Date: Tue, 26 Apr 2022 19:20:55 -0700 Subject: [PATCH] World level updates without needing to restart --- .../grasscutter/command/commands/SetWorldLevelCommand.java | 2 +- src/main/java/emu/grasscutter/game/GenshinPlayer.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/command/commands/SetWorldLevelCommand.java b/src/main/java/emu/grasscutter/command/commands/SetWorldLevelCommand.java index 146837523..2499293d4 100644 --- a/src/main/java/emu/grasscutter/command/commands/SetWorldLevelCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/SetWorldLevelCommand.java @@ -29,7 +29,7 @@ public final class SetWorldLevelCommand implements CommandHandler { // Set in both world and player props sender.getWorld().setWorldLevel(level); - sender.setProperty(PlayerProperty.PROP_PLAYER_WORLD_LEVEL, level); + sender.setWorldLevel(level); sender.dropMessage("World level set to " + level + "."); } catch (NumberFormatException ignored) { diff --git a/src/main/java/emu/grasscutter/game/GenshinPlayer.java b/src/main/java/emu/grasscutter/game/GenshinPlayer.java index 9df81955b..ad0fe248d 100644 --- a/src/main/java/emu/grasscutter/game/GenshinPlayer.java +++ b/src/main/java/emu/grasscutter/game/GenshinPlayer.java @@ -267,6 +267,11 @@ public class GenshinPlayer { public int getWorldLevel() { return this.getProperty(PlayerProperty.PROP_PLAYER_WORLD_LEVEL); } + + public void setWorldLevel(int level) { + this.setProperty(PlayerProperty.PROP_PLAYER_WORLD_LEVEL, level); + this.sendPacket(new PacketPlayerPropNotify(this, PlayerProperty.PROP_PLAYER_WORLD_LEVEL)); + } public int getPrimogems() { return this.getProperty(PlayerProperty.PROP_PLAYER_HCOIN);