Solved getConfig().getStringList()

Discussion in 'Spigot Plugin Development' started by fishy_ydrib, Jan 11, 2020.

  1. Hello. I am new to coding Spigot plugins and I would like to get a list of strings from my config. However, I want to use it in a class besides my main class (that extends JavaPlugin). I was wondering how I can use the string list in my other class.

    Thanks!
     
  2. You would want to hook into the main class with putting an "instance" in it.
    Put this in your main class:
    Code (Text):
    private static (MainClass) instance;

    public void onEnable(){
        instance = this;
    }

    public static (MainClass) getInstance() {
        return instance;
    }
    Then you want to do this in your other class:
    Code (Text):
    (MainClass).getInstance().getConfig().getStringList("")
     
    • Useful Useful x 2
  3. Thank you so much!