Slash function may not support 'server' argument in Bukkit / Spigot
TonyGravagno opened this issue ยท 2 comments
The API doc says:
sender: The player or server on whose behalf the commands should be executed.
Examples use server but with Spigot I can't get server to work anywhere, only player. I'm getting error:
Cannot cast org.bukkit.craftbukkit.v1_10_R1.CraftServer to org.bukkit.command.CommandSender.
There's a forum post that says this work(s)(ed) with Canary so I'm guessing the Bukkit code was never enhanced to support a CraftServer object.
I haven't checked the source yet but will soon. Just reporting this here for now.
With Bukit, if the object is a Server, we need to use server.getConsoleSender().
Here is a small fix that works; in the slash.js file (on the module folder) change the slash function to
function slash( commands, sender ){
if (_.isArray(commands)){
_.each(commands, function(command){
slash(command, sender);
});
return;
}
if (__plugin.canary){
if (sender === server){
server.consoleCommand( commands );
} else {
server.consoleCommand( commands, sender );
}
}
if (__plugin.bukkit){
if (sender === server){
server.dispatchCommand(server.getConsoleSender(), commands );
} else {
server.dispatchCommand(sender, commands);
}
}
}