I've already googled. Use
If I use
but even if it executes as player, the command sender is still console (otherwise the permisson check will fail).
Is there any way to run a command as op? And how can I get the identity (not sender) in
Thank you!
try ... finally
to give op temporarily is a bad idea, and use the console sender will misperform the target selector (like @s).If I use
execute as Name run kill @s
in console, it works well. But when it comes to our custom command, we can only use the following codes to select the targets
Code:
Bukkit.getServer().selectEntities(sender, args[i]);
Is there any way to run a command as op? And how can I get the identity (not sender) in
CommandExecutor.onCommand
?Thank you!