0

Deleted FolderRegistry

This commit is contained in:
Pepich 2017-02-02 20:29:11 +01:00
parent d89761c436
commit cce1fdaf4a
5 changed files with 10 additions and 78 deletions

View File

@ -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);

View File

@ -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;
}
}
}

View File

@ -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<Serializable, Serializable> 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)
{

View File

@ -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<Serializable, Serializable> mysqlCredentials = new HashMap<>();
File mysqlCredentialsFile = new File(FolderRegistry.configFolder, "mysqlCredentials.json");
File mysqlCredentialsFile = new File(Main.plugin.getDataFolder(), "mysqlCredentials.json");
if (mysqlCredentialsFile.exists())
{
try

View File

@ -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<String, SpamInput> inputs;
boolean changingInput = false;
List<Material> 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<Material>();
Collections.addAll(acceptedInputs, Material.WOOD_BUTTON, Material.STONE_BUTTON, Material.LEVER);