From ef263cb3265474500a62ca6b3aed0c0a4d4a640b Mon Sep 17 00:00:00 2001 From: scooterboo Date: Thu, 11 May 2023 19:04:43 -0700 Subject: [PATCH] unload scene when there are no players (#2147) * unload scene when there are no players * Update src/main/java/emu/grasscutter/game/world/Scene.java Co-authored-by: Magix <27646710+KingRainbow44@users.noreply.github.com> --------- Co-authored-by: Magix <27646710+KingRainbow44@users.noreply.github.com> --- src/main/java/emu/grasscutter/game/world/Scene.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/emu/grasscutter/game/world/Scene.java b/src/main/java/emu/grasscutter/game/world/Scene.java index 924a2a87f..498b112c7 100644 --- a/src/main/java/emu/grasscutter/game/world/Scene.java +++ b/src/main/java/emu/grasscutter/game/world/Scene.java @@ -511,6 +511,10 @@ public final class Scene { this.finishLoading(); this.checkPlayerRespawn(); if (this.tickCount++ % 10 == 0) this.broadcastPacket(new PacketSceneTimeNotify(this)); + if (this.getPlayerCount() <= 0 && !this.dontDestroyWhenEmpty) { + this.getScriptManager().onDestroy(); + this.getWorld().deregisterScene(this); + } } /** Validates a player's current position. Teleports the player if the player is out of bounds. */