Solved How to save everything from a config to an ArrayList?

Discussion in 'Spigot Plugin Development' started by KevinDasPikachu, Aug 4, 2020.

Thread Status:
Not open for further replies.
  1. I have a config where I save words like
    word0: wawdadawda
    word1: waeaeaeaeae
    word2: adadadadada
    and so on.How would I get those words to be in a List<String> words = new ArrayList<> efficiently? My only way to do this is with if else or switch bu there has to be another way. I am sorry if this isn't an API related question (I don't know if configs are from Bukkit or not but I suppose they aren't). I would ask on StackOverflow but people there are toxic.
  2. You shouldn't store them like that if you're gonna get them into an ArrayList

    They should be set as:

    - word1
    - word2

    then do List<String> words = new ArrayList<>(getConfig().getStringList("words"));
  3. List<String> words = new ArrayList<>(getConfig().getStringList("words")); doesn't seem to work
  4. Yes because you're not setting them as a list.
    You need to set them as a list like I showed you.
Thread Status:
Not open for further replies.