Solved How can i check how many people are in a rank / group

Discussion in 'Plugin Development' started by DSCxSander, Jul 8, 2014.

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

    DSCxSander

    I'm making a plugin for my own server,
    And what i will is if a player

    /builder

    that a message says how many people are in the group builder.

    Is this possible?

    I'm working with Essentials GroupManager

    - Sander
     
  2. Offline

    Asgernohns

    DSCxSander I don't know, but I think it would be easier if you used vault's API for it
     
  3. Offline

    DSCxSander

  4. Offline

    Asgernohns

    DSCxSander I personally think it's easier. And you also get a package of chat related stuff, and economy support. And also most popular plugins is supported.
     
  5. Offline

    DSCxSander

    I have never worked with Vault
     
  6. Offline

    bubba1234119

  7. Yeah, use Vault instead of the actual permission plugin unless Vault doesn't support it. The reason being, Vault supports multiple permissions plugins and is easier to use. It also makes it easier if your main permissions plugin stops getting updated, and so you can easily switch without having to re-code your plugin.

    http://dev.bukkit.org/bukkit-plugins/vault/#w-linking-vault
    Only take out the Permission bits, such as setupPermissions().
    If you've already imported Permission from Bukkit's package, you may want to manually type in the package.

    Edit: Looking at Vault's SRC, it seems like they don't have a method of getting the amount of players in a group, yet they have a way of getting all groups. I guess you could do something like this:
    Code:
    public String getAmountOfPlayers(String rank) {
        int amountOfPlayers = 0;
        for (OfflinePlayer oP : Bukkit.getOfflinePlayers()) { // Loop through every player who's joined the server previously.
            for (World world : Bukkit.getWorlds()) { // Loop through all worlds to see if they're in the group, regardless of the world.
                if (permissions.playerInGroup(world, oP, rank)) { // Check if they're in that group in that world.
                    amountOfPlayers++; // If they are, add 1 to the amount of players.
                    break; // If someone's inside the same group in 2 different worlds, don't add 1 again for them, so exit out of the world loop.
                }
            }
        }
        return amountOfPlayers;
    }
    
     
  8. Offline

    DSCxSander

    Thank you!
     
    KingFaris11 likes this.
  9. Offline

    Asgernohns

    KingFaris11 likes this.
Thread Status:
Not open for further replies.

Share This Page