#command stage or check luckperms
23 messages · Page 1 of 1 (latest)
.requires(src => src.isPlayer() && src.player.stages && src.player.stages.has("my_stage"))
that should wokr
ServerEvents.command(event => {
const { commands: Commands } = event
event.register(Commands.literal('back').executes(context => {
.requires(src => src.isPlayer() && src.player.stages && src.player.stages.has("my_stage"))
player.tell('Disable');
return 1;
}));
});```
like that ?
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)
Not working the command is not disable with stage or no stage
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.
command.js#5: Error in 'ServerEvents.command': TypeError: Cannot find function register in object dev.latvian.mods.kubejs.server.CommandEventJS@5ac458b.
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
.command is trigged everytime a command is executed
commandRegistry is for actually adding new commands
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()
})