Remember to sync before pushing!

This commit is contained in:
Maxetto 2015-07-10 17:02:57 +02:00
parent d52e242c53
commit 91a4afb41f

View File

@ -33,7 +33,6 @@ import fr.xephi.authme.Utils.groupType;
import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache; import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.SpawnTeleportEvent; import fr.xephi.authme.events.SpawnTeleportEvent;
import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
@ -46,10 +45,8 @@ public class AdminCommand implements CommandExecutor {
public AuthMe plugin; public AuthMe plugin;
private Messages m = Messages.getInstance(); private Messages m = Messages.getInstance();
public DataSource database;
public AdminCommand(AuthMe plugin, DataSource database) { public AdminCommand(AuthMe plugin) {
this.database = database;
this.plugin = plugin; this.plugin = plugin;
} }
@ -117,7 +114,7 @@ public class AdminCommand implements CommandExecutor {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, -(Integer.parseInt(args[1]))); calendar.add(Calendar.DATE, -(Integer.parseInt(args[1])));
long until = calendar.getTimeInMillis(); long until = calendar.getTimeInMillis();
List<String> purged = database.autoPurgeDatabase(until); List<String> purged = plugin.database.autoPurgeDatabase(until);
sender.sendMessage("Deleted " + purged.size() + " user accounts"); sender.sendMessage("Deleted " + purged.size() + " user accounts");
if (Settings.purgeEssentialsFile && plugin.ess != null) if (Settings.purgeEssentialsFile && plugin.ess != null)
plugin.dataManager.purgeEssentials(purged); plugin.dataManager.purgeEssentials(purged);
@ -172,7 +169,7 @@ public class AdminCommand implements CommandExecutor {
return true; return true;
} }
try { try {
PlayerAuth auth = database.getAuth(args[1].toLowerCase()); PlayerAuth auth = plugin.database.getAuth(args[1].toLowerCase());
} catch (NullPointerException e) { } catch (NullPointerException e) {
m.send(sender, "unknown_user"); m.send(sender, "unknown_user");
return true; return true;
@ -203,7 +200,7 @@ public class AdminCommand implements CommandExecutor {
PlayerAuth auth = null; PlayerAuth auth = null;
String message = "[AuthMe] "; String message = "[AuthMe] ";
try { try {
auth = database.getAuth(args[1].toLowerCase()); auth = plugin.database.getAuth(args[1].toLowerCase());
} catch (NullPointerException npe) { } catch (NullPointerException npe) {
m.send(sender, "unknown_user"); m.send(sender, "unknown_user");
return true; return true;
@ -212,7 +209,7 @@ public class AdminCommand implements CommandExecutor {
m.send(sender, "unknown_user"); m.send(sender, "unknown_user");
return true; return true;
} }
List<String> accountList = database.getAllAuthsByName(auth); List<String> accountList = plugin.database.getAllAuthsByName(auth);
if (accountList.isEmpty() || accountList == null) { if (accountList.isEmpty() || accountList == null) {
m.send(sender, "user_unknown"); m.send(sender, "user_unknown");
return true; return true;
@ -246,7 +243,7 @@ public class AdminCommand implements CommandExecutor {
sender.sendMessage("[AuthMe] Please put a valid IP"); sender.sendMessage("[AuthMe] Please put a valid IP");
return; return;
} }
List<String> accountList = database.getAllAuthsByIp(args[1]); List<String> accountList = plugin.database.getAllAuthsByIp(args[1]);
if (accountList.isEmpty() || accountList == null) { if (accountList.isEmpty() || accountList == null) {
sender.sendMessage("[AuthMe] This IP does not exist in the database"); sender.sendMessage("[AuthMe] This IP does not exist in the database");
return true; return true;
@ -298,7 +295,7 @@ public class AdminCommand implements CommandExecutor {
} }
try { try {
String name = args[1].toLowerCase(); String name = args[1].toLowerCase();
if (database.isAuthAvailable(name)) { if (plugin.database.isAuthAvailable(name)) {
m.send(sender, "user_regged"); m.send(sender, "user_regged");
return true; return true;
} }
@ -307,7 +304,7 @@ public class AdminCommand implements CommandExecutor {
if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null) if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null)
auth.setSalt(PasswordSecurity.userSalt.get(name)); auth.setSalt(PasswordSecurity.userSalt.get(name));
else auth.setSalt(""); else auth.setSalt("");
if (!database.saveAuth(auth)) { if (!plugin.database.saveAuth(auth)) {
m.send(sender, "error"); m.send(sender, "error");
return true; return true;
} }
@ -324,7 +321,7 @@ public class AdminCommand implements CommandExecutor {
return true; return true;
} }
String playername = args[1].toLowerCase(); String playername = args[1].toLowerCase();
PlayerAuth auth = database.getAuth(playername); PlayerAuth auth = plugin.database.getAuth(playername);
if (auth == null) { if (auth == null) {
m.send(sender, "unknown_user"); m.send(sender, "unknown_user");
return true; return true;
@ -341,13 +338,13 @@ public class AdminCommand implements CommandExecutor {
return true; return true;
} }
String playername = args[1].toLowerCase(); String playername = args[1].toLowerCase();
PlayerAuth auth = database.getAuth(playername); PlayerAuth auth = plugin.database.getAuth(playername);
if (auth == null) { if (auth == null) {
m.send(sender, "unknown_user"); m.send(sender, "unknown_user");
return true; return true;
} }
auth.setEmail(args[2]); auth.setEmail(args[2]);
if (!database.updateEmail(auth)) { if (!plugin.database.updateEmail(auth)) {
m.send(sender, "error"); m.send(sender, "error");
return true; return true;
} }
@ -388,7 +385,7 @@ public class AdminCommand implements CommandExecutor {
for (OfflinePlayer off : plugin.getServer().getBannedPlayers()) { for (OfflinePlayer off : plugin.getServer().getBannedPlayers()) {
bannedPlayers.add(off.getName().toLowerCase()); bannedPlayers.add(off.getName().toLowerCase());
} }
database.purgeBanned(bannedPlayers); plugin.database.purgeBanned(bannedPlayers);
if (Settings.purgeEssentialsFile && plugin.ess != null) if (Settings.purgeEssentialsFile && plugin.ess != null)
plugin.dataManager.purgeEssentials(bannedPlayers); plugin.dataManager.purgeEssentials(bannedPlayers);
if (Settings.purgePlayerDat) if (Settings.purgePlayerDat)
@ -455,8 +452,8 @@ public class AdminCommand implements CommandExecutor {
PlayerAuth auth = null; PlayerAuth auth = null;
if (PlayerCache.getInstance().isAuthenticated(name)) { if (PlayerCache.getInstance().isAuthenticated(name)) {
auth = PlayerCache.getInstance().getAuth(name); auth = PlayerCache.getInstance().getAuth(name);
} else if (database.isAuthAvailable(name)) { } else if (plugin.database.isAuthAvailable(name)) {
auth = database.getAuth(name); auth = plugin.database.getAuth(name);
} }
if (auth == null) { if (auth == null) {
m.send(sender, "unknown_user"); m.send(sender, "unknown_user");
@ -465,9 +462,9 @@ public class AdminCommand implements CommandExecutor {
auth.setHash(hash); auth.setHash(hash);
if (PasswordSecurity.userSalt.containsKey(name)) { if (PasswordSecurity.userSalt.containsKey(name)) {
auth.setSalt(PasswordSecurity.userSalt.get(name)); auth.setSalt(PasswordSecurity.userSalt.get(name));
database.updateSalt(auth); plugin.database.updateSalt(auth);
} }
if (!database.updatePassword(auth)) { if (!plugin.database.updatePassword(auth)) {
m.send(sender, "error"); m.send(sender, "error");
return true; return true;
} }
@ -484,11 +481,11 @@ public class AdminCommand implements CommandExecutor {
return true; return true;
} }
String name = args[1].toLowerCase(); String name = args[1].toLowerCase();
if (!database.isAuthAvailable(name)) { if (!plugin.database.isAuthAvailable(name)) {
m.send(sender, "user_unknown"); m.send(sender, "user_unknown");
return true; return true;
} }
if (!database.removeAuth(name)) { if (!plugin.database.removeAuth(name)) {
m.send(sender, "error"); m.send(sender, "error");
return true; return true;
} }
@ -533,7 +530,7 @@ public class AdminCommand implements CommandExecutor {
} }
try { try {
String name = args[1].toLowerCase(); String name = args[1].toLowerCase();
PlayerAuth auth = database.getAuth(name); PlayerAuth auth = plugin.database.getAuth(name);
if (auth == null) { if (auth == null) {
m.send(sender, "unknown_user"); m.send(sender, "unknown_user");
return true; return true;
@ -542,7 +539,7 @@ public class AdminCommand implements CommandExecutor {
auth.setQuitLocY(0D); auth.setQuitLocY(0D);
auth.setQuitLocZ(0D); auth.setQuitLocZ(0D);
auth.setWorld("world"); auth.setWorld("world");
database.updateQuitLoc(auth); plugin.database.updateQuitLoc(auth);
sender.sendMessage(name + "'s last position location is now reset"); sender.sendMessage(name + "'s last position location is now reset");
} catch (Exception e) { } catch (Exception e) {
ConsoleLogger.showError("An error occured while trying to reset location or player do not exist, please see below: "); ConsoleLogger.showError("An error occured while trying to reset location or player do not exist, please see below: ");