This isn’t working as intended. It’s supposed to remove all active raids when the last player leaves the world, but the cleanup isn’t triggering.
world.afterEvents.playerLeave.subscribe((event) => {
if (world.getAllPlayers().length === 0) {
system.run(() => {
console.log("[RaidCore] Last player left: removing all active raids...");
const overworld = getOverworldSafe();
if (!overworld) return;
for (const [key, raid] of activeRaids) {
try {
overworld.runCommand(`setblock ${Math.floor(raid.loc.x)} ${Math.floor(raid.loc.y)} ${Math.floor(raid.loc.z)} minecraft:air`);
} catch (e) {
if (raidcoreConfig.DEBUG) console.warn("[RaidCore] failed clearing core on last player leave:", e);
}
try {
overworld.runCommand(`kill @e[tag=raidmob_${raid.id}]`);
} catch (e) {
if (raidcoreConfig.DEBUG) console.warn("[RaidCore] failed killing raid mobs on last player leave:", e);
}
removeRaidHologram(raid.loc);
try {
overworld.runCommand(`tag @e[tag=raidcore_active] remove raidcore_active`);
} catch (e) {
if (raidcoreConfig.DEBUG) console.warn("[RaidCore] failed removing raidcore_active tags on last player leave:", e);
}
activeRaids.delete(key);
}
saveActiveRaids();
console.log("[RaidCore] All active raids removed after last player left.");
});
}
});