// Priority: 1
/**
  
  █▀▄▀█ █▀█ █▄░█ █░█ █▀▄▀█ █▀▀ █▄░█ ▀█▀ ▄▀█ █░░   █▀▀ ▀▄▀ █▀█ █▀▀ █▀█ █ █▀▀ █▄░█ █▀▀ █▀▀
  █░▀░█ █▄█ █░▀█ █▄█ █░▀░█ ██▄ █░▀█ ░█░ █▀█ █▄▄   ██▄ █░█ █▀▀ ██▄ █▀▄ █ ██▄ █░▀█ █▄▄ ██▄

  ☻/  * @file Default Gamerule Initialization
  /▌  * @copyright KnightDexx's Modded Minecraft World | ModernGamingWorld | GeekTechMedia
  /\

  PORTED: 1.20.1 → 1.21.1 NeoForge
  - ServerEvents.loaded(), persistentData, and runCommandSilent() are all unchanged
  - FIXED: Removed leading '/' from runCommandSilent() calls — the slash prefix
    is not needed and can cause silent failures in KubeJS 1.21.1
  - CONSOLIDATED: All 3 separate gamerule files merged into one for cleanliness

*/
ServerEvents.loaded((event) => {

  const gamerules = [
    { rule: 'doFireTick',                value: 'false' },
    { rule: 'doImmediateRespawn',        value: 'true'  },
    { rule: 'playersSleepingPercentage', value: '1'     },
  ]

  gamerules.forEach((gamerule) => {
    if (!event.server.persistentData[gamerule.rule]) {
      // Note: no leading '/' — runCommandSilent does not require it
      event.server.runCommandSilent(`gamerule ${gamerule.rule} ${gamerule.value}`)
      console.log(`Default Gamerule Applied: ${gamerule.rule} = ${gamerule.value}`)
      event.server.persistentData[gamerule.rule] = gamerule.value
    }
  })

})
