Strings config.

Discussion in 'Spigot Plugin Development' started by KingTux, May 14, 2016.

  1. This is my config I want to get the player's name or in this case staff one staff2 ... and at the end of the each players name and the rank I want it to say Is (online or offline ) is this possible?
    - staff1 is a Mod
    - staff2 is a helper
    - staff3
    - staff4 is a dude
    I got this code for getting the config text.
    Code (Text):

           List<String> staff = this.getConfig().getStringList("staff");
           for (String s : staff) {
  2. Contain the name and rank in one string, then use create an offline player object with Bukkit#getOfflinePlayer(String) (String is their name) and use OfflinePlayer#isOnline()
  3. How do i get the name?
  4. Use a seperator character between name and rank, like : for example, split the string value at that character and go from there
  5. String arr[] = s.split( " ", 2);
  6. Yeah space works too, and I don't think you need the 2. :p
  7. Code (Text):
                      Player player = event.getPlayer();
                      String name = player.getName();
  8. In the conifg.
  9. Code (Text):
     p.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("NAME OF IT HOW IT SHOULD BE IN THE CONFIG").replace("%player%", name));
  10. Seriously man you need to read the thread, not what he's trying to do at all
    • Agree Agree x 1
  11. well he wanted the name of the player to be in the config right?
  12. He's trying to get the value of a name and rank from a list of staff ranks. I've told him what do already
  13. oh okay then sorry.
  14. Code (Java):
    for (String s : Bukkit.getPlugin(Main.class).getConfig().getStringList("staff"))
        if (s.contains(separatorChar))
            staff.put(Bukkit.getOfflinePlayer(s.split(separatorChar)[0]).getUniqueId(), //Staff: HashMap<UUID, Rank(Enum)> staff = ...;
    Loop through and get the rank name and if it's online and send your messages.

    Hope that's what you wanted.
  15. There is no Bukkit.GetPlugin?
  16. This is what i got.
    Code (Text):

          List<String> staff = this.getConfig().getStringList("staff");
           for (String s : staff) {
              String arr[] = s.split(" ");

             player.sendMessage(s+ arr);