Fix disabled instance being re-enabled on login

This commit is contained in:
ForestOfLight
2025-06-09 23:47:39 -07:00
Unverified
parent acd116e2f1
commit 8b6b5530fa
@@ -249,12 +249,12 @@ export class StructureInstance {
// This prevents a memory leak when no players are online. // This prevents a memory leak when no players are online.
world.beforeEvents.playerLeave.subscribe(event => { world.beforeEvents.playerLeave.subscribe(event => {
system.run(() => { system.run(() => {
if (world.getAllPlayers().length === 0) { if (world.getAllPlayers().length === 0 && this.options.isEnabled) {
console.info(`[Construct] No players are online. Disabling instance: '${this.options.instanceName}'`); console.info(`[Construct] No players are online. Disabling instance: '${this.options.instanceName}'`);
this.disable(); this.disable();
this.shouldEnableOnJoin = true; this.shouldEnableOnJoin = true;
} }
}) });
}); });
world.afterEvents.playerJoin.subscribe(event => { world.afterEvents.playerJoin.subscribe(event => {
if (this.shouldEnableOnJoin) { if (this.shouldEnableOnJoin) {