KubeJS-Mods / KubeJS

https://kubejs.com
GNU Lesser General Public License v3.0
307 stars 90 forks source link

Method not found error when setting stages via PlayerEvents.loggedIn() #844

Closed antiphysika closed 3 months ago

antiphysika commented 3 months ago

Minecraft Version

1.20.1

KubeJS Version

2001.6.5-build.7

Rhino Version

2.2-build.18

Architectury Version

9.2.14

Forge/Fabric Version

NeoForge-47.1.106

Describe your issue

Pretty sure I'm not doing anything cursed but bracing for a reality check just in case :stuck_out_tongue:

With the following script:

PlayerEvents.loggedIn(event =>
{
  let clear_player_inventory = (player) =>
  {
    let inventory = player.inventory
    inventory.clear()
  }

  const { player } = event

  if (player.stages.has('cleared_initial_inventory'))
    return

  console.log(`New player logging in: ${player.name}`)

  clear_player_inventory(player)
  player.stages.set('cleared_initial_inventory')

})

I'm getting a strange method-not-found error when setting the cleared_initial_inventory player stage:

07Jun2024 19:57:06.784] [Server thread/INFO] [KubeJS Server/]: events/player/clear_initial_inventory.js#17: New player logging in: literal{antiphysika}
[07Jun2024 19:57:06.795] [Server thread/ERROR] [KubeJS Server/]: events/player/clear_initial_inventory.js#20: Error in 'PlayerEvents.loggedIn': Can't find method dev.latvian.mods.kubejs.stages.Stages.set(string).
[07Jun2024 19:57:06.796] [Server thread/ERROR] [KubeJS Server/]: …rhino.EvaluatorException: Can't find method …kubejs.stages.Stages.set(string). (server_scripts:events/player/clear_initial_inventory.js#20)
[07Jun2024 19:57:06.796] [Server thread/ERROR] [KubeJS Server/]:   at …rhino.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:67)
[...]

Logs:

Crash report/logs

No response

liopyu commented 3 months ago

stages.set requires a string and a boolean, image

antiphysika commented 3 months ago

Gahhh. What a numpty. I must've cack-handidly deleted that at some point.

Thank you! And sorry for the noise