Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Get all permissions and put them in an list (array)

Comments in 'Plugin Development' started by Tim // robske Büba, Feb 2, 2016.

  1. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Is there an way to do this (It would be the best if i could get the description too!)
    (If there is already an plugin, let me know)
  2. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PurePerms.

    Try getting permissions from plugin.yml
    PHP:
    $plugin->getDescription()->getPermissions();
    applqpak likes this.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    For all permissions present on the server: PluginManager->getPermissions()
    applqpak likes this.
  4. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Would that give me an array with all permissions, wich i can implode and then output?
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    applqpak likes this.
  6. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Lol the perm system is pretty well written
    PocketKiller likes this.
  7. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    I've finished it:
    You can choose to spam the console:
    PHP:
          switch($command->getName())
            {
                case 
    "permList":
                
    $permArray $this->getServer()->getPluginManager()->getPermissions();
                
    $permName_DescArray NULL;
                
    $INDEX 0;
                foreach(
    $permArray as $perm)
                {
                    
    $permName_DescArray[$INDEX] = "Permission: ".$perm->getName()." Description: ".$perm->getDescription();
                    
    $INDEX++;
                }
                
    $this->getServer()->getLogger()->info(implode(" \n ",$permName_DescArray));
            return 
    true;
            }  
    or make an almost unreadable text:
    PHP:
          switch($command->getName())
            {
                case 
    "permList":
                
    $permArray $this->getServer()->getPluginManager()->getPermissions();
                
    $permName_DescArray NULL;
                
    $INDEX 0;
                foreach(
    $permArray as $perm)
                {
                    
    $permName_DescArray[$INDEX] = "Permission: ".$perm->getName()." Description: ".$perm->getDescription();
                    
    $INDEX++;
                }
                
    $this->getServer()->getLogger()->info(implode(" // ",$permName_DescArray));
            return 
    true;
            }  
    Please tell me if this contains an bad practise!
    And should i add this thread to resources? Because with this you can easily list all your permissions (for perm plugins)
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Command names should always be in lowercase. They are case insensitive.
    applqpak likes this.

Share This Page

Advertisement