From cce1fdaf4af3fad1b79b6094e76c105f1084705a Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 2 Feb 2017 20:29:11 +0100 Subject: [PATCH] Deleted FolderRegistry --- src/com/redstoner/misc/Main.java | 4 +- .../redstoner/misc/mysql/FolderRegistry.java | 68 ------------------- src/com/redstoner/misc/mysql/JSONManager.java | 6 +- .../redstoner/misc/mysql/MysqlHandler.java | 3 +- .../redstoner/modules/damnspam/DamnSpam.java | 7 +- 5 files changed, 10 insertions(+), 78 deletions(-) delete mode 100644 src/com/redstoner/misc/mysql/FolderRegistry.java diff --git a/src/com/redstoner/misc/Main.java b/src/com/redstoner/misc/Main.java index 79130ff..332e099 100644 --- a/src/com/redstoner/misc/Main.java +++ b/src/com/redstoner/misc/Main.java @@ -5,7 +5,6 @@ import org.bukkit.plugin.java.JavaPlugin; import com.redstoner.annotations.Version; import com.redstoner.coremods.debugger.Debugger; import com.redstoner.coremods.moduleLoader.ModuleLoader; -import com.redstoner.misc.mysql.FolderRegistry; import com.redstoner.misc.mysql.MysqlHandler; import com.redstoner.modules.adminchat.Adminchat; import com.redstoner.modules.adminnotes.AdminNotes; @@ -23,7 +22,7 @@ import com.redstoner.modules.warn.Warn; /** Main class. Duh. * * @author Pepich */ -@Version(major = 1, minor = 2, revision = 5, compatible = -1) +@Version(major = 1, minor = 3, revision = 0, compatible = -1) public class Main extends JavaPlugin { public static JavaPlugin plugin; @@ -34,7 +33,6 @@ public class Main extends JavaPlugin plugin = this; Debugger.init(); ModuleLoader.init(); - FolderRegistry.init(); MysqlHandler.init(); // TODO: ModuleLoader.addModule(Answerbot.class); ModuleLoader.addModule(Adminchat.class); diff --git a/src/com/redstoner/misc/mysql/FolderRegistry.java b/src/com/redstoner/misc/mysql/FolderRegistry.java deleted file mode 100644 index 4f9b368..0000000 --- a/src/com/redstoner/misc/mysql/FolderRegistry.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.redstoner.misc.mysql; - -import java.io.File; - -import com.redstoner.misc.Main; - -public class FolderRegistry -{ - public static File moduleFolder, configFolder, commandFolder, tempFolder; - - public static void init() - { - File dataFolder = Main.plugin.getDataFolder(); - moduleFolder = new File(dataFolder, "modules/"); - configFolder = new File(dataFolder, "config/"); - commandFolder = new File(dataFolder, "commands/"); - tempFolder = new File(dataFolder, "temp/"); - if (!moduleFolder.exists()) - { - moduleFolder.mkdirs(); - } - if (!configFolder.exists()) - { - configFolder.mkdirs(); - } - if (!commandFolder.exists()) - { - commandFolder.mkdirs(); - } - if (tempFolder.exists()) - { - deleteFolder(tempFolder); - } - if (!tempFolder.exists()) - { - tempFolder.mkdirs(); - } - } - - public static boolean deleteFolder(File folder) - { - for (File file : folder.listFiles()) - { - if (file.isDirectory()) - { - if (!deleteFolder(file)) - { - return false; - } - } - else - { - if (!file.delete()) - { - return false; - } - } - } - if (folder.delete()) - { - return true; - } - else - { - return false; - } - } -} diff --git a/src/com/redstoner/misc/mysql/JSONManager.java b/src/com/redstoner/misc/mysql/JSONManager.java index b40676a..ae248d5 100644 --- a/src/com/redstoner/misc/mysql/JSONManager.java +++ b/src/com/redstoner/misc/mysql/JSONManager.java @@ -18,11 +18,13 @@ import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; +import com.redstoner.misc.Main; + public class JSONManager { public static Map getConfiguration(String fileName) { - File file = new File(FolderRegistry.configFolder, fileName); + File file = new File(Main.plugin.getDataFolder(), fileName); if (!file.exists()) { try @@ -51,7 +53,7 @@ public class JSONManager { try { - saveMap(new File(FolderRegistry.configFolder, fileName), config); + saveMap(new File(Main.plugin.getDataFolder(), fileName), config); } catch (IOException e) { diff --git a/src/com/redstoner/misc/mysql/MysqlHandler.java b/src/com/redstoner/misc/mysql/MysqlHandler.java index 6245c5d..909d276 100644 --- a/src/com/redstoner/misc/mysql/MysqlHandler.java +++ b/src/com/redstoner/misc/mysql/MysqlHandler.java @@ -17,6 +17,7 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.json.simple.parser.ParseException; +import com.redstoner.misc.Main; import com.redstoner.misc.mysql.elements.MysqlDatabase; public class MysqlHandler @@ -34,7 +35,7 @@ public class MysqlHandler public static void init() { Map mysqlCredentials = new HashMap<>(); - File mysqlCredentialsFile = new File(FolderRegistry.configFolder, "mysqlCredentials.json"); + File mysqlCredentialsFile = new File(Main.plugin.getDataFolder(), "mysqlCredentials.json"); if (mysqlCredentialsFile.exists()) { try diff --git a/src/com/redstoner/modules/damnspam/DamnSpam.java b/src/com/redstoner/modules/damnspam/DamnSpam.java index 72a7716..cc8c952 100644 --- a/src/com/redstoner/modules/damnspam/DamnSpam.java +++ b/src/com/redstoner/modules/damnspam/DamnSpam.java @@ -33,15 +33,15 @@ import org.json.simple.parser.ParseException; import com.nemez.cmdmgr.Command; import com.redstoner.annotations.AutoRegisterListener; import com.redstoner.annotations.Version; -import com.redstoner.misc.mysql.FolderRegistry; +import com.redstoner.misc.Main; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 1, minor = 0, revision = 0, compatible = 1) +@Version(major = 1, minor = 1, revision = 0, compatible = 1) public class DamnSpam implements Module, Listener { private boolean enabled = false; - File configFile; + File configFile = new File(Main.plugin.getDataFolder(), "DamnSpam.json"); Map inputs; boolean changingInput = false; List acceptedInputs; @@ -53,7 +53,6 @@ public class DamnSpam implements Module, Listener @Override public void onEnable() { - configFile = new File(FolderRegistry.configFolder, "DamnSpam.json"); loadInputs(); acceptedInputs = new ArrayList(); Collections.addAll(acceptedInputs, Material.WOOD_BUTTON, Material.STONE_BUTTON, Material.LEVER);