Getting members from a Guild?

Discussion in 'Spigot Plugin Development' started by Nosmakos, Jun 4, 2017.

  1. I want to get all the members from each Guild in a Scoreboard. For example when a player is in a Guild called
    Monsters, The scoreboard would look:

    Code (Text):
    Monsters Members:
    So the thing is, i have to get from a custom yml file all the players that are in this GUILD called Monsters. Server has 4 Guilds, there can't be more or less.
    I have to get all the players from this yml file and check if this player is in this GUILD and set him as a number of this scoreboard.

    for (String users: plugin.getCustomConfig().getConfigurationSection(player.getUniqueId() + "Statistics.Guild.").getKeys(false)){
    with this way i am taking all the guilds that all players are in. But i want to get in a specific guild as i said all the uuids that are in and change them as an integer.
  2. Can you get the ConfigurationSection of the specific guild?
  3. This is what i don't know.
    And i am not sure if this works.
    Code (Text):
                    int members = 0;
                    for (String users: plugin.getUsersConfig().getConfigurationSection(player.getUniqueId() + "Statistics.Guild.").getKeys(false)){
                        if (users.contains("Monsters")){
                            o.getScore(ChatColor.GRAY + "" + ChatColor.WHITE + members).setScore(7);
    #3 Nosmakos, Jun 4, 2017
    Last edited: Jun 4, 2017
  4. If you config looks like this:
    Code (Text):
    Code (Text):
    Set<String> guilds = new HashSet<>();
    for (String uuid : users) {
        for (Set<String> guildKeys : plugin.getCustomConfig().getConfigurationSection(player.getUniqueId() + ".Guild").getKeys(false)){
    I'd say that is pretty inefficient config though.
    Could save users in different guilds as a String list instead of storing guilds under each uuid.
  5. Well this config has players statistics, it's called users.yml so it has their uuid their state, their money everything. so i just want to get their state from there. the guild. So this will work? or it will give their uuids than numbers? this is not getting the guild you want, it's getting all the guilds.
  6. Oh this just gets what guilds there are.
    Just modify it a bit.
  7. Yup this is what i have problem with, i am trying to get for example how many people are in 1 guild but didn't figured it out yet.
  8. really, you should be making guild objects to manipulate the data within the guild as well as to retrieve values, such as members.
    • Agree Agree x 1
  9. Yeah you are right but because i haven't done that i am trying like an idiot to figure out the way