diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index f11b5105e..ec7cea77d 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -208,13 +208,13 @@ public class AuthMe extends JavaPlugin { setupDatabase(); - dataManager = new DataManager(this, database); + dataManager = new DataManager(this); // Setup API - api = new API(this, database); + api = new API(this); // Setup Management - management = new Management(database, this); + management = new Management(this); PluginManager pm = getServer().getPluginManager(); if (Settings.bungee) { @@ -222,25 +222,25 @@ public class AuthMe extends JavaPlugin { Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeCordMessage(this)); } - pm.registerEvents(new AuthMePlayerListener(this, database), this); - pm.registerEvents(new AuthMeBlockListener(database, this), this); - pm.registerEvents(new AuthMeEntityListener(database, this), this); + pm.registerEvents(new AuthMePlayerListener(this), this); + pm.registerEvents(new AuthMeBlockListener(this), this); + pm.registerEvents(new AuthMeEntityListener(this), this); pm.registerEvents(new AuthMeServerListener(this), this); if (ChestShop != 0) { - pm.registerEvents(new AuthMeChestShopListener(database, this), this); + pm.registerEvents(new AuthMeChestShopListener(this), this); ConsoleLogger.info("Successfully hook with ChestShop!"); } - this.getCommand("authme").setExecutor(new AdminCommand(this, database)); + this.getCommand("authme").setExecutor(new AdminCommand(this)); this.getCommand("register").setExecutor(new RegisterCommand(this)); this.getCommand("login").setExecutor(new LoginCommand(this)); - this.getCommand("changepassword").setExecutor(new ChangePasswordCommand(database, this)); - this.getCommand("logout").setExecutor(new LogoutCommand(this, database)); - this.getCommand("unregister").setExecutor(new UnregisterCommand(this, database)); + this.getCommand("changepassword").setExecutor(new ChangePasswordCommand(this)); + this.getCommand("logout").setExecutor(new LogoutCommand(this)); + this.getCommand("unregister").setExecutor(new UnregisterCommand(this)); this.getCommand("passpartu").setExecutor(new PasspartuCommand(this)); - this.getCommand("email").setExecutor(new EmailCommand(this, database)); + this.getCommand("email").setExecutor(new EmailCommand(this)); this.getCommand("captcha").setExecutor(new CaptchaCommand(this)); - this.getCommand("converter").setExecutor(new ConverterCommand(this, database)); + this.getCommand("converter").setExecutor(new ConverterCommand(this)); if (!Settings.isForceSingleSessionEnabled) { ConsoleLogger.showError("BECAREFUL !!! By disabling ForceSingleSession, your server protection is set to LOW"); diff --git a/src/main/java/fr/xephi/authme/DataManager.java b/src/main/java/fr/xephi/authme/DataManager.java index a1de30f31..3804999ad 100644 --- a/src/main/java/fr/xephi/authme/DataManager.java +++ b/src/main/java/fr/xephi/authme/DataManager.java @@ -8,23 +8,19 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; -import net.milkbowl.vault.permission.Permission; - import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.settings.Settings; +import net.milkbowl.vault.permission.Permission; public class DataManager { public AuthMe plugin; - public DataSource database; - public DataManager(AuthMe plugin, DataSource database) { + public DataManager(AuthMe plugin) { this.plugin = plugin; - this.database = database; } public void run() { diff --git a/src/main/java/fr/xephi/authme/api/API.java b/src/main/java/fr/xephi/authme/api/API.java index c60de1210..d718a0adb 100644 --- a/src/main/java/fr/xephi/authme/api/API.java +++ b/src/main/java/fr/xephi/authme/api/API.java @@ -13,7 +13,6 @@ import fr.xephi.authme.AuthMe; import fr.xephi.authme.Utils; import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerCache; -import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.plugin.manager.CombatTagComunicator; import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.settings.Settings; @@ -23,16 +22,13 @@ public class API { public static final String newline = System.getProperty("line.separator"); public static API singleton; public AuthMe plugin; - public DataSource database; - public API(AuthMe plugin, DataSource database) { + public API(AuthMe plugin) { this.plugin = plugin; - this.database = database; } public API(Server serv) { this.plugin = (AuthMe) serv.getPluginManager().getPlugin("AuthMe"); - this.database = this.plugin.database; } /** @@ -50,7 +46,7 @@ public class API { return null; } AuthMe authme = (AuthMe) p; - singleton = (new API(authme, authme.database)); + singleton = (new API(authme)); return singleton; } @@ -119,7 +115,7 @@ public class API { */ public boolean isRegistered(String playerName) { String player = playerName.toLowerCase(); - return database.isAuthAvailable(player); + return plugin.database.isAuthAvailable(player); } /** @@ -131,7 +127,7 @@ public class API { if (!isRegistered(playerName)) return false; String player = playerName.toLowerCase(); - PlayerAuth auth = database.getAuth(player); + PlayerAuth auth = plugin.database.getAuth(player); try { return PasswordSecurity.comparePasswordWithHash(passwordToCheck, auth.getHash(), playerName); } catch (NoSuchAlgorithmException e) { @@ -154,7 +150,7 @@ public class API { return false; } PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0, "your@email.com"); - if (!database.saveAuth(auth)) { + if (!plugin.database.saveAuth(auth)) { return false; } return true; diff --git a/src/main/java/fr/xephi/authme/commands/AdminCommand.java b/src/main/java/fr/xephi/authme/commands/AdminCommand.java index 947df69a2..fffc0aca1 100644 --- a/src/main/java/fr/xephi/authme/commands/AdminCommand.java +++ b/src/main/java/fr/xephi/authme/commands/AdminCommand.java @@ -33,7 +33,6 @@ import fr.xephi.authme.Utils.groupType; import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.limbo.LimboCache; -import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.events.SpawnTeleportEvent; import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.settings.Messages; @@ -46,10 +45,8 @@ public class AdminCommand implements CommandExecutor { public AuthMe plugin; private Messages m = Messages.getInstance(); - public DataSource database; - public AdminCommand(AuthMe plugin, DataSource database) { - this.database = database; + public AdminCommand(AuthMe plugin) { this.plugin = plugin; } @@ -107,7 +104,7 @@ public class AdminCommand implements CommandExecutor { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, -(Integer.parseInt(args[1]))); long until = calendar.getTimeInMillis(); - List purged = database.autoPurgeDatabase(until); + List purged = plugin.database.autoPurgeDatabase(until); sender.sendMessage("Deleted " + purged.size() + " user accounts"); if (Settings.purgeEssentialsFile && plugin.ess != null) plugin.dataManager.purgeEssentials(purged); @@ -161,8 +158,8 @@ public class AdminCommand implements CommandExecutor { return true; } try { - if (database.getAuth(args[1].toLowerCase()) != null) { - PlayerAuth player = database.getAuth(args[1].toLowerCase()); + if (plugin.database.getAuth(args[1].toLowerCase()) != null) { + PlayerAuth player = plugin.database.getAuth(args[1].toLowerCase()); long lastLogin = player.getLastLogin(); Date d = new Date(lastLogin); final long diff = System.currentTimeMillis() - lastLogin; @@ -195,13 +192,13 @@ public class AdminCommand implements CommandExecutor { PlayerAuth pAuth = null; String message = "[AuthMe] "; try { - pAuth = database.getAuth(arguments[1].toLowerCase()); + pAuth = plugin.database.getAuth(arguments[1].toLowerCase()); } catch (NullPointerException npe) { fSender.sendMessage("[AuthMe] This player is unknown"); return; } if (pAuth != null) { - List accountList = database.getAllAuthsByName(pAuth); + List accountList = plugin.database.getAllAuthsByName(pAuth); if (accountList.isEmpty() || accountList == null) { fSender.sendMessage("[AuthMe] This player is unknown"); return; @@ -238,7 +235,7 @@ public class AdminCommand implements CommandExecutor { public void run() { String message = "[AuthMe] "; if (arguments[1] != null) { - List accountList = database.getAllAuthsByIp(arguments[1]); + List accountList = plugin.database.getAllAuthsByIp(arguments[1]); if (accountList.isEmpty() || accountList == null) { fSender.sendMessage("[AuthMe] Please put a valid IP"); return; @@ -275,7 +272,7 @@ public class AdminCommand implements CommandExecutor { } try { String name = args[1].toLowerCase(); - if (database.isAuthAvailable(name)) { + if (plugin.database.isAuthAvailable(name)) { m.send(sender, "user_regged"); return true; } @@ -284,7 +281,7 @@ public class AdminCommand implements CommandExecutor { if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null) auth.setSalt(PasswordSecurity.userSalt.get(name)); else auth.setSalt(""); - if (!database.saveAuth(auth)) { + if (!plugin.database.saveAuth(auth)) { m.send(sender, "error"); return true; } @@ -301,7 +298,7 @@ public class AdminCommand implements CommandExecutor { return true; } String playername = args[1].toLowerCase(); - PlayerAuth getAuth = database.getAuth(playername); + PlayerAuth getAuth = plugin.database.getAuth(playername); if (getAuth == null) { m.send(sender, "unknown_user"); return true; @@ -314,13 +311,13 @@ public class AdminCommand implements CommandExecutor { return true; } String playername = args[1].toLowerCase(); - PlayerAuth getAuth = database.getAuth(playername); + PlayerAuth getAuth = plugin.database.getAuth(playername); if (getAuth == null) { m.send(sender, "unknown_user"); return true; } getAuth.setEmail(args[2]); - if (!database.updateEmail(getAuth)) { + if (!plugin.database.updateEmail(getAuth)) { m.send(sender, "error"); return true; } @@ -358,7 +355,7 @@ public class AdminCommand implements CommandExecutor { for (OfflinePlayer off : plugin.getServer().getBannedPlayers()) { bannedPlayers.add(off.getName().toLowerCase()); } - database.purgeBanned(bannedPlayers); + plugin.database.purgeBanned(bannedPlayers); if (Settings.purgeEssentialsFile && plugin.ess != null) plugin.dataManager.purgeEssentials(bannedPlayers); if (Settings.purgePlayerDat) @@ -406,8 +403,8 @@ public class AdminCommand implements CommandExecutor { PlayerAuth auth = null; if (PlayerCache.getInstance().isAuthenticated(name)) { auth = PlayerCache.getInstance().getAuth(name); - } else if (database.isAuthAvailable(name)) { - auth = database.getAuth(name); + } else if (plugin.database.isAuthAvailable(name)) { + auth = plugin.database.getAuth(name); } if (auth == null) { m.send(sender, "unknown_user"); @@ -416,9 +413,9 @@ public class AdminCommand implements CommandExecutor { auth.setHash(hash); if (PasswordSecurity.userSalt.containsKey(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"); return true; } @@ -435,11 +432,11 @@ public class AdminCommand implements CommandExecutor { return true; } String name = args[1].toLowerCase(); - if (!database.isAuthAvailable(name)) { + if (!plugin.database.isAuthAvailable(name)) { m.send(sender, "user_unknown"); return true; } - if (!database.removeAuth(name)) { + if (!plugin.database.removeAuth(name)) { m.send(sender, "error"); return true; } @@ -484,7 +481,7 @@ public class AdminCommand implements CommandExecutor { } try { String name = args[1].toLowerCase(); - PlayerAuth auth = database.getAuth(name); + PlayerAuth auth = plugin.database.getAuth(name); if (auth == null) { sender.sendMessage("The player " + name + " is not registered "); return true; @@ -493,7 +490,7 @@ public class AdminCommand implements CommandExecutor { auth.setQuitLocY(0); auth.setQuitLocZ(0); auth.setWorld("world"); - database.updateQuitLoc(auth); + plugin.database.updateQuitLoc(auth); sender.sendMessage(name + " 's last pos location is now reset"); } catch (Exception e) { ConsoleLogger.showError("An error occured while trying to reset location or player do not exist, please see below: "); @@ -539,7 +536,7 @@ public class AdminCommand implements CommandExecutor { sender.sendMessage("Usage : /authme resetPosition "); return true; } - PlayerAuth auth = database.getAuth(args[1]); + PlayerAuth auth = plugin.database.getAuth(args[1]); if (auth == null) { m.send(sender, "unknown_user"); return true; @@ -548,7 +545,7 @@ public class AdminCommand implements CommandExecutor { auth.setQuitLocY(0D); auth.setQuitLocZ(0D); auth.setWorld("world"); - database.updateQuitLoc(auth); + plugin.database.updateQuitLoc(auth); sender.sendMessage("[AuthMe] Successfully reset position for " + auth.getNickname()); return true; } else if (args[0].equalsIgnoreCase("forcelogin")) { diff --git a/src/main/java/fr/xephi/authme/commands/ChangePasswordCommand.java b/src/main/java/fr/xephi/authme/commands/ChangePasswordCommand.java index c6c5fb5c7..aa905658f 100644 --- a/src/main/java/fr/xephi/authme/commands/ChangePasswordCommand.java +++ b/src/main/java/fr/xephi/authme/commands/ChangePasswordCommand.java @@ -11,7 +11,6 @@ import fr.xephi.authme.AuthMe; import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerCache; -import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Settings; @@ -19,11 +18,9 @@ import fr.xephi.authme.settings.Settings; public class ChangePasswordCommand implements CommandExecutor { private Messages m = Messages.getInstance(); - private DataSource database; public AuthMe plugin; - public ChangePasswordCommand(DataSource database, AuthMe plugin) { - this.database = database; + public ChangePasswordCommand(AuthMe plugin) { this.plugin = plugin; } @@ -79,11 +76,11 @@ public class ChangePasswordCommand implements CommandExecutor { if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null) auth.setSalt(PasswordSecurity.userSalt.get(name)); else auth.setSalt(""); - if (!database.updatePassword(auth)) { + if (!plugin.database.updatePassword(auth)) { m.send(player, "error"); return true; } - database.updateSalt(auth); + plugin.database.updateSalt(auth); PlayerCache.getInstance().updatePlayer(auth); m.send(player, "pwd_changed"); ConsoleLogger.info(player.getName() + " changed his password"); diff --git a/src/main/java/fr/xephi/authme/commands/ConverterCommand.java b/src/main/java/fr/xephi/authme/commands/ConverterCommand.java index a5c3a1155..3da052a04 100644 --- a/src/main/java/fr/xephi/authme/commands/ConverterCommand.java +++ b/src/main/java/fr/xephi/authme/commands/ConverterCommand.java @@ -16,18 +16,15 @@ import fr.xephi.authme.converter.RoyalAuthConverter; import fr.xephi.authme.converter.SqlToFlat; import fr.xephi.authme.converter.vAuthConverter; import fr.xephi.authme.converter.xAuthConverter; -import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.settings.Messages; public class ConverterCommand implements CommandExecutor { private AuthMe plugin; private Messages m = Messages.getInstance(); - private DataSource database; - public ConverterCommand(AuthMe plugin, DataSource database) { + public ConverterCommand(AuthMe plugin) { this.plugin = plugin; - this.database = database; } @Override @@ -61,22 +58,22 @@ public class ConverterCommand implements CommandExecutor { converter = new FlatToSqlite(sender); break; case xauth: - converter = new xAuthConverter(plugin, database, sender); + converter = new xAuthConverter(plugin, sender); break; case crazylogin: - converter = new CrazyLoginConverter(plugin, database, sender); + converter = new CrazyLoginConverter(plugin, sender); break; case rakamak: - converter = new RakamakConverter(plugin, database, sender); + converter = new RakamakConverter(plugin, sender); break; case royalauth: converter = new RoyalAuthConverter(plugin); break; case vauth: - converter = new vAuthConverter(plugin, database, sender); + converter = new vAuthConverter(plugin, sender); break; case sqltoflat: - converter = new SqlToFlat(plugin, database, sender); + converter = new SqlToFlat(plugin, sender); break; default: break; diff --git a/src/main/java/fr/xephi/authme/commands/EmailCommand.java b/src/main/java/fr/xephi/authme/commands/EmailCommand.java index ab32be6de..a5ada2c0d 100644 --- a/src/main/java/fr/xephi/authme/commands/EmailCommand.java +++ b/src/main/java/fr/xephi/authme/commands/EmailCommand.java @@ -11,7 +11,6 @@ import fr.xephi.authme.AuthMe; import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerCache; -import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.RandomString; import fr.xephi.authme.settings.Messages; @@ -24,12 +23,10 @@ import fr.xephi.authme.settings.Settings; public class EmailCommand implements CommandExecutor { public AuthMe plugin; - private DataSource data; private Messages m = Messages.getInstance(); - public EmailCommand(AuthMe plugin, DataSource data) { + public EmailCommand(AuthMe plugin) { this.plugin = plugin; - this.data = data; } @Override @@ -60,7 +57,7 @@ public class EmailCommand implements CommandExecutor { return true; } if (Settings.getmaxRegPerEmail > 0) { - if (!plugin.authmePermissible(sender, "authme.allow2accounts") && data.getAllAuthsByEmail(args[1]).size() >= Settings.getmaxRegPerEmail) { + if (!plugin.authmePermissible(sender, "authme.allow2accounts") && plugin.database.getAllAuthsByEmail(args[1]).size() >= Settings.getmaxRegPerEmail) { m.send(player, "max_reg"); return true; } @@ -76,7 +73,7 @@ public class EmailCommand implements CommandExecutor { return true; } auth.setEmail(args[1]); - if (!data.updateEmail(auth)) { + if (!plugin.database.updateEmail(auth)) { m.send(player, "error"); return true; } @@ -86,7 +83,7 @@ public class EmailCommand implements CommandExecutor { } else if (PlayerCache.getInstance().isAuthenticated(name)) { m.send(player, "email_confirm"); } else { - if (!data.isAuthAvailable(name)) { + if (!plugin.database.isAuthAvailable(name)) { m.send(player, "login_msg"); } else { m.send(player, "reg_email_msg"); @@ -98,7 +95,7 @@ public class EmailCommand implements CommandExecutor { return true; } if (Settings.getmaxRegPerEmail > 0) { - if (!plugin.authmePermissible(sender, "authme.allow2accounts") && data.getAllAuthsByEmail(args[2]).size() >= Settings.getmaxRegPerEmail) { + if (!plugin.authmePermissible(sender, "authme.allow2accounts") && plugin.database.getAllAuthsByEmail(args[2]).size() >= Settings.getmaxRegPerEmail) { m.send(player, "max_reg"); return true; } @@ -118,7 +115,7 @@ public class EmailCommand implements CommandExecutor { return true; } auth.setEmail(args[2]); - if (!data.updateEmail(auth)) { + if (!plugin.database.updateEmail(auth)) { m.send(player, "error"); return true; } @@ -128,7 +125,7 @@ public class EmailCommand implements CommandExecutor { } else if (PlayerCache.getInstance().isAuthenticated(name)) { m.send(player, "email_confirm"); } else { - if (!data.isAuthAvailable(name)) { + if (!plugin.database.isAuthAvailable(name)) { m.send(player, "login_msg"); } else { m.send(player, "reg_email_msg"); @@ -144,7 +141,7 @@ public class EmailCommand implements CommandExecutor { m.send(player, "error"); return true; } - if (data.isAuthAvailable(name)) { + if (plugin.database.isAuthAvailable(name)) { if (PlayerCache.getInstance().isAuthenticated(name)) { m.send(player, "logged_in"); return true; @@ -156,8 +153,8 @@ public class EmailCommand implements CommandExecutor { PlayerAuth auth = null; if (PlayerCache.getInstance().isAuthenticated(name)) { auth = PlayerCache.getInstance().getAuth(name); - } else if (data.isAuthAvailable(name)) { - auth = data.getAuth(name); + } else if (plugin.database.isAuthAvailable(name)) { + auth = plugin.database.getAuth(name); } else { m.send(player, "unknown_user"); return true; @@ -172,7 +169,7 @@ public class EmailCommand implements CommandExecutor { return true; } auth.setHash(hashnew); - data.updatePassword(auth); + plugin.database.updatePassword(auth); plugin.mail.main(auth, thePass); m.send(player, "email_send"); } catch (NoSuchAlgorithmException ex) { diff --git a/src/main/java/fr/xephi/authme/commands/LogoutCommand.java b/src/main/java/fr/xephi/authme/commands/LogoutCommand.java index cb05b4de0..4c21f7f66 100644 --- a/src/main/java/fr/xephi/authme/commands/LogoutCommand.java +++ b/src/main/java/fr/xephi/authme/commands/LogoutCommand.java @@ -6,23 +6,15 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import fr.xephi.authme.AuthMe; -import fr.xephi.authme.Utils; -import fr.xephi.authme.cache.backup.FileCache; -import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.settings.Messages; public class LogoutCommand implements CommandExecutor { private Messages m = Messages.getInstance(); private AuthMe plugin; - private DataSource database; - private Utils utils = Utils.getInstance(); - private FileCache playerBackup; - public LogoutCommand(AuthMe plugin, DataSource database) { + public LogoutCommand(AuthMe plugin) { this.plugin = plugin; - this.database = database; - this.playerBackup = new FileCache(plugin); } @Override diff --git a/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java b/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java index 0b8bf9435..dd1a94e94 100644 --- a/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java +++ b/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java @@ -20,7 +20,6 @@ import fr.xephi.authme.Utils.groupType; import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.backup.FileCache; import fr.xephi.authme.cache.limbo.LimboCache; -import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.events.SpawnTeleportEvent; import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.settings.Messages; @@ -32,12 +31,10 @@ public class UnregisterCommand implements CommandExecutor { private Messages m = Messages.getInstance(); public AuthMe plugin; - private DataSource database; private FileCache playerCache; - public UnregisterCommand(AuthMe plugin, DataSource database) { + public UnregisterCommand(AuthMe plugin) { this.plugin = plugin; - this.database = database; this.playerCache = new FileCache(plugin); } @@ -67,7 +64,7 @@ public class UnregisterCommand implements CommandExecutor { } try { if (PasswordSecurity.comparePasswordWithHash(args[0], PlayerCache.getInstance().getAuth(name).getHash(), player.getName())) { - if (!database.removeAuth(name)) { + if (!plugin.database.removeAuth(name)) { player.sendMessage("error"); return true; } diff --git a/src/main/java/fr/xephi/authme/converter/CrazyLoginConverter.java b/src/main/java/fr/xephi/authme/converter/CrazyLoginConverter.java index fdd8e34f0..d4577bcd7 100644 --- a/src/main/java/fr/xephi/authme/converter/CrazyLoginConverter.java +++ b/src/main/java/fr/xephi/authme/converter/CrazyLoginConverter.java @@ -5,6 +5,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; + import org.bukkit.command.CommandSender; import fr.xephi.authme.AuthMe; @@ -23,10 +24,9 @@ public class CrazyLoginConverter implements Converter { public DataSource database; public CommandSender sender; - public CrazyLoginConverter(AuthMe instance, DataSource database, - CommandSender sender) { + public CrazyLoginConverter(AuthMe instance, CommandSender sender) { this.instance = instance; - this.database = database; + this.database = instance.database; this.sender = sender; } diff --git a/src/main/java/fr/xephi/authme/converter/RakamakConverter.java b/src/main/java/fr/xephi/authme/converter/RakamakConverter.java index 2d0c5a51e..712207673 100644 --- a/src/main/java/fr/xephi/authme/converter/RakamakConverter.java +++ b/src/main/java/fr/xephi/authme/converter/RakamakConverter.java @@ -29,10 +29,9 @@ public class RakamakConverter implements Converter { public DataSource database; public CommandSender sender; - public RakamakConverter(AuthMe instance, DataSource database, - CommandSender sender) { + public RakamakConverter(AuthMe instance, CommandSender sender) { this.instance = instance; - this.database = database; + this.database = instance.database; this.sender = sender; } diff --git a/src/main/java/fr/xephi/authme/converter/SqlToFlat.java b/src/main/java/fr/xephi/authme/converter/SqlToFlat.java index 0194e412f..4dccbd439 100644 --- a/src/main/java/fr/xephi/authme/converter/SqlToFlat.java +++ b/src/main/java/fr/xephi/authme/converter/SqlToFlat.java @@ -17,9 +17,9 @@ public class SqlToFlat implements Converter { public DataSource database; public CommandSender sender; - public SqlToFlat(AuthMe plugin, DataSource database, CommandSender sender) { + public SqlToFlat(AuthMe plugin, CommandSender sender) { this.plugin = plugin; - this.database = database; + this.database = plugin.database; this.sender = sender; } diff --git a/src/main/java/fr/xephi/authme/converter/vAuthConverter.java b/src/main/java/fr/xephi/authme/converter/vAuthConverter.java index bc9bc8de3..1939c6c1a 100644 --- a/src/main/java/fr/xephi/authme/converter/vAuthConverter.java +++ b/src/main/java/fr/xephi/authme/converter/vAuthConverter.java @@ -12,17 +12,16 @@ public class vAuthConverter implements Converter { public DataSource database; public CommandSender sender; - public vAuthConverter(AuthMe plugin, DataSource database, - CommandSender sender) { + public vAuthConverter(AuthMe plugin, CommandSender sender) { this.plugin = plugin; - this.database = database; + this.database = plugin.database; this.sender = sender; } @Override public void run() { try { - new vAuthFileReader(plugin, database, sender).convert(); + new vAuthFileReader(plugin, sender).convert(); } catch (Exception e) { sender.sendMessage(e.getMessage()); ConsoleLogger.showError(e.getMessage()); diff --git a/src/main/java/fr/xephi/authme/converter/vAuthFileReader.java b/src/main/java/fr/xephi/authme/converter/vAuthFileReader.java index 55cbec588..5b2a0be99 100644 --- a/src/main/java/fr/xephi/authme/converter/vAuthFileReader.java +++ b/src/main/java/fr/xephi/authme/converter/vAuthFileReader.java @@ -19,10 +19,9 @@ public class vAuthFileReader { public DataSource database; public CommandSender sender; - public vAuthFileReader(AuthMe plugin, DataSource database, - CommandSender sender) { + public vAuthFileReader(AuthMe plugin, CommandSender sender) { this.plugin = plugin; - this.database = database; + this.database = plugin.database; this.sender = sender; } diff --git a/src/main/java/fr/xephi/authme/converter/xAuthConverter.java b/src/main/java/fr/xephi/authme/converter/xAuthConverter.java index 46f549ead..1f8136682 100644 --- a/src/main/java/fr/xephi/authme/converter/xAuthConverter.java +++ b/src/main/java/fr/xephi/authme/converter/xAuthConverter.java @@ -3,18 +3,14 @@ package fr.xephi.authme.converter; import org.bukkit.command.CommandSender; import fr.xephi.authme.AuthMe; -import fr.xephi.authme.datasource.DataSource; public class xAuthConverter implements Converter { public AuthMe plugin; - public DataSource database; public CommandSender sender; - public xAuthConverter(AuthMe plugin, DataSource database, - CommandSender sender) { + public xAuthConverter(AuthMe plugin, CommandSender sender) { this.plugin = plugin; - this.database = database; this.sender = sender; } @@ -22,7 +18,7 @@ public class xAuthConverter implements Converter { public void run() { try { Class.forName("de.luricos.bukkit.xAuth.xAuth"); - xAuthToFlat converter = new xAuthToFlat(plugin, database, sender); + xAuthToFlat converter = new xAuthToFlat(plugin, sender); converter.convert(); } catch (ClassNotFoundException ce) { sender.sendMessage("xAuth has not been found, please put xAuth.jar in your plugin folder and restart!"); diff --git a/src/main/java/fr/xephi/authme/converter/xAuthToFlat.java b/src/main/java/fr/xephi/authme/converter/xAuthToFlat.java index 02d9946f5..e8ac1c9a6 100644 --- a/src/main/java/fr/xephi/authme/converter/xAuthToFlat.java +++ b/src/main/java/fr/xephi/authme/converter/xAuthToFlat.java @@ -23,10 +23,9 @@ public class xAuthToFlat { public DataSource database; public CommandSender sender; - public xAuthToFlat(AuthMe instance, DataSource database, - CommandSender sender) { + public xAuthToFlat(AuthMe instance, CommandSender sender) { this.instance = instance; - this.database = database; + this.database = instance.database; this.sender = sender; } diff --git a/src/main/java/fr/xephi/authme/listener/AuthMeBlockListener.java b/src/main/java/fr/xephi/authme/listener/AuthMeBlockListener.java index d706f0953..763797109 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMeBlockListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMeBlockListener.java @@ -9,16 +9,14 @@ import org.bukkit.event.block.BlockPlaceEvent; import fr.xephi.authme.AuthMe; import fr.xephi.authme.Utils; import fr.xephi.authme.cache.auth.PlayerCache; -import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.settings.Settings; public class AuthMeBlockListener implements Listener { - private DataSource data; public AuthMe instance; - public AuthMeBlockListener(DataSource data, AuthMe instance) { - this.data = data; + public AuthMeBlockListener(AuthMe instance) { + this.instance = instance; } @@ -39,7 +37,7 @@ public class AuthMeBlockListener implements Listener { return; } - if (!data.isAuthAvailable(name)) { + if (!instance.database.isAuthAvailable(name)) { if (!Settings.isForcedRegistrationEnabled) { return; } @@ -64,7 +62,7 @@ public class AuthMeBlockListener implements Listener { return; } - if (!data.isAuthAvailable(name)) { + if (!instance.database.isAuthAvailable(name)) { if (!Settings.isForcedRegistrationEnabled) { return; } diff --git a/src/main/java/fr/xephi/authme/listener/AuthMeChestShopListener.java b/src/main/java/fr/xephi/authme/listener/AuthMeChestShopListener.java index ae3c41aa2..563218759 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMeChestShopListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMeChestShopListener.java @@ -11,16 +11,13 @@ import com.Acrobot.ChestShop.Events.PreTransactionEvent.TransactionOutcome; import fr.xephi.authme.AuthMe; import fr.xephi.authme.Utils; import fr.xephi.authme.cache.auth.PlayerCache; -import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.settings.Settings; public class AuthMeChestShopListener implements Listener { - public DataSource database; public AuthMe plugin; - public AuthMeChestShopListener(DataSource database, AuthMe plugin) { - this.database = database; + public AuthMeChestShopListener(AuthMe plugin) { this.plugin = plugin; } @@ -41,7 +38,7 @@ public class AuthMeChestShopListener implements Listener { return; } - if (!database.isAuthAvailable(name)) { + if (!plugin.database.isAuthAvailable(name)) { if (!Settings.isForcedRegistrationEnabled) { return; } diff --git a/src/main/java/fr/xephi/authme/listener/AuthMeEntityListener.java b/src/main/java/fr/xephi/authme/listener/AuthMeEntityListener.java index 56b637e94..f0a62591e 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMeEntityListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMeEntityListener.java @@ -15,17 +15,14 @@ import org.bukkit.event.entity.FoodLevelChangeEvent; import fr.xephi.authme.AuthMe; import fr.xephi.authme.Utils; import fr.xephi.authme.cache.auth.PlayerCache; -import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.plugin.manager.CombatTagComunicator; import fr.xephi.authme.settings.Settings; public class AuthMeEntityListener implements Listener { - private DataSource data; public AuthMe instance; - public AuthMeEntityListener(DataSource data, AuthMe instance) { - this.data = data; + public AuthMeEntityListener(AuthMe instance) { this.instance = instance; } @@ -57,7 +54,7 @@ public class AuthMeEntityListener implements Listener { return; } - if (!data.isAuthAvailable(name)) { + if (!instance.database.isAuthAvailable(name)) { if (!Settings.isForcedRegistrationEnabled) { return; } @@ -89,7 +86,7 @@ public class AuthMeEntityListener implements Listener { return; } - if (!data.isAuthAvailable(name)) { + if (!instance.database.isAuthAvailable(name)) { if (!Settings.isForcedRegistrationEnabled) { return; } @@ -117,7 +114,7 @@ public class AuthMeEntityListener implements Listener { return; } - if (!data.isAuthAvailable(name)) { + if (!instance.database.isAuthAvailable(name)) { if (!Settings.isForcedRegistrationEnabled) { return; } @@ -147,7 +144,7 @@ public class AuthMeEntityListener implements Listener { return; } - if (!data.isAuthAvailable(name)) { + if (!instance.database.isAuthAvailable(name)) { if (!Settings.isForcedRegistrationEnabled) { return; } @@ -178,7 +175,7 @@ public class AuthMeEntityListener implements Listener { return; } - if (!data.isAuthAvailable(name)) { + if (!instance.database.isAuthAvailable(name)) { if (!Settings.isForcedRegistrationEnabled) { return; } @@ -212,7 +209,7 @@ public class AuthMeEntityListener implements Listener { return; } - if (!data.isAuthAvailable(name)) { + if (!instance.database.isAuthAvailable(name)) { if (!Settings.isForcedRegistrationEnabled) { return; } @@ -244,7 +241,7 @@ public class AuthMeEntityListener implements Listener { return; } - if (!data.isAuthAvailable(name)) { + if (!instance.database.isAuthAvailable(name)) { if (!Settings.isForcedRegistrationEnabled) { return; } diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index cda89dc58..ac1551de8 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -43,7 +43,6 @@ import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.limbo.LimboCache; import fr.xephi.authme.cache.limbo.LimboPlayer; -import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.plugin.manager.CombatTagComunicator; import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Settings; @@ -54,13 +53,11 @@ public class AuthMePlayerListener implements Listener { public static ConcurrentHashMap joinMessage = new ConcurrentHashMap(); private Messages m = Messages.getInstance(); public AuthMe plugin; - private DataSource data; public static ConcurrentHashMap causeByAuthMe = new ConcurrentHashMap(); private List antibot = new ArrayList(); - public AuthMePlayerListener(AuthMe plugin, DataSource data) { + public AuthMePlayerListener(AuthMe plugin) { this.plugin = plugin; - this.data = data; } @EventHandler(priority = EventPriority.LOWEST) @@ -77,7 +74,7 @@ public class AuthMePlayerListener implements Listener { if (PlayerCache.getInstance().isAuthenticated(name)) return; - if (!data.isAuthAvailable(name)) + if (!plugin.database.isAuthAvailable(name)) if (!Settings.isForcedRegistrationEnabled) return; @@ -113,7 +110,7 @@ public class AuthMePlayerListener implements Listener { String cmd = event.getMessage().split(" ")[0]; - if (data.isAuthAvailable(name)) { + if (plugin.database.isAuthAvailable(name)) { m.send(player, "login_msg"); } else { if (!Settings.isForcedRegistrationEnabled) { @@ -150,7 +147,7 @@ public class AuthMePlayerListener implements Listener { String cmd = event.getMessage().split(" ")[0]; - if (data.isAuthAvailable(name)) { + if (plugin.database.isAuthAvailable(name)) { m.send(player, "login_msg"); } else { if (!Settings.isForcedRegistrationEnabled) { @@ -187,7 +184,7 @@ public class AuthMePlayerListener implements Listener { String cmd = event.getMessage().split(" ")[0]; - if (data.isAuthAvailable(name)) { + if (plugin.database.isAuthAvailable(name)) { m.send(player, "login_msg"); } else { if (!Settings.isForcedRegistrationEnabled) { @@ -224,7 +221,7 @@ public class AuthMePlayerListener implements Listener { String cmd = event.getMessage().split(" ")[0]; - if (data.isAuthAvailable(name)) { + if (plugin.database.isAuthAvailable(name)) { m.send(player, "login_msg"); } else { if (!Settings.isForcedRegistrationEnabled) { @@ -262,7 +259,7 @@ public class AuthMePlayerListener implements Listener { String cmd = event.getMessage().split(" ")[0]; - if (data.isAuthAvailable(name)) { + if (plugin.database.isAuthAvailable(name)) { m.send(player, "login_msg"); } else { if (!Settings.isForcedRegistrationEnabled) { @@ -299,7 +296,7 @@ public class AuthMePlayerListener implements Listener { String cmd = event.getMessage().split(" ")[0]; - if (data.isAuthAvailable(name)) { + if (plugin.database.isAuthAvailable(name)) { m.send(player, "login_msg"); } else { if (!Settings.isForcedRegistrationEnabled) { @@ -336,7 +333,7 @@ public class AuthMePlayerListener implements Listener { } if (!Settings.isForcedRegistrationEnabled) { - if (!data.isAuthAvailable(name)) + if (!plugin.database.isAuthAvailable(name)) return; } @@ -404,7 +401,7 @@ public class AuthMePlayerListener implements Listener { if (player == null) return; final String name = player.getName().toLowerCase(); - boolean isAuthAvailable = data.isAuthAvailable(name); + boolean isAuthAvailable = plugin.database.isAuthAvailable(name); if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) { return; @@ -428,7 +425,7 @@ public class AuthMePlayerListener implements Listener { } if (Settings.isKickNonRegisteredEnabled) { - if (!data.isAuthAvailable(name)) { + if (!plugin.database.isAuthAvailable(name)) { event.setKickMessage(m.send("reg_only")[0]); event.setResult(PlayerLoginEvent.Result.KICK_OTHER); return; @@ -579,7 +576,7 @@ public class AuthMePlayerListener implements Listener { plugin.management.performQuit(player, false); - if (data.getAuth(name) != null && !PlayerCache.getInstance().isAuthenticated(name) && Settings.enableProtection) + if (plugin.database.getAuth(name) != null && !PlayerCache.getInstance().isAuthenticated(name) && Settings.enableProtection) event.setQuitMessage(null); } @@ -622,7 +619,7 @@ public class AuthMePlayerListener implements Listener { return; } - if (!data.isAuthAvailable(name)) { + if (!plugin.database.isAuthAvailable(name)) { if (!Settings.isForcedRegistrationEnabled) { return; } @@ -650,7 +647,7 @@ public class AuthMePlayerListener implements Listener { return; } - if (!data.isAuthAvailable(name)) { + if (!plugin.database.isAuthAvailable(name)) { if (!Settings.isForcedRegistrationEnabled) { return; } @@ -679,7 +676,7 @@ public class AuthMePlayerListener implements Listener { return; } - if (!data.isAuthAvailable(name)) { + if (!plugin.database.isAuthAvailable(name)) { if (!Settings.isForcedRegistrationEnabled) { return; } @@ -708,7 +705,7 @@ public class AuthMePlayerListener implements Listener { return; } - if (!data.isAuthAvailable(name)) { + if (!plugin.database.isAuthAvailable(name)) { if (!Settings.isForcedRegistrationEnabled) { return; } @@ -734,7 +731,7 @@ public class AuthMePlayerListener implements Listener { return; } - if (!data.isAuthAvailable(name)) { + if (!plugin.database.isAuthAvailable(name)) { if (!Settings.isForcedRegistrationEnabled) { return; } @@ -761,7 +758,7 @@ public class AuthMePlayerListener implements Listener { return; } - if (!data.isAuthAvailable(name)) { + if (!plugin.database.isAuthAvailable(name)) { if (!Settings.isForcedRegistrationEnabled) { return; } @@ -785,7 +782,7 @@ public class AuthMePlayerListener implements Listener { return; } - if (!data.isAuthAvailable(name)) { + if (!plugin.database.isAuthAvailable(name)) { if (!Settings.isForcedRegistrationEnabled) { return; } @@ -806,7 +803,7 @@ public class AuthMePlayerListener implements Listener { if (PlayerCache.getInstance().isAuthenticated(name)) { return; } - if (!data.isAuthAvailable(name)) { + if (!plugin.database.isAuthAvailable(name)) { if (!Settings.isForcedRegistrationEnabled) { return; } @@ -832,15 +829,15 @@ public class AuthMePlayerListener implements Listener { if (PlayerCache.getInstance().isAuthenticated(name)) return; - if (!data.isAuthAvailable(name)) + if (!plugin.database.isAuthAvailable(name)) if (!Settings.isForcedRegistrationEnabled) return; Location spawn = plugin.getSpawnLocation(player); - if (Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) { + if (Settings.isSaveQuitLocationEnabled && plugin.database.isAuthAvailable(name)) { final PlayerAuth auth = new PlayerAuth(name, spawn.getX(), spawn.getY(), spawn.getZ(), spawn.getWorld().getName()); try { - data.updateQuitLoc(auth); + plugin.database.updateQuitLoc(auth); } catch (NullPointerException npe) { } } @@ -871,7 +868,7 @@ public class AuthMePlayerListener implements Listener { if (PlayerCache.getInstance().isAuthenticated(name)) return; - if (!data.isAuthAvailable(name)) + if (!plugin.database.isAuthAvailable(name)) if (!Settings.isForcedRegistrationEnabled) return; diff --git a/src/main/java/fr/xephi/authme/process/Management.java b/src/main/java/fr/xephi/authme/process/Management.java index 45fc97fa9..479790e58 100644 --- a/src/main/java/fr/xephi/authme/process/Management.java +++ b/src/main/java/fr/xephi/authme/process/Management.java @@ -5,7 +5,6 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.PluginManager; import fr.xephi.authme.AuthMe; -import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.process.join.AsyncronousJoin; import fr.xephi.authme.process.login.AsyncronousLogin; import fr.xephi.authme.process.logout.AsyncronousLogout; @@ -22,13 +21,11 @@ import fr.xephi.authme.settings.Settings; */ public class Management { - public DataSource database; public AuthMe plugin; public static RandomString rdm = new RandomString(Settings.captchaLength); public PluginManager pm; - public Management(DataSource database, AuthMe plugin) { - this.database = database; + public Management(AuthMe plugin) { this.plugin = plugin; this.pm = plugin.getServer().getPluginManager(); } @@ -39,7 +36,7 @@ public class Management { @Override public void run() { - new AsyncronousLogin(player, password, forceLogin, plugin, database).process(); + new AsyncronousLogin(player, password, forceLogin, plugin, plugin.database).process(); } }); } @@ -50,7 +47,7 @@ public class Management { @Override public void run() { - new AsyncronousRegister(player, password, email, plugin, database).process(); + new AsyncronousRegister(player, password, email, plugin, plugin.database).process(); } }); } @@ -60,7 +57,7 @@ public class Management { @Override public void run() { - new AsyncronousLogout(player, plugin, database).process(); + new AsyncronousLogout(player, plugin, plugin.database).process(); } }); } @@ -70,7 +67,7 @@ public class Management { @Override public void run() { - new AsyncronousQuit(player, plugin, database, isKick).process(); + new AsyncronousQuit(player, plugin, plugin.database, isKick).process(); } }); @@ -81,7 +78,7 @@ public class Management { @Override public void run() { - new AsyncronousJoin(player, plugin, database).process(); + new AsyncronousJoin(player, plugin, plugin.database).process(); } });