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>
This commit is contained in:
scooterboo 2023-05-11 19:04:43 -07:00 committed by GitHub
parent c425fb12c4
commit ef263cb326
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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. */