ServerEvents.tick(event => {
    if (event.server.tickCount % 100 !== 0) return;

    let level = event.server.getLevel('minecraft:overworld');
    let day = Math.floor(level.dayTime() / 24000);
    let pData = event.server.persistentData;

    // DAY 55 - Spore Horde
    if (day >= 55 && day < 81 && !pData.getBoolean('sporeday55_done')) {
        event.server.runCommandSilent('hordeManager startJsonHorde sporeday55 @p');
        pData.putBoolean('sporeday55_done', true);
    }

    // DAY 81 - End of Day 80
    if (day >= 81 && day < 101 && !pData.getBoolean('sporeday81_done')) {
        event.server.runCommandSilent('hordeManager startJsonHorde sporeday80 @p');
        pData.putBoolean('sporeday81_done', true);
    }

    // DAY 101 - End of Day 100
    if (day >= 101 && day < 121 && !pData.getBoolean('sporeday101_done')) {
        event.server.runCommandSilent('hordeManager startJsonHorde sporeday100 @p');
        pData.putBoolean('sporeday101_done', true);
    }

    // DAY 121 - End of Day 120
    if (day >= 121 && day < 131 && !pData.getBoolean('sporeday121_done')) {
        event.server.runCommandSilent('hordeManager startJsonHorde sporeday120 @p');
        pData.putBoolean('sporeday121_done', true);
    }

    // DAY 131 - End of Day 130
    if (day >= 131 && !pData.getBoolean('sporeday131_done')) {
        event.server.runCommandSilent('hordeManager startJsonHorde sporeday130 @p');
        pData.putBoolean('sporeday131_done', true);
    }
});
