Solved multiple config.yml

Discussion in 'Plugin Development' started by xelatercero, Oct 11, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    xelatercero

    i have a default config file created, but now i have made another one , and i call it in other classes with an instance, for example:

    PHP:
    Main plugin;
        
        public 
    home(Main instance) {
        
    plugin instance;
        }
    and i have made a new one called data.yml:

    PHP:
    FileConfiguration data YamlConfiguration.loadConfiguration(new File(getDataFolder(), "data.yml"));
            
    data.options().copyDefaults(true);
            
    saveConfig();
    my question is: how i can use the data.yml in other classes i mean if i do plugin.getConfig, i am getting the default config file but i want to get the data.yml, how i do it
     
  2. @xelatercero
    You could either make a method to get the special yml file in the main class, or just use YamlConfiguration.loadConfiguration() in the other class.
     
  3. Offline

    xelatercero

    @AlvinB
    PHP:
    FileConfiguration data YamlConfiguration.loadConfiguration(getResource("data.yml"))
    This dont work, i mean i have an error i cant use this, why?
     
  4. @xelatercero
    The getResource method gets stuff that is packaged inside the jar file of your plugin. Are you sure there is a data.yml file in your plugins jar file?
     
  5. Offline

    xelatercero

    @AlvinB YamlConfiguration.loadConfiguration("data"); but this dont work i put this and drop an error
     
  6. @xelatercero
    You have to put in a File Object.
    Code:java
    1. YamlConfiguration.loadConfiguration(new File("myfile.yml"))
     
  7. Offline

    xelatercero

    @AlvinB omg i am so stupid, thanks!!!
     
Thread Status:
Not open for further replies.

Share This Page