(this might have been asked already, but I can't find it if it was) I know how to force a player to send a command, but how can I make the command be sent as OP? I know I could just OP them temporarily, but that's a bit of an ugly solution. Is there a better way? Edit: For those interested, I am writing a plugin that uses MobDisguise, but MD's API is extremely basic, and doesn't support things like toggling the person as a baby, which I need. Therefore, I have to use commands.
It seems like the best way to do it would be to either user permissions (temporarily I guess?), do whatever you need to in your own plugin by copying the applicable methods into your plugin, or see about plugging into their API. I don't think it's a good idea at all to even allow the possibility of any command to be sent as an OP.
You can make the server send the command (the server is practically OP): Code:java Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "<command here>");
Unfortunately, the MobDisguise commands only work when run by a player (it's dumb). They should really take a player as an argument, and work from the console.
Best bet would probably be to hook into MobDisguise and just use his methods to set the players appearance. There most likely is a .setAppearance(player, type) or something along the lines of that method. I will look into if you'd like
Why can't you do something like this? Code:java @Overridepublic boolean onCommand(CommandSender sender, Command command,String label, String[] args) {Player p = null;if(sender instanceof Player){p = ((Player) sender).getPlayer();} else {sender.sendMessage("Command must be run by a player");return true;}if(label.equalsIgnoreCase("hideme")){MobDisguiseAPI.disguisePlayer(p, "chicken");}if(label.equalsIgnoreCase("showme")){MobDisguiseAPI.undisguisePlayer(p);}return true;}
so Don't use mob disguise, do it yourself. You can look off of MD's source to see how it changes the player to begin with as a reference. Or, you could ask the author to add support for that
I don't want to link against CB.jar, which MobDisguise needs to do what it does. I might have to, though.