#Cant run command in forge event, just crashing the game.

27 messages · Page 1 of 1 (latest)

vivid hawk
#
//startup
ForgeEvents.onEvent("net.minecraftforge.event.entity.player.PlayerWakeUpEvent", event => {
    global.WakeUp(event)
})
//server
global.WakeUp = (event) =>{
    console.log('Worked')
    event.server.runCommandSilent('time set noon')
}
indigo hareBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

stark meadowBOT
#

You can write your code in a codeblock by typing it between the codeblock delimiters:

```js :arrow_left:

onEvent('recipes', e => {
e.smelting('minecraft:glass', '#forge:sand').xp(.1)
})

``` :arrow_left:

As an example, :arrow_up: will look like this:

onEvent('recipes', e => {
  e.smelting('minecraft:glass', '#forge:sand').xp(.1)
})
vale violet
#
Util.server.runCommandSilent('time set noon')
vivid hawk
vale violet
#

try Utils

vivid hawk
# vale violet try `Utils`

its work perfectly now, i really appreciate your help 🙏
However, where can i get all utils.server methods?

stark meadowBOT
#

Kubejs has a feature known as beans which allows you to make scripts a tad more readable.
Anything getXy() can be gotten with xy, anything setXy(value) can be set with xy = value and anything isXy() can be checked with just xy.

This allows us to shorten our code! For example, to get a list of all online players you can do: event.getServer().getPlayers(). With beans this can be shortened to event.server.players!

Note that get and is beans only work if the method has no parameters. This means a method like getHeldItem(InteractionHand hand) cannot be shortened to heldItem.
For set the method needs to have a single parameter.

vivid hawk
#

thanks 🙏
When i will done with all, i am going send finished work here

vivid hawk
# vale violet try `Utils`

ok, guess i need a little bit more help, look

//server
global.WakeUp = (event) =>{
    console.log('Worked')
    //event.player.runCommand('dragon-altar')
    Utils.server.runCommandSilent('execute as ${event.player.username} run dragon-altar')
}
#

How can i do a event.player.runCommandSilent?

#

Because when i try it, it just crash the game, as the event.server.runCommandSilent

sick willow
#

it would be event.entity.runCommandSilent

#

you can't just expect variables to be there when you're not using kjs based events

vivid hawk
sick willow
vivid hawk
#

Ok, now its really done, so when u tipsy and wake up, start's command that open GUI to change from human to dragon. Yes i spendet like 4-6 hours for thatbigbrain. Thanks to everyone there who help me in that coward code 🙏

//server
global.WakeUp = (event) =>{
    console.log('Worked')
    //event.player.runCommand('dragon-altar') !!NOT WORK
    //Utils.server.runCommandSilent('execute as ${event.player.name} run dragon-altar') !!NOT WORK
    if(event.entity.hasEffect('brewinandchewin:tipsy')){
    event.entity.runCommandSilent('dragon-altar')}
}
vivid hawk
#

Ok i have one little question, how can i run that part with higher permission?

    if(event.entity.hasEffect('brewinandchewin:tipsy')){
    event.entity.runCommandSilent('dragon-altar')}
}
#

I mean, this command only for OP's, but i need run it for normal player

#

I can make it with luckyperms, but than player will be abile to use command on start

#

And when i tryed use

Utils.server.runCommandSilent('execute as ${playerName} run dragon-altar')
#

Server just dies

vivid hawk
#

ok, i just needed other type of ''