Hi everyone.
I'm tring to create an objective to count player's number of death. I try to read kubejs offline doc but it's very hard.
For now I've this pice of code :
ServerEvents.loaded(event => {
const { server } = event
// if (server.persistentData.gameRules) return // later when I finish this script to to all this actions once only
// Scoreboards
const { scoreboard } = server
console.log('=======================================================')
console.log(scoreboard) // see net.minecraft.server.ServerScoreboard@7bf4afcb [net.minecraft.server.ServerScoreboard]c
const { objectives } = scoreboard
console.log(objectives) // see [net.minecraft.world.scores.Objective@58a07670, ..., net.minecraft.world.scores.Objective@1c32e1dd] [java.util.ArrayList] so ok, this is a JAVA array so cannot use addObjective on it but where in this case ?
objectives.addObjective('nbDeath', 'DEATH_COUNT', {text: "Nombre de mort", color: "black"}, 'INTEGER') // equivalent of scoreboard objectives add nbDeath deathCount if I understand
scoreboard.setDisplayObjective('LIST', 'nbDeath') // equivalent of scoreboard objectives setdisplay list nbDeath if I understand
scoreboard.startTrackingObjective('nbDeath') // equivalent of scoreboard players enable @a nbDeath ?
server.persistentData.gameRules = true
})
But kubejs throw error "Error in 'ServerEvents.loaded': dev.latvian.mods.rhino.EcmaError: TypeError: Cannot find function addObjective in object {...}" but :
- In the offline doc I can view this function
- Why it's an instance of "object" and not "net.minecraft.server.ServerScoreboard" ?
- In addition, what's the two last parameters of addObjective ? (a boolean and an integer, right, but what is used for ?)
I realy try to understand KubeJS by myself but it's very complexe without a true doc :/ Thank in advance 🙂