Code is here: http://pastebin.com/6QPN1LUj What I'm trying to do here, is make OP only toggleable from the console. However, when I do /op In game and In Console, It just says "/op [player]" Do I need to have code to disable the vanilla OP command, or what?
see if the sender is not an instanceof player and if so allow the command, else, send the sender a message stating that it could only be executed from the console
Plater p = event.getPlayer(); if(p instanceof Player) { sendmsg.(BAD); e.setcancelled(true); return; }else{ //do nothing continue from console } @jorster23
In the PasteBin it looks like you are trying to override the onCommand method from JavaPlugin or CommandExecutor. The method only has one CommandSender as an argument, in the code provided, there is two. I would suggest to change the "cs" reference to "sender", and delete the ", CommandSender cs" part of the onCommand methods parameters. If you don't have it, add "@Override above the onCommand method, and it should tell you what parameter types it expects (assuming you are using an IDE). Try this code (untested). Code:java public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("op") && args.length == 1) { if (sender instanceof Player) { sender.sendMessage("This command is disabled!"); return true; } else { Player op = Bukkit.getPlayer(args[0]); if (op != null) { op.setOp(true); return true; } else { sender.sendMessage("Player is not online!"); } } } return false; }
DirtyStarfish Thanks! I will test this when I get home, and post a status update about whether or not it works.