From 01235ff3981f7a2fe1924a0a49dc1813ca0ef705 Mon Sep 17 00:00:00 2001 From: NuclearW Date: Thu, 17 May 2012 21:02:26 -0400 Subject: [PATCH] isInJar --- src/main/java/com/gmail/nossr50/mcMMO.java | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 250ec12c9..d05a30b3d 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -361,9 +361,9 @@ public class mcMMO extends JavaPlugin { } treasuresConfig = YamlConfiguration.loadConfiguration(treasuresConfigFile); - InputStream defConfigStream = getResource("treasures.yml"); // Look for defaults in the jar - if (defConfigStream != null) { + if (isInJar("treasures.yml")) { + InputStream defConfigStream = getResource("treasures.yml"); YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream); treasuresConfig.setDefaults(defConfig); } @@ -414,9 +414,9 @@ public class mcMMO extends JavaPlugin { } toolsConfig = YamlConfiguration.loadConfiguration(toolsConfigFile); - InputStream defConfigStream = getResource("tools.yml"); // Look for defaults in the jar - if (defConfigStream != null) { + if (isInJar("tools.yml")) { + InputStream defConfigStream = getResource("tools.yml"); YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream); toolsConfig.setDefaults(defConfig); } @@ -467,9 +467,9 @@ public class mcMMO extends JavaPlugin { } armorConfig = YamlConfiguration.loadConfiguration(armorConfigFile); - InputStream defConfigStream = getResource("armor.yml"); // Look for defaults in the jar - if (defConfigStream != null) { + if (isInJar("armor.yml")) { + InputStream defConfigStream = getResource("armor.yml"); YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream); armorConfig.setDefaults(defConfig); } @@ -520,9 +520,9 @@ public class mcMMO extends JavaPlugin { } blocksConfig = YamlConfiguration.loadConfiguration(blocksConfigFile); - InputStream defConfigStream = getResource("blocks.yml"); // Look for defaults in the jar - if (defConfigStream != null) { + if (isInJar("blocks.yml")) { + InputStream defConfigStream = getResource("blocks.yml"); YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream); blocksConfig.setDefaults(defConfig); } @@ -556,4 +556,9 @@ public class mcMMO extends JavaPlugin { getLogger().severe("Could not save config to " + blocksConfigFile + ex.toString()); } } + + public boolean isInJar(String resource) { + InputStream iStream = getResource(resource); + return iStream != null; + } }