Solved Getting any value from another file other than the config.yml

Discussion in 'Spigot Plugin Development' started by Wilsoon, Feb 14, 2020.

  1. I'm making more redundant posts...
    But, what do I need to make another file and get any details from it other than the config.yml?
     
  2. Code (Text):
    private File data;
    private FileConfiguration datacfg;


    public void createData() {
            data = new File(getDataFolder(),"data.yml");
            if(!data.exists()) {
                data.getParentFile().mkdirs();
                saveResource("data.yml",false);
            }
            datacfg = new YamlConfiguration();
            try {
                datacfg.load(data);
            }catch (IOException | InvalidConfigurationException e) {
                e.printStackTrace();
            }
        }
        public void saveData() throws IOException{
                datacfg.save(data);
        }
        public FileConfiguration getData() {
            return this.datacfg;
        }
     
    Also as config.yml a file named data.yml must be created

    Requires you the ability to actually get the plugin instance known(aka knowing how to create/get instances)
     
    #2 Stellrow, Feb 14, 2020
    Last edited: Feb 14, 2020
    • Like Like x 1
  3. Thanks for the quick reply!