Bug with get strings from config.yml

Discussion in 'Plugin Development' started by SlayZBro, Jul 10, 2018.

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

    SlayZBro

    I have config file like this
    Code:
    mute:
      SlayZBro:
        time: 30
        reason: dsa
      MrBahur:
        time: 30
        reason: dsa
    
    And I was trying to get the name 'SlayZBro' & 'MrBahur' and print them every second in the server with this code:
    Code:
    public void runnable() {
            new BukkitRunnable() {   
                @Override
                public void run() {
                        for(String x : getConfig().getStringList("mute"))
                            Bukkit.broadcastMessage(x);               
                }
            }.runTaskTimerAsynchronously(this, 0, 20);
        }
    (I added the method runnable into onEnable).
     
  2. Offline

    MemeplexOwner

    getStringList() is for a list like this:
    Code:
    mute:
      something:
        - 1
        - 2
        - 3
    (if i remember correctly)
    
    after mute.SlayZBro there is no list so you'd need to add "-" before time and reason and indent properly.

    Might I add it seems you don't know config.yml paths properly. Don't know how to help you there but you can search google on how config.yml syntax works (and how to get values from it).

    Sorry if it's confusing tag me if you need help.
     
  3. Offline

    SlayZBro

  4. Offline

    MemeplexOwner

    What is the problem? Did you try what I said? Also once you get the list you can't store it as a String as it's a list.
     
  5. Offline

    SlayZBro

  6. Offline

    Reflxction

    What you're probably looking for is config.getConfigurationSection("mutes").getKeys(false), which returns a set of strings. Loop through that or do your thing

    Sent from my TRT-L21A using Tapatalk
     
Thread Status:
Not open for further replies.

Share This Page