Solved [Help] how do I list all the permitted commands

Discussion in 'Plugin Development' started by Cheesepro, Nov 4, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Cheesepro

    As the title said is there a way to list all the commands that I have permission to. I tried this:
    Code:java
    1. for (HelpTopic cmdLabel : getServer().getHelpMap().getHelpTopics()) {
    2. p.sendMessage(cmdLabel.getName());
    3. }

    But it listed all the commands, even the commands that I don't have permission to. If you know how to do it please help me! Thank you :D
     
  2. Offline

    Barinade

    Not tested, just looked through the API docs and came up with this, there may be a better way. Also, written without IDE, could be some errors

    for (Plugin p : getServer().getPluginManager().getPlugins()) {
    for (Map.Entry<String,Map<String,Object>> e : p.getDescriptionFile().getCommands()) {
    if (sender.hasPermission(getServer().getPluginCommand(e.getKey()).getPermission())) {
    //
    }
    }
    }Ignore this, the guy below me knows what he's doing.
     
  3. Offline

    Gamecube762

  4. Offline

    Cheesepro

    Gamecube762 Thank you very much! Just another question, is it possible to list the description of the command too? :D Thank you

    Sorry.. just fingured it out by the link you gave me, Thanks again :D

    Gamecube762 oh last question, do you know how to disable the appearance of alias?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  5. Offline

    Gamecube762

Thread Status:
Not open for further replies.

Share This Page