what is the code for op players on server?

Discussion in 'Spigot Plugin Help' started by rickerd120, Jul 7, 2015.

  1. hi,

    i am making a plugin, this is a small piece of the code

    for so far i have when you do /op it says that you dont have the permission (CUSTOM TEXT MESSAGE) for it. but i tested it with permissions but i did not work...

    and olso i want that when you do /op and you have the permission to do op that you get opped, because there is op for, but what i get is nothing? it is doing nothing which code do i need to use for getting opped?
    • Agree Agree x 1
  2. Here's the sorted code for you:
    Code (Text):
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
            if (commandLabel.equalsIgnoreCase("message")) {
                sender.sendMessage(ChatColor.translateAlternateColorCodes('&', this.getConfig().getString("Message"));
            return false;
    And the method for setting as operator is: player.setOp(true);
  3. And please.. Use cmd.getLabel() for alias support.
    • Optimistic Optimistic x 1
  4. I'm pretty sure cmd.getName() is the recommended way, it works with aliases in the plugin.yml too.
  5. Yes? I said so. He used commandLabel right?