How to get HashMap from custom YAML

Discussion in 'Plugin Development' started by Goksi, May 2, 2017.

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

    Goksi

    My question is How i can get reason from hashmap stored in my custom yaml

    This is how my banlist.yml looks like:
    Code:
    bans:
      GoksiSRB: Left u toku SS/SL
    How i can get the string "Left u toku SS/SL"
     
  2. Online

    timtower Administrator Administrator Moderator

    @Goksi ConfigurationSection#getKeys(false)
    Use that on the bans configurationsection.
    Then loop through the set that you get and call configurationSection.getString
     
  3. Offline

    Goksi

    Something like this ?
    Code:
    String result = plugin.banlist.getConfigurationSection("bans").getKeys(false);
     
  4. Online

    timtower Administrator Administrator Moderator

    @Goksi It is a set of strings though.
     
  5. Offline

    Goksi

    How should i do that than ?
     
  6. Online

    timtower Administrator Administrator Moderator

    Look at the return type.
    Copy that.
     
  7. Offline

    Goksi

    I tried everything but it didnt worked ...
     
  8. Offline

    Zombie_Striker

    @Goksi
    It returns a set of strings, a Set<String>. That is what you need to set as the variable type.
     
  9. Offline

    Goksi

    I done that:
    Code:
    Set<String> result = plugin.getBanList().getConfigurationSection("bans").getKeys(false);
    Now how should i make it so i can send it in format like "You are banned for: " + result
     
  10. Offline

    Zombie_Striker

    @Goksi
    1. Create a string builder object.
    2. Create a for loop. For loop through all the results.
    3. For each string, append the string to the string builder
    4. Outside of the for loop
    5. send the message "You are banned for "+ stringBuilder.toString();
     
Thread Status:
Not open for further replies.

Share This Page