1.16.5 How to get a list of strings from config?

Discussion in 'Spigot Plugin Development' started by Bluehawk409, Jun 14, 2021.

  1. Hello, I am having some trouble with trying to get a list of strings from. I use:
    Code (Text):

    but I'm not sure how I would write it in the config since this doesn't work:
    Code (Text):
    I know this is definitely a dumb question but I'm new to config and all.
  2. If you put the : at the end then that key points to a value. Since oak_planks and obsidian have it, environments.1.blocks is not a list is a configuration section.

    Code (YAML):
         - "oak_planks"
         - "obsidian"
    now it is a string list, to get it you do plugin.getConfig().getStringList("environments.1.blocks")
    • Agree Agree x 2
    • Winner Winner x 1
  3. Thank you! Is there any way to get the number of entries inside of "blocks:"?
  4. It's actually super easy, all you have to do is
    Code (Java):
    If you are using something like IntelliJ or Eclipse you should have auto completion which can generally be used to find small stuff like this out, in this case I could even find this out without an IDE using the JavaDocs! https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/util/List.html#size
    The docs are one of your best friends when developing.