Solved Looking through config

Discussion in 'Plugin Development' started by AlbkadDev, Jan 5, 2018.

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

    AlbkadDev

    So I am trying to look at the config and put all the players fines inside of the hashmap but it doesnt seem to work the way I am doing it. I have tried doing

    Code:
    for (int i = 0; i < m.getConfig().getStringList(m.getConfig().getString("Fines.")).size(); i++) {
                Bukkit.getServer().broadcastMessage("This is working");
                m.fine.put(Bukkit.getServer().getPlayer(m.getConfig().getStringList(m.getConfig().getString("Fines.")).get(i)).getUniqueId(), m.getConfig().getInt(Bukkit.getServer().getPlayer(m.getConfig().getStringList(m.getConfig().getString("Fines.")).get(i)).getUniqueId().toString()));
              
            }
    But it doesnt work. It doesnt give me any errors. The config should look like this.

    Code:
    Fines:
        673616jdaui-37177j (This is a fictional UUID): 10
        y4y27y76tg4t76-y731g3g: 40
     
  2. Offline

    Max8801

    You are looking for a configuration section you can loop through. Loop through the set of strings returned by the method getConfigurationSection("Fines").getKeys(false) and use them to retrieve values from the config.
    e.g.:
    Code:java
    1.  
    2. for(String key: getConfig().getConfigurationSection("Fines").getKeys(false)) {
    3. int value = getConfig().getInt("Fines." + key);
    4. }
    5.  
     
  3. Offline

    AlbkadDev

  4. Offline

    Max8801

    You're very welcome
     
  5. Offline

    AlbkadDev

    I just got an error. I am using
    Code:
     m.fine.put(Bukkit.getServer().getOfflinePlayer(key).getUniqueId(), value);
    To change the key into a player and then into a uuid. But it doesnt work. It doesnt give me any errors either. But when I use my name in the config it works. I want to use UUID's inside of my config for safety purposes.
     
  6. Offline

    Max8801

    So you are basically trying to fetch the UUID of a player?
     
  7. Offline

    AlbkadDev

    Ye. I am trying to get the uuid from the config and then use it as a uuid. So I turn it into a player then into a uuid.
     
  8. Offline

    Max8801

    Why don't you just store the UUID rather than the name in the config ?
     
  9. Offline

    AlbkadDev

     
  10. Offline

    Max8801

    Ah, okay, then use
    Code:java
    1.  
    2. UUID uuid = UUID.fromString(yourUUIDAsString);
    3.  

    instead of using offline players
     
  11. Offline

    AlbkadDev

    Ok Thx
     
Thread Status:
Not open for further replies.

Share This Page