Move stopPlugin() to GeneralMethods

This commit is contained in:
Jack Lin 2015-07-12 01:23:56 +12:00
parent 086128f8fa
commit 3805b2342b
3 changed files with 7 additions and 6 deletions

View file

@ -20,7 +20,7 @@ public class DBConnection {
sql = new MySQL(ProjectKorra.log, "[ProjectKorra] Establishing MySQL Connection...", host, port, user, pass, db); sql = new MySQL(ProjectKorra.log, "[ProjectKorra] Establishing MySQL Connection...", host, port, user, pass, db);
if (((MySQL) sql).open() == null) { if (((MySQL) sql).open() == null) {
ProjectKorra.log.severe("Disabling due to database error"); ProjectKorra.log.severe("Disabling due to database error");
ProjectKorra.plugin.stopPlugin(); GeneralMethods.stopPlugin();
return; return;
} }
@ -70,7 +70,7 @@ public class DBConnection {
sql = new SQLite(ProjectKorra.log, "[ProjectKorra] Establishing SQLite Connection.", "projectkorra.db", ProjectKorra.plugin.getDataFolder().getAbsolutePath()); sql = new SQLite(ProjectKorra.log, "[ProjectKorra] Establishing SQLite Connection.", "projectkorra.db", ProjectKorra.plugin.getDataFolder().getAbsolutePath());
if (((SQLite) sql).open() == null) { if (((SQLite) sql).open() == null) {
ProjectKorra.log.severe("Disabling due to database error"); ProjectKorra.log.severe("Disabling due to database error");
ProjectKorra.plugin.stopPlugin(); GeneralMethods.stopPlugin();
return; return;
} }

View file

@ -1691,6 +1691,10 @@ public class GeneralMethods {
TempBlock.removeAll(); TempBlock.removeAll();
MultiAbilityManager.removeAll(); MultiAbilityManager.removeAll();
} }
public static void stopPlugin() {
plugin.getServer().getPluginManager().disablePlugin(plugin);
}
public static void writeToDebug(String message) { public static void writeToDebug(String message) {
try { try {

View file

@ -64,7 +64,7 @@ public class ProjectKorra extends JavaPlugin {
DBConnection.user = getConfig().getString("Storage.MySQL.user"); DBConnection.user = getConfig().getString("Storage.MySQL.user");
DBConnection.init(); DBConnection.init();
if (DBConnection.isOpen() == false) { if (DBConnection.isOpen() == false) {
//TODO: Log a proper message displaying database problem, pk will not function //Message is logged by DBConnection
return; return;
} }
@ -103,7 +103,4 @@ public class ProjectKorra extends JavaPlugin {
handler.close(); handler.close();
} }
public void stopPlugin() {
getServer().getPluginManager().disablePlugin(plugin);
}
} }