#command stage or check luckperms

23 messages · Page 1 of 1 (latest)

split obsidianBOT
#

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

wind token
#
.requires(src => src.isPlayer() && src.player.stages && src.player.stages.has("my_stage"))
#

that should wokr

ashen tide
wind token
#

no

#
ServerEvents.command(event => {
    const { commands: Commands } = event
    event.register(Commands.literal('back')
        .requires(src => src.isPlayer() && src.player.stages && src.player.stages.has("my_stage"))
        .executes(context => {
            player.tell('Disable') // also this line won't work
            return 1
        })
    )
})
#

you can possilbe also remove the && src.player.stages check (the first one)

ashen tide
#

Not working the command is not disable with stage or no stage

sacred iglooBOT
#

You can find your KubeJS server log in /minecraft/logs/kubejs/server.log.
If you are on 1.18 or 1.16 it will be called server.txt.
Please send it if asked, as it contains helpful information.

ashen tide
#

command.js#5: Error in 'ServerEvents.command': TypeError: Cannot find function register in object dev.latvian.mods.kubejs.server.CommandEventJS@5ac458b.

wind token
#

You need ServerEvents.commandRegistry

ashen tide
# wind token You need ServerEvents.commandRegistry
ServerEvents.command(event => {
    const { commands: Commands } = event

    
    event.register(Commands.literal('back').executes(context => {
        
        player.tell('Disable');
        return 1;
    }));
});```

When i was using this script i try with ServerEvents.commandRegistry and this was not working so i assume this will do the same but i will try
#

So i get no error in the log but with or with nothing not working

wind token
#

.command is trigged everytime a command is executed

#

commandRegistry is for actually adding new commands

ashen tide
#

Yeah but the command already exist

#

i want to disable it for group of people

wind token
#

try this

ServerEvents.command(event => {
    if(event.getCommandName() != "back") return
    let source = event.results.context.source
    if(source.isPlayer() && source.player.stages.has("my_stage") return
    event.cancel()
})
ashen tide
#

command.js#3: Error in 'ServerEvents.command': TypeError: Cannot read property "context" from undefined

#

And now i get the error from minecraft An unexpected error occured trying to execute that command

stoic thunder
#

Try replacing let source = event.results.context.source by let source = event.parseResults.context.source;

#

@ashen tide