/*
 * Copyright (c) 2013
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
 * and associated documentation files (the "Software"), to deal in the Software without restriction,
 * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do
 * so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or substantial
 * portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
 * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package net.alexben.JustAFK;

import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;

public class ConfigAccessor
{
	private final String fileName;
	private final JavaPlugin plugin;

	private File configFile;
	private FileConfiguration fileConfiguration;

	public ConfigAccessor(JavaPlugin plugin, String fileName)
	{
		if(plugin == null) throw new IllegalArgumentException("Plugin can't be null.");
		if(!plugin.isInitialized()) throw new IllegalArgumentException("Plugin must be initialized.");
		this.plugin = plugin;
		this.fileName = fileName;
		File dataFolder = plugin.getDataFolder();
		if(dataFolder == null) throw new IllegalStateException();
		this.configFile = new File(plugin.getDataFolder(), fileName);
		saveDefaultConfig();
	}

	public void reloadConfig()
	{
		fileConfiguration = YamlConfiguration.loadConfiguration(configFile);

		// Look for defaults in the jar
		InputStream defConfigStream = plugin.getResource(fileName);
		if(defConfigStream != null)
		{
			YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
			fileConfiguration.setDefaults(defConfig);
		}
	}

	public FileConfiguration getConfig()
	{
		if(fileConfiguration == null)
		{
			this.reloadConfig();
		}
		return fileConfiguration;
	}

	public void saveConfig()
	{
		if(fileConfiguration == null || configFile == null)
		{
			return;
		}
		else
		{
			try
			{
				getConfig().save(configFile);
			}
			catch(IOException ex)
			{
				plugin.getLogger().log(Level.SEVERE, "Could not save config to " + configFile, ex);
			}
		}
	}

	public void saveDefaultConfig()
	{
		if(!configFile.exists())
		{
			this.plugin.saveResource(fileName, false);
		}
	}

}

@@ -2608,18 +2608,18 @@
 ion 
-=
+!
 = null 
-%7C%7C
+&&
  con
@@ -2626,17 +2626,17 @@
 figFile 
-=
+!
 = null)%0A
@@ -2643,34 +2643,8 @@
 %09%09%7B%0A
-%09%09%09return;%0A%09%09%7D%0A%09%09else%0A%09%09%7B%0A
 %09%09%09t

Fix control flow issue.