Creating config

Discussion in 'Plugin Development' started by Clybzotik, Jan 12, 2019 at 11:23 AM.

  1. Offline

    Clybzotik

    Hello, I wanted to create a plugin config, but I encountered the following problem: I can't get a config with this code, the file just does not appear.
    PHP:
    public void OnEnable() {
            
    File config = new File(getDataFolder() + File.separator  "config.yml");
            if(!
    config.exists()) {
                
    getConfig().options().copyDefaults(true);
                
    saveDefaultConfig();
                
    getLogger().info("Create config...");
            }
    }
     
  2. Offline

    timtower Ninja on the waves Moderator

    @Clybzotik It needs to be onEnable, not OnEnable.
     
  3. Offline

    Clybzotik

    Realy?
    Yes, the problem was exactly that, thanks
     
  4. Offline

    KarimAKL

    @Clybzotik Pretty sure 'saveDefaultConfig();' should be enough to create the config, why all the other code? Just asking because i'm curious.
     

Share This Page