Solved Get all players in a list

Discussion in 'Plugin Development' started by iAmGuus, Oct 19, 2014.

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

    iAmGuus

    Hi Bukkit :D,
    So today i wanna ask you something about a plugin i make.
    Ok, so what i want, is a method that gets all the players in List<String> stored by their uuid in the config.
    So, how can i get all those players from the List<String> in the config>
    Any idea?

    Thanks in advance,
    iAmGuus
     
  2. Offline

    FerusGrim

    Code:java
    1. List<UUID> uuidList = new ArrayList<UUID>();
    2.  
    3. for (String uuidStr : getConfig().getStringList("path.to.list")) {
    4. uuidList.add(UUID.fromString(uuidStr);
    5. }
     
  3. Offline

    iAmGuus

    FerusGrim And how do i get the players in that list?
     
  4. Offline

    FerusGrim

    How so? You mean, such as output them on the screen?

    Code:java
    1. getLogger().info("Player IDs!:");
    2. for (UUID uuid : uuidList) {
    3. getLogger().info(uuid);
    4. }
     
  5. Offline

    iAmGuus

    FerusGrim no, for instance, to send them a message
    like p.sendMessage("§eHi");
     
  6. Offline

    FerusGrim

    Code:java
    1. for (Player player : getServer().getOnlinePlayers()) {
    2. if (uuidList.contains(player.getUuid())) {
    3. player.sendMessage("Hi.");
    4. }
    5. }
     
    ChipDev likes this.
  7. Offline

    iAmGuus

    FerusGrim, thanks, you helped me out with this problem :d
     
  8. Offline

    FerusGrim

    No problem, iAmGuus

    Glad I could help. :) If you don't mind marking this as solved, so that anyone looking for a similar solution can see that one was reached, that'd be great.
     
  9. Offline

    iAmGuus

    Ok, Ill do
     
Thread Status:
Not open for further replies.

Share This Page