Change method of not ticking empty scenes (#2211)

This commit is contained in:
Nazrin 2023-06-16 11:04:16 -07:00 committed by GitHub
parent 248af4abfb
commit 89376d58bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View File

@ -556,10 +556,6 @@ 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. */

View File

@ -437,7 +437,9 @@ public class World implements Iterable<Player> {
// Check if there are players in this world.
if (this.getPlayerCount() == 0) return true;
// Tick all associated scenes.
this.getScenes().forEach((k, scene) -> scene.onTick());
this.getScenes().forEach((k, scene) -> {
if (scene.getPlayerCount() > 0) scene.onTick();
});
// sync time every 10 seconds
if (this.tickCount % 10 == 0) {