// priority: 0

// Visit the wiki for more info - https://kubejs.com/

console.info('Hello, World! (Loaded server scripts)')

ServerEvents.loaded((event) => {
    event.server.runCommandSilent('reload')
  })
  //Login Event

PlayerEvents.loggedIn(event => {

  let player = event.entity

  if (!event.player.stages.has('climate_clemency_start_of_game')) {

      event.player.stages.add('climate_clemency_start_of_game')
    //  event.player.give('minecraft:wooden_axe')
    //  event.player.give('16x minecraft:apple')
    //  event.player.give(Item.of('patchouli:guide_book', '{"patchouli:book":"patchouli:world_types"}'))
    //  event.player.addEffect(Internal.MobEffect.getId(2), player)

      player.potionEffects.add("toughasnails:climate_clemency", 12000);

  }



})	

//WORLD EVENTS

ItemEvents.rightClicked(event => {
  if (event.item === 'strainers:improved_everything_upgrade' && event.player.crouching) {
    event.player.give('strainers:improved_mesh_upgrade')
    event.player.give('strainers:improved_input_upgrade')
    event.player.give('strainers:improved_output_upgrade')
    event.player.give('strainers:improved_duration_upgrade')
    event.item.setCount(event.item.getCount() - 1)
  }

  if (event.item === 'strainers:sturdy_everything_upgrade' && event.player.crouching) {
    event.player.give('strainers:sturdy_mesh_upgrade')
    event.player.give('strainers:sturdy_input_upgrade')
    event.player.give('strainers:sturdy_output_upgrade')
    event.player.give('strainers:sturdy_duration_upgrade')
    event.item.setCount(event.item.getCount() - 1)
  }

  if (event.item === 'strainers:everlasting_everything_upgrade' && event.player.crouching) {
    event.player.give('strainers:everlasting_mesh_upgrade')
    event.player.give('strainers:everlasting_input_upgrade')
    event.player.give('strainers:everlasting_output_upgrade')
    event.player.give('strainers:everlasting_duration_upgrade')
    event.item.setCount(event.item.getCount() - 1)
  }

  if (event.item === 'strainers:reinforced_everything_upgrade' && event.player.crouching) {
    event.player.give('strainers:reinforced_mesh_upgrade')
    event.player.give('strainers:reinforced_input_upgrade')
    event.player.give('strainers:reinforced_output_upgrade')
    event.player.give('strainers:reinforced_duration_upgrade')
    event.item.setCount(event.item.getCount() - 1)
  }


})
