Help with Config files. How to create config.yml if it does not exist?

Discussion in 'Plugin Development' started by heylookoverthere, Aug 22, 2011.

Thread Status:
Not open for further replies.
  1. this code (taken and edited from a tutorial) works fine if you have a config.yml, but if you don't it give and IO exception.

    Code:
    		Configuration configFile;
    		File file =new File("plugins/BananaMapCycler/", "config.yml");
    		if (!file.exists()) {
    			try {
    				    file.createNewFile();
    				} catch (IOException e) {
    					e.printStackTrace();
    				}
    			configFile = new Configuration(file);
    			configFile.setProperty("use-permissions", true);
    			configFile.save();        			
    		}else
    		{
    			configFile = new Configuration(file);
    			configFile.load();
    			perms=configFile.getBoolean("use-permissions", true);
    		}
    	}
    
    
    Thanks for any help.
     
  2. Offline

    thehutch

    Its much easier if you just use

    Code:
    Configuration config = getConfiguration();
     
    NeoSilky likes this.
Thread Status:
Not open for further replies.

Share This Page