Grabbing Pex Users

Discussion in 'Plugin Development' started by AmberK, Apr 9, 2012.

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

    AmberK

    Is there a simple way to grab online pex users in a list? I have tried this:
    Code:
    PermissionUser[] admins = pex.getUsers("admins");
    ....
    p.sendMessage("§2" + admins);
    Including about every variation I can imagine on the last one:
    Code:
    admins.clone()
    admins.toString()
    Right now I'm just using:
    Code:
    Integer.toString(admins.length)
    So that the output is just a number instead of a bunch of stuff like this:
    Code:
    [Lru.tehkode.permissions.PermissionUser;@682bb56a
    Also, for the love of god, don't tell me to run off and get Vault.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
  2. Offline

    messageofdeath

    Code:
    private ArrayList<String> admins = new ArrayList();
     
    //For the method of putting them into a list
    for(Player players:Bukkit.getOnlinePlayers()) {
                        if(PermissionsEx.getUser(players).inGroup("ServerOwner")) {
                            admins.add(players.getName());
                        }
                    }
                    String g = admins.toString();
                    player.sendMessage("Admins Online: " + g);
                    admins.clear();
     
  3. Offline

    AmberK

    I got the names working (thanks for that), and I did
    Code:
     public String nobrackets(String string)
      {
        string = string.replaceAll("[", "");
        return string = string.replaceAll("]", "");
      }
    To get rid of the brackets, now my only issue is that I can't seem to get the people within the groups visible to others. Gotta say I've gotten pretty far with this though :)
     
  4. Offline

    dsmyth1915

    Why not use vault? It support all perms and econ
     
  5. Offline

    AmberK

    Because it isn't public in the first place. Because I want to learn with Pex. Because I asked, for information's sake ;)
     
  6. Offline

    Sorroko

    AmberK The way that you first post is correct you can simply iterate through admins as
    for(PermissionUser p: admins){
    //p is an individual user
    }
    Might not work ;) but it saves you from looping through all online players, If I am completely wrong its probably cause I read the question wrong.
     
  7. Offline

    messageofdeath

    Also if you want to get all players and be able to do this admin[0] admin[1] etc... use
    PHP:
    string string.replaceAll(" """);
    String[] admin line.split(",");
     
    //To get them
    admin[0admin[1admin[2admin[3etc...
     
Thread Status:
Not open for further replies.

Share This Page