From 7be0acfd705b7120703940048b7801d1218a6598 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 2 Dec 2017 11:18:56 +0200 Subject: [PATCH] Refactored ThemeConfig --- .../plan/settings/theme/ThemeConfig.java | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/theme/ThemeConfig.java b/Plan/src/main/java/com/djrapitops/plan/settings/theme/ThemeConfig.java index 9391a1dd2..8616ef239 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/theme/ThemeConfig.java +++ b/Plan/src/main/java/com/djrapitops/plan/settings/theme/ThemeConfig.java @@ -30,33 +30,7 @@ public class ThemeConfig extends Config { } private static List getDefaults(String fileName) throws IOException { - String fileLocation = "themes/"; - - switch (fileName.toLowerCase()) { - case "mute": - case "lowsaturation": - fileLocation += "mute.yml"; - break; - case "pastel": - case "brigth": - case "saturated": - case "high": - fileLocation += "pastel.yml"; - break; - case "sepia": - case "brown": - fileLocation += "sepia.yml"; - break; - case "grey": - case "gray": - case "greyscale": - case "grayscale": - fileLocation += "greyscale.yml"; - break; - default: - fileLocation += "theme.yml"; - break; - } + String fileLocation = getFileLocation(fileName); IPlan plugin = MiscUtils.getIPlan(); try { @@ -66,10 +40,36 @@ public class ThemeConfig extends Config { } } + private static String getFileLocation(String fileName) { + switch (fileName.toLowerCase()) { + case "mute": + case "lowsaturation": + return "themes/mute.yml"; + case "pastel": + case "bright": + case "harsh": + case "saturated": + case "high": + return "themes/pastel.yml"; + case "sepia": + case "brown": + return "themes/sepia.yml"; + case "grey": + case "gray": + case "greyscale": + case "grayscale": + return "themes/greyscale.yml"; + default: + return "themes/theme.yml"; + } + } + private static File getConfigFile() throws IOException { File folder = MiscUtils.getIPlan().getDataFolder(); - folder.mkdirs(); + if (!folder.exists()) { + folder.mkdirs(); + } File themeFile = new File(folder, "theme.yml"); if (!themeFile.exists()) { themeFile.createNewFile();