From 8632baed2701577f36d0d16e742b690660488693 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 7 Oct 2013 11:54:23 -0400 Subject: [PATCH] No reason to handle this ourselves, Bukkit does it for us. --- .../gmail/nossr50/config/ConfigLoader.java | 56 +------------------ 1 file changed, 2 insertions(+), 54 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java b/src/main/java/com/gmail/nossr50/config/ConfigLoader.java index ae1c63941..2e8b0c804 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigLoader.java @@ -1,11 +1,6 @@ package com.gmail.nossr50.config; import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; import java.util.List; import org.bukkit.configuration.file.FileConfiguration; @@ -16,7 +11,7 @@ import com.gmail.nossr50.mcMMO; public abstract class ConfigLoader { protected static final mcMMO plugin = mcMMO.p; protected String fileName; - protected File configFile; + private File configFile; protected FileConfiguration config; public ConfigLoader(String relativePath, String fileName) { @@ -34,7 +29,7 @@ public abstract class ConfigLoader { protected void loadFile() { if (!configFile.exists()) { plugin.debug("Creating mcMMO " + fileName + " File..."); - createFile(); + plugin.saveResource(fileName, false); } else { plugin.debug("Loading mcMMO " + fileName + " File..."); @@ -45,53 +40,6 @@ public abstract class ConfigLoader { protected abstract void loadKeys(); - protected void createFile() { - configFile.getParentFile().mkdirs(); - - InputStream inputStream = plugin.getResource(fileName); - - if (inputStream == null) { - plugin.getLogger().severe("Missing resource file: '" + fileName + "' please notify the plugin authors"); - return; - } - - OutputStream outputStream = null; - - try { - outputStream = new FileOutputStream(configFile); - - int read; - byte[] bytes = new byte[1024]; - - while ((read = inputStream.read(bytes)) != -1) { - outputStream.write(bytes, 0, read); - } - } - catch (FileNotFoundException e) { - e.printStackTrace(); - } - catch (IOException e) { - e.printStackTrace(); - } - finally { - if (outputStream != null) { - try { - outputStream.close(); - } - catch (IOException e) { - e.printStackTrace(); - } - } - - try { - inputStream.close(); - } - catch (IOException e) { - e.printStackTrace(); - } - } - } - protected boolean validateKeys() { return true; }