Change how authme reload works, but don't forget ...

This commit is contained in:
Xephi59 2015-07-06 18:02:44 +02:00
parent e021a32f1f
commit 6aad66b731
2 changed files with 37 additions and 38 deletions

View File

@ -17,10 +17,6 @@ import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import me.muizers.Notifications.Notifications;
import net.citizensnpcs.Citizens;
import net.milkbowl.vault.permission.Permission;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -74,6 +70,9 @@ import fr.xephi.authme.settings.OtherAccounts;
import fr.xephi.authme.settings.PlayersLogs; import fr.xephi.authme.settings.PlayersLogs;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.Spawn; import fr.xephi.authme.settings.Spawn;
import me.muizers.Notifications.Notifications;
import net.citizensnpcs.Citizens;
import net.milkbowl.vault.permission.Permission;
public class AuthMe extends JavaPlugin { public class AuthMe extends JavaPlugin {
@ -200,37 +199,7 @@ public class AuthMe extends JavaPlugin {
else ConsoleLogger.showError("Error while making Backup"); else ConsoleLogger.showError("Error while making Backup");
} }
/* setupDatabase();
* Backend MYSQL - FILE - SQLITE
*/
switch (Settings.getDataSource) {
case FILE:
FlatFile fileThread = new FlatFile();
database = fileThread;
final int a = database.getAccountsRegistered();
if (a >= 1000) {
ConsoleLogger.showError("YOU'RE USING FILE DATABASE WITH " + a + "+ ACCOUNTS, FOR BETTER PERFORMANCES, PLEASE USE MYSQL!!");
}
break;
case MYSQL:
MySQL sqlThread = new MySQL();
database = sqlThread;
break;
case SQLITE:
SQLite sqliteThread = new SQLite();
database = sqliteThread;
final int b = database.getAccountsRegistered();
if (b >= 2000) {
ConsoleLogger.showError("YOU'RE USING SQLITE DATABASE WITH " + b + "+ ACCOUNTS, FOR BETTER PERFORMANCES, PLEASE USE MYSQL!!");
}
break;
}
if (Settings.isCachingEnabled) {
database = new CacheDataSource(this, database);
}
database = new DatabaseCalls(this, database);
dataManager = new DataManager(this, database); dataManager = new DataManager(this, database);
@ -511,8 +480,8 @@ public class AuthMe extends JavaPlugin {
return authme; return authme;
} }
public void savePlayer(Player player) throws IllegalStateException, public void savePlayer(Player player)
NullPointerException { throws IllegalStateException, NullPointerException {
try { try {
if ((citizens.isNPC(player, this)) || (Utils.getInstance().isUnrestricted(player)) || (CombatTagComunicator.isNPC(player))) { if ((citizens.isNPC(player, this)) || (Utils.getInstance().isUnrestricted(player)) || (CombatTagComunicator.isNPC(player))) {
return; return;
@ -827,4 +796,33 @@ public class AuthMe extends JavaPlugin {
} }
return realIP; return realIP;
} }
public void setupDatabase() {
/*
* Backend MYSQL - FILE - SQLITE
*/
switch (Settings.getDataSource) {
case FILE:
database = new FlatFile();
final int a = database.getAccountsRegistered();
if (a >= 1000)
ConsoleLogger.showError("YOU'RE USING FILE DATABASE WITH " + a + "+ ACCOUNTS, FOR BETTER PERFORMANCES, PLEASE USE MYSQL!!");
break;
case MYSQL:
database = new MySQL();
break;
case SQLITE:
database = new SQLite();
final int b = database.getAccountsRegistered();
if (b >= 2000)
ConsoleLogger.showError("YOU'RE USING SQLITE DATABASE WITH " + b + "+ ACCOUNTS, FOR BETTER PERFORMANCES, PLEASE USE MYSQL!!");
break;
}
if (Settings.isCachingEnabled) {
database = new CacheDataSource(this, database);
}
database = new DatabaseCalls(this, database);
}
} }

View File

@ -125,7 +125,6 @@ public class AdminCommand implements CommandExecutor {
return true; return true;
} }
} else if (args[0].equalsIgnoreCase("reload")) { } else if (args[0].equalsIgnoreCase("reload")) {
database.reload();
File newConfigFile = new File("plugins" + File.separator + "AuthMe", "config.yml"); File newConfigFile = new File("plugins" + File.separator + "AuthMe", "config.yml");
if (!newConfigFile.exists()) { if (!newConfigFile.exists()) {
InputStream fis = getClass().getResourceAsStream("" + File.separator + "config.yml"); InputStream fis = getClass().getResourceAsStream("" + File.separator + "config.yml");
@ -156,6 +155,8 @@ public class AdminCommand implements CommandExecutor {
Settings.reloadConfigOptions(newConfig); Settings.reloadConfigOptions(newConfig);
m.reLoad(); m.reLoad();
s.reLoad(); s.reLoad();
plugin.database.close();
plugin.setupDatabase();
m.send(sender, "reload"); m.send(sender, "reload");
} else if (args[0].equalsIgnoreCase("lastlogin")) { } else if (args[0].equalsIgnoreCase("lastlogin")) {
if (args.length != 2) { if (args.length != 2) {