#Getting the player who issued a command
8 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
not all commands are ran by players
entities, command blocks and datapacks can also run commands
i believe you should be able to get the context/source from the command, and there are methods on that to check what executed it
i took a look at the forge event earlier today and apparently its no better than the kubejs command event
I think I figured it out from that, thanks
ServerEvents.command( event => {
let commandList = [
'spawn'
]
let effectList = [
'minecraft:speed'
]
let command = event.getCommandName()
if (!commandList.some(list => {
return command == list
})) return
let player = event.getParseResults().getContext().getSource().getEntity()
if (!player.isPlayer()) return
if (!effectList.some(list => {
return player.hasEffect(list)
})) return
event.cancel();
})