Getting values from config.

Discussion in 'Spigot Plugin Development' started by Leonwilber, Jun 30, 2016.

  1. I want a config set out like:
    Code (Text):
    Player:
      playername:
        StringList:
          - 'string 1'
          - 'string 2'
          - 'string 3'
    However
    Code (Text):
    getConfig().getStringList("Players."+ playername.toLowerCase()+ "StringList").contains(keyword.toLowerCase()
    wont work for some reason.
     
  2. I wouldn't save it with playernames.. they can be changed. Use UUIDs. Player#getUniqueId

    Anyway, your problem is, in the code you're trying to get "Players."... and in the config it's "Player."
     
  3. Ill use the uuid thanks for sugesting. I missed typed the config its:

    Code (Text):
    Players:
      playername:
        StringList:
          - 'string 1'
          - 'string 2'
          - 'string 3'
    But still have the same issue
     
  4. Well I assume in the config you actually have your real playername, not just "playername", correct?
     
  5. Use:
    Code (Text):
    getConfig().getStringList("Players."+playername.toLowerCase()+".StringList")
    You forgot the dot (".StringList")
     
    • Agree Agree x 2
    • Like Like x 1