mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-02-03 13:31:28 +01:00
Set classes to use Messages getter in plugin instance.
This commit is contained in:
parent
0601ab0e40
commit
2de0e0e819
@ -221,7 +221,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
this.otherAccounts = OtherAccounts.getInstance();
|
this.otherAccounts = OtherAccounts.getInstance();
|
||||||
|
|
||||||
// Setup messages
|
// Setup messages
|
||||||
this.messages = Messages.getInstance();
|
this.messages = new Messages(Settings.messageFile, Settings.messagesLanguage);
|
||||||
|
|
||||||
// Set up Metrics
|
// Set up Metrics
|
||||||
setupMetrics();
|
setupMetrics();
|
||||||
@ -902,7 +902,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
*
|
*
|
||||||
* @return The real IP of the player.
|
* @return The real IP of the player.
|
||||||
*/
|
*/
|
||||||
// TODO: Cache the result
|
// TODO: Cache the result or run it async, it can cause trouble if verygames server isn't responding.
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String getVeryGamesIp(Player player) {
|
public String getVeryGamesIp(Player player) {
|
||||||
String realIP = player.getAddress().getAddress().getHostAddress();
|
String realIP = player.getAddress().getAddress().getHostAddress();
|
||||||
|
@ -21,7 +21,7 @@ public class AccountsCommand extends ExecutableCommand {
|
|||||||
final AuthMe plugin = AuthMe.getInstance();
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
|
|
||||||
// Messages instance
|
// Messages instance
|
||||||
final Messages m = Messages.getInstance();
|
final Messages m = plugin.getMessages();
|
||||||
|
|
||||||
// Get the player query
|
// Get the player query
|
||||||
String playerQuery = sender.getName();
|
String playerQuery = sender.getName();
|
||||||
|
@ -20,8 +20,9 @@ public class ChangePasswordCommand extends ExecutableCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||||
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
// Messages instance
|
// Messages instance
|
||||||
final Messages m = Messages.getInstance();
|
final Messages m = plugin.getMessages();
|
||||||
|
|
||||||
// Get the player and password
|
// Get the player and password
|
||||||
String playerName = commandArguments.get(0);
|
String playerName = commandArguments.get(0);
|
||||||
@ -47,9 +48,7 @@ public class ChangePasswordCommand extends ExecutableCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the password
|
// Set the password
|
||||||
final AuthMe plugin = AuthMe.getInstance();
|
|
||||||
final String playerNameLowerCase = playerName.toLowerCase();
|
final String playerNameLowerCase = playerName.toLowerCase();
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public class GetEmailCommand extends ExecutableCommand {
|
|||||||
|
|
||||||
// Get the authenticated user
|
// Get the authenticated user
|
||||||
AuthMe plugin = AuthMe.getInstance();
|
AuthMe plugin = AuthMe.getInstance();
|
||||||
Messages m = Messages.getInstance();
|
Messages m = plugin.getMessages();
|
||||||
PlayerAuth auth = plugin.database.getAuth(playerName.toLowerCase());
|
PlayerAuth auth = plugin.database.getAuth(playerName.toLowerCase());
|
||||||
if (auth == null) {
|
if (auth == null) {
|
||||||
m.send(sender, "unknown_user");
|
m.send(sender, "unknown_user");
|
||||||
|
@ -22,7 +22,7 @@ public class LastLoginCommand extends ExecutableCommand {
|
|||||||
|
|
||||||
// Validate the player
|
// Validate the player
|
||||||
AuthMe plugin = AuthMe.getInstance();
|
AuthMe plugin = AuthMe.getInstance();
|
||||||
Messages m = Messages.getInstance();
|
Messages m = plugin.getMessages();
|
||||||
|
|
||||||
PlayerAuth auth;
|
PlayerAuth auth;
|
||||||
try {
|
try {
|
||||||
|
@ -28,7 +28,7 @@ public class PurgeLastPositionCommand extends ExecutableCommand {
|
|||||||
final AuthMe plugin = AuthMe.getInstance();
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
|
|
||||||
// Messages instance
|
// Messages instance
|
||||||
final Messages m = Messages.getInstance();
|
final Messages m = plugin.getMessages();
|
||||||
|
|
||||||
// Get the player
|
// Get the player
|
||||||
String playerName = sender.getName();
|
String playerName = sender.getName();
|
||||||
|
@ -32,7 +32,7 @@ public class RegisterCommand extends ExecutableCommand {
|
|||||||
final AuthMe plugin = AuthMe.getInstance();
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
|
|
||||||
// Messages instance
|
// Messages instance
|
||||||
final Messages m = Messages.getInstance();
|
final Messages m = plugin.getMessages();
|
||||||
|
|
||||||
// Get the player name and password
|
// Get the player name and password
|
||||||
final String playerName = commandArguments.get(0);
|
final String playerName = commandArguments.get(0);
|
||||||
|
@ -33,15 +33,15 @@ public class ReloadCommand extends ExecutableCommand {
|
|||||||
AuthMe plugin = AuthMe.getInstance();
|
AuthMe plugin = AuthMe.getInstance();
|
||||||
|
|
||||||
// Messages instance
|
// Messages instance
|
||||||
Messages m = Messages.getInstance();
|
Messages m = plugin.getMessages();
|
||||||
|
|
||||||
// Show a status message
|
// Show a status message
|
||||||
// sender.sendMessage(ChatColor.YELLOW + "Reloading AuthMeReloaded...");
|
// sender.sendMessage(ChatColor.YELLOW + "Reloading AuthMeReloaded...");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Settings.reload();
|
Settings.reload();
|
||||||
|
plugin.setMessages(new Messages(Settings.messageFile, Settings.messagesLanguage));
|
||||||
plugin.getModuleManager().reloadModules();
|
plugin.getModuleManager().reloadModules();
|
||||||
Messages.getInstance().reloadMessages();
|
|
||||||
plugin.setupDatabase();
|
plugin.setupDatabase();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ConsoleLogger.showError("Fatal error occurred! AuthMe instance ABORTED!");
|
ConsoleLogger.showError("Fatal error occurred! AuthMe instance ABORTED!");
|
||||||
|
@ -28,7 +28,7 @@ public class SetEmailCommand extends ExecutableCommand {
|
|||||||
AuthMe plugin = AuthMe.getInstance();
|
AuthMe plugin = AuthMe.getInstance();
|
||||||
|
|
||||||
// Messages instance
|
// Messages instance
|
||||||
Messages m = Messages.getInstance();
|
Messages m = plugin.getMessages();
|
||||||
|
|
||||||
// Get the player name and email address
|
// Get the player name and email address
|
||||||
String playerName = commandArguments.get(0);
|
String playerName = commandArguments.get(0);
|
||||||
|
@ -39,7 +39,7 @@ public class UnregisterCommand extends ExecutableCommand {
|
|||||||
final AuthMe plugin = AuthMe.getInstance();
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
|
|
||||||
// Messages instance
|
// Messages instance
|
||||||
final Messages m = Messages.getInstance();
|
final Messages m = plugin.getMessages();
|
||||||
|
|
||||||
// Get the player name
|
// Get the player name
|
||||||
String playerName = commandArguments.get(0);
|
String playerName = commandArguments.get(0);
|
||||||
|
@ -29,8 +29,11 @@ public class CaptchaCommand extends ExecutableCommand {
|
|||||||
// Get the parameter values
|
// Get the parameter values
|
||||||
String captcha = commandArguments.get(0);
|
String captcha = commandArguments.get(0);
|
||||||
|
|
||||||
|
// AuthMe plugin instance
|
||||||
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
|
|
||||||
// Messages instance
|
// Messages instance
|
||||||
final Messages m = Messages.getInstance();
|
final Messages m = plugin.getMessages();
|
||||||
|
|
||||||
// Command logic
|
// Command logic
|
||||||
if (PlayerCache.getInstance().isAuthenticated(playerNameLowerCase)) {
|
if (PlayerCache.getInstance().isAuthenticated(playerNameLowerCase)) {
|
||||||
@ -43,8 +46,6 @@ public class CaptchaCommand extends ExecutableCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuthMe plugin instance
|
|
||||||
final AuthMe plugin = AuthMe.getInstance();
|
|
||||||
|
|
||||||
if (!plugin.cap.containsKey(playerNameLowerCase)) {
|
if (!plugin.cap.containsKey(playerNameLowerCase)) {
|
||||||
m.send(player, MessageKey.USAGE_LOGIN);
|
m.send(player, MessageKey.USAGE_LOGIN);
|
||||||
|
@ -16,7 +16,8 @@ public class ChangePasswordCommand extends ExecutableCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||||
final Messages m = Messages.getInstance();
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
|
final Messages m = plugin.getMessages();
|
||||||
|
|
||||||
// Get the passwords
|
// Get the passwords
|
||||||
String playerPass = commandArguments.get(0);
|
String playerPass = commandArguments.get(0);
|
||||||
@ -37,7 +38,11 @@ public class ChangePasswordCommand extends ExecutableCommand {
|
|||||||
|
|
||||||
// Make sure the password is allowed
|
// Make sure the password is allowed
|
||||||
String playerPassLowerCase = playerPass.toLowerCase();
|
String playerPassLowerCase = playerPass.toLowerCase();
|
||||||
if (playerPassLowerCase.contains("delete") || playerPassLowerCase.contains("where") || playerPassLowerCase.contains("insert") || playerPassLowerCase.contains("modify") || playerPassLowerCase.contains("from") || playerPassLowerCase.contains("select") || playerPassLowerCase.contains(";") || playerPassLowerCase.contains("null") || !playerPassLowerCase.matches(Settings.getPassRegex)) {
|
if (playerPassLowerCase.contains("delete") || playerPassLowerCase.contains("where")
|
||||||
|
|| playerPassLowerCase.contains("insert") || playerPassLowerCase.contains("modify")
|
||||||
|
|| playerPassLowerCase.contains("from") || playerPassLowerCase.contains("select")
|
||||||
|
|| playerPassLowerCase.contains(";") || playerPassLowerCase.contains("null")
|
||||||
|
|| !playerPassLowerCase.matches(Settings.getPassRegex)) {
|
||||||
m.send(player, "password_error");
|
m.send(player, "password_error");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -45,7 +50,8 @@ public class ChangePasswordCommand extends ExecutableCommand {
|
|||||||
m.send(player, "password_error_nick");
|
m.send(player, "password_error_nick");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (playerPassLowerCase.length() < Settings.getPasswordMinLen || playerPassLowerCase.length() > Settings.passwordMaxLength) {
|
if (playerPassLowerCase.length() < Settings.getPasswordMinLen
|
||||||
|
|| playerPassLowerCase.length() > Settings.passwordMaxLength) {
|
||||||
m.send(player, "pass_len");
|
m.send(player, "pass_len");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -57,8 +63,8 @@ public class ChangePasswordCommand extends ExecutableCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the password
|
// Set the password
|
||||||
final AuthMe plugin = AuthMe.getInstance();
|
plugin.getServer().getScheduler().runTaskAsynchronously(plugin,
|
||||||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new ChangePasswordTask(plugin, player, playerPass, playerPassVerify));
|
new ChangePasswordTask(plugin, player, playerPass, playerPassVerify));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public class ConverterCommand extends ExecutableCommand {
|
|||||||
final AuthMe plugin = AuthMe.getInstance();
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
|
|
||||||
// Messages instance
|
// Messages instance
|
||||||
final Messages m = Messages.getInstance();
|
final Messages m = plugin.getMessages();
|
||||||
|
|
||||||
// Get the conversion job
|
// Get the conversion job
|
||||||
String job = commandArguments.get(0);
|
String job = commandArguments.get(0);
|
||||||
|
@ -35,7 +35,7 @@ public class RecoverEmailCommand extends ExecutableCommand {
|
|||||||
|
|
||||||
// Command logic
|
// Command logic
|
||||||
final AuthMe plugin = AuthMe.getInstance();
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
final Messages m = Messages.getInstance();
|
final Messages m = plugin.getMessages();
|
||||||
|
|
||||||
if (plugin.mail == null) {
|
if (plugin.mail == null) {
|
||||||
m.send(player, "error");
|
m.send(player, "error");
|
||||||
|
@ -16,7 +16,6 @@ public class RegisterCommand extends ExecutableCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||||
final Messages m = Messages.getInstance();
|
|
||||||
|
|
||||||
// Make sure the sender is a player
|
// Make sure the sender is a player
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
@ -24,6 +23,9 @@ public class RegisterCommand extends ExecutableCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
|
final Messages m = plugin.getMessages();
|
||||||
|
|
||||||
// Make sure the command arguments are valid
|
// Make sure the command arguments are valid
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
if (commandArguments.getCount() == 0 || (Settings.getEnablePasswordVerifier && commandArguments.getCount() < 2)) {
|
if (commandArguments.getCount() == 0 || (Settings.getEnablePasswordVerifier && commandArguments.getCount() < 2)) {
|
||||||
@ -31,7 +33,7 @@ public class RegisterCommand extends ExecutableCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Management management = AuthMe.getInstance().getManagement();
|
final Management management = plugin.getManagement();
|
||||||
if (Settings.emailRegistration && !Settings.getmailAccount.isEmpty()) {
|
if (Settings.emailRegistration && !Settings.getmailAccount.isEmpty()) {
|
||||||
if (Settings.doubleEmailCheck) {
|
if (Settings.doubleEmailCheck) {
|
||||||
if (commandArguments.getCount() < 2 || !commandArguments.get(0).equals(commandArguments.get(1))) {
|
if (commandArguments.getCount() < 2 || !commandArguments.get(0).equals(commandArguments.get(1))) {
|
||||||
@ -44,16 +46,16 @@ public class RegisterCommand extends ExecutableCommand {
|
|||||||
m.send(player, "email_invalid");
|
m.send(player, "email_invalid");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
RandomString rand = new RandomString(Settings.getRecoveryPassLength);
|
final String thePass = new RandomString(Settings.getRecoveryPassLength).nextString();
|
||||||
final String thePass = rand.nextString();
|
|
||||||
management.performRegister(player, thePass, email);
|
management.performRegister(player, thePass, email);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (commandArguments.getCount() > 1 && Settings.getEnablePasswordVerifier)
|
if (commandArguments.getCount() > 1 && Settings.getEnablePasswordVerifier) {
|
||||||
if (!commandArguments.get(0).equals(commandArguments.get(1))) {
|
if (!commandArguments.get(0).equals(commandArguments.get(1))) {
|
||||||
m.send(player, "password_error");
|
m.send(player, "password_error");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
management.performRegister(player, commandArguments.get(0), "");
|
management.performRegister(player, commandArguments.get(0), "");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public class UnregisterCommand extends ExecutableCommand {
|
|||||||
final AuthMe plugin = AuthMe.getInstance();
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
|
|
||||||
// Messages instance
|
// Messages instance
|
||||||
final Messages m = Messages.getInstance();
|
final Messages m = plugin.getMessages();
|
||||||
|
|
||||||
// Make sure the current command executor is a player
|
// Make sure the current command executor is a player
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
|
@ -52,7 +52,7 @@ public class SqlToFlat implements Converter {
|
|||||||
sender.sendMessage("Successfully convert from SQL table to file auths.db");
|
sender.sendMessage("Successfully convert from SQL table to file auths.db");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
Messages.getInstance().send(sender, "error");
|
plugin.getMessages().send(sender, "error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
public static final ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<>();
|
public static final ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<>();
|
||||||
public static final ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>();
|
public static final ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>();
|
||||||
public final AuthMe plugin;
|
public final AuthMe plugin;
|
||||||
private final Messages m = Messages.getInstance();
|
private final Messages m;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for AuthMePlayerListener.
|
* Constructor for AuthMePlayerListener.
|
||||||
@ -48,6 +48,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
* @param plugin AuthMe
|
* @param plugin AuthMe
|
||||||
*/
|
*/
|
||||||
public AuthMePlayerListener(AuthMe plugin) {
|
public AuthMePlayerListener(AuthMe plugin) {
|
||||||
|
this.m = plugin.getMessages();
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@ import org.bukkit.plugin.Plugin;
|
|||||||
*/
|
*/
|
||||||
public class AuthMeServerListener implements Listener {
|
public class AuthMeServerListener implements Listener {
|
||||||
|
|
||||||
public final AuthMe plugin;
|
private final AuthMe plugin;
|
||||||
private final Messages m = Messages.getInstance();
|
private final Messages m;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for AuthMeServerListener.
|
* Constructor for AuthMeServerListener.
|
||||||
@ -26,6 +26,7 @@ public class AuthMeServerListener implements Listener {
|
|||||||
* @param plugin AuthMe
|
* @param plugin AuthMe
|
||||||
*/
|
*/
|
||||||
public AuthMeServerListener(AuthMe plugin) {
|
public AuthMeServerListener(AuthMe plugin) {
|
||||||
|
this.m = plugin.getMessages();
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,12 +23,12 @@ public class AsyncChangeEmail {
|
|||||||
private final Messages m;
|
private final Messages m;
|
||||||
|
|
||||||
public AsyncChangeEmail(Player player, AuthMe plugin, String oldEmail, String newEmail, String newEmailVerify) {
|
public AsyncChangeEmail(Player player, AuthMe plugin, String oldEmail, String newEmail, String newEmailVerify) {
|
||||||
|
this.m = plugin.getMessages();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.oldEmail = oldEmail;
|
this.oldEmail = oldEmail;
|
||||||
this.newEmail = newEmail;
|
this.newEmail = newEmail;
|
||||||
this.newEmailVerify = newEmailVerify;
|
this.newEmailVerify = newEmailVerify;
|
||||||
this.m = Messages.getInstance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AsyncChangeEmail(Player player, AuthMe plugin, String oldEmail, String newEmail) {
|
public AsyncChangeEmail(Player player, AuthMe plugin, String oldEmail, String newEmail) {
|
||||||
|
@ -40,12 +40,12 @@ public class AsynchronousJoin {
|
|||||||
private final BukkitScheduler sched;
|
private final BukkitScheduler sched;
|
||||||
|
|
||||||
public AsynchronousJoin(Player player, AuthMe plugin, DataSource database) {
|
public AsynchronousJoin(Player player, AuthMe plugin, DataSource database) {
|
||||||
|
this.m = plugin.getMessages();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.sched = plugin.getServer().getScheduler();
|
this.sched = plugin.getServer().getScheduler();
|
||||||
this.database = database;
|
this.database = database;
|
||||||
this.name = player.getName().toLowerCase();
|
this.name = player.getName().toLowerCase();
|
||||||
this.m = Messages.getInstance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void process() {
|
public void process() {
|
||||||
|
@ -33,7 +33,7 @@ public class AsynchronousLogin {
|
|||||||
protected final boolean forceLogin;
|
protected final boolean forceLogin;
|
||||||
private final AuthMe plugin;
|
private final AuthMe plugin;
|
||||||
private final DataSource database;
|
private final DataSource database;
|
||||||
private final Messages m = Messages.getInstance();
|
private final Messages m;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for AsynchronousLogin.
|
* Constructor for AsynchronousLogin.
|
||||||
@ -44,12 +44,12 @@ public class AsynchronousLogin {
|
|||||||
* @param plugin AuthMe
|
* @param plugin AuthMe
|
||||||
* @param data DataSource
|
* @param data DataSource
|
||||||
*/
|
*/
|
||||||
public AsynchronousLogin(Player player, String password, boolean forceLogin,
|
public AsynchronousLogin(Player player, String password, boolean forceLogin, AuthMe plugin, DataSource data) {
|
||||||
AuthMe plugin, DataSource data) {
|
this.m = plugin.getMessages();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
this.name = player.getName().toLowerCase();
|
||||||
this.password = password;
|
this.password = password;
|
||||||
name = player.getName().toLowerCase();
|
this.realName = player.getName();
|
||||||
realName = player.getName();
|
|
||||||
this.forceLogin = forceLogin;
|
this.forceLogin = forceLogin;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.database = data;
|
this.database = data;
|
||||||
|
@ -20,7 +20,7 @@ public class AsynchronousLogout {
|
|||||||
protected final AuthMe plugin;
|
protected final AuthMe plugin;
|
||||||
protected final DataSource database;
|
protected final DataSource database;
|
||||||
protected boolean canLogout = true;
|
protected boolean canLogout = true;
|
||||||
private final Messages m = Messages.getInstance();
|
private final Messages m;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for AsynchronousLogout.
|
* Constructor for AsynchronousLogout.
|
||||||
@ -29,8 +29,8 @@ public class AsynchronousLogout {
|
|||||||
* @param plugin AuthMe
|
* @param plugin AuthMe
|
||||||
* @param database DataSource
|
* @param database DataSource
|
||||||
*/
|
*/
|
||||||
public AsynchronousLogout(Player player, AuthMe plugin,
|
public AsynchronousLogout(Player player, AuthMe plugin, DataSource database) {
|
||||||
DataSource database) {
|
this.m = plugin.getMessages();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.database = database;
|
this.database = database;
|
||||||
|
@ -22,7 +22,7 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
|
|||||||
protected final Player player;
|
protected final Player player;
|
||||||
protected final AuthMe plugin;
|
protected final AuthMe plugin;
|
||||||
protected final String name;
|
protected final String name;
|
||||||
private final Messages m = Messages.getInstance();
|
private final Messages m;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for ProcessSyncronousPlayerLogout.
|
* Constructor for ProcessSyncronousPlayerLogout.
|
||||||
@ -31,6 +31,7 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
|
|||||||
* @param plugin AuthMe
|
* @param plugin AuthMe
|
||||||
*/
|
*/
|
||||||
public ProcessSyncronousPlayerLogout(Player player, AuthMe plugin) {
|
public ProcessSyncronousPlayerLogout(Player player, AuthMe plugin) {
|
||||||
|
this.m = plugin.getMessages();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.name = player.getName().toLowerCase();
|
this.name = player.getName().toLowerCase();
|
||||||
|
@ -23,7 +23,7 @@ public class AsyncRegister {
|
|||||||
protected String email = "";
|
protected String email = "";
|
||||||
private final AuthMe plugin;
|
private final AuthMe plugin;
|
||||||
private final DataSource database;
|
private final DataSource database;
|
||||||
private final Messages m = Messages.getInstance();
|
private final Messages m;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for AsyncRegister.
|
* Constructor for AsyncRegister.
|
||||||
@ -34,11 +34,11 @@ public class AsyncRegister {
|
|||||||
* @param plugin AuthMe
|
* @param plugin AuthMe
|
||||||
* @param data DataSource
|
* @param data DataSource
|
||||||
*/
|
*/
|
||||||
public AsyncRegister(Player player, String password, String email,
|
public AsyncRegister(Player player, String password, String email, AuthMe plugin, DataSource data) {
|
||||||
AuthMe plugin, DataSource data) {
|
this.m = plugin.getMessages();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
name = player.getName().toLowerCase();
|
this.name = player.getName().toLowerCase();
|
||||||
this.email = email;
|
this.email = email;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.database = data;
|
this.database = data;
|
||||||
|
@ -20,7 +20,7 @@ public class ProcessSyncEmailRegister implements Runnable {
|
|||||||
protected final Player player;
|
protected final Player player;
|
||||||
protected final String name;
|
protected final String name;
|
||||||
private final AuthMe plugin;
|
private final AuthMe plugin;
|
||||||
private final Messages m = Messages.getInstance();
|
private final Messages m;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for ProcessSyncEmailRegister.
|
* Constructor for ProcessSyncEmailRegister.
|
||||||
@ -29,6 +29,7 @@ public class ProcessSyncEmailRegister implements Runnable {
|
|||||||
* @param plugin AuthMe
|
* @param plugin AuthMe
|
||||||
*/
|
*/
|
||||||
public ProcessSyncEmailRegister(Player player, AuthMe plugin) {
|
public ProcessSyncEmailRegister(Player player, AuthMe plugin) {
|
||||||
|
this.m = plugin.getMessages();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.name = player.getName().toLowerCase();
|
this.name = player.getName().toLowerCase();
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
@ -25,7 +25,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
|||||||
protected final Player player;
|
protected final Player player;
|
||||||
protected final String name;
|
protected final String name;
|
||||||
private final AuthMe plugin;
|
private final AuthMe plugin;
|
||||||
private final Messages m = Messages.getInstance();
|
private final Messages m;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for ProcessSyncronousPasswordRegister.
|
* Constructor for ProcessSyncronousPasswordRegister.
|
||||||
@ -34,6 +34,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
|||||||
* @param plugin AuthMe
|
* @param plugin AuthMe
|
||||||
*/
|
*/
|
||||||
public ProcessSyncronousPasswordRegister(Player player, AuthMe plugin) {
|
public ProcessSyncronousPasswordRegister(Player player, AuthMe plugin) {
|
||||||
|
this.m = plugin.getMessages();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.name = player.getName().toLowerCase();
|
this.name = player.getName().toLowerCase();
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
@ -29,7 +29,7 @@ public class AsynchronousUnregister {
|
|||||||
protected final String password;
|
protected final String password;
|
||||||
protected final boolean force;
|
protected final boolean force;
|
||||||
private final AuthMe plugin;
|
private final AuthMe plugin;
|
||||||
private final Messages m = Messages.getInstance();
|
private final Messages m;
|
||||||
private final JsonCache playerCache;
|
private final JsonCache playerCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,12 +40,12 @@ public class AsynchronousUnregister {
|
|||||||
* @param force boolean
|
* @param force boolean
|
||||||
* @param plugin AuthMe
|
* @param plugin AuthMe
|
||||||
*/
|
*/
|
||||||
public AsynchronousUnregister(Player player, String password,
|
public AsynchronousUnregister(Player player, String password, boolean force, AuthMe plugin) {
|
||||||
boolean force, AuthMe plugin) {
|
this.m = plugin.getMessages();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
this.name = player.getName().toLowerCase();
|
||||||
this.password = password;
|
this.password = password;
|
||||||
this.force = force;
|
this.force = force;
|
||||||
name = player.getName().toLowerCase();
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.playerCache = new JsonCache();
|
this.playerCache = new JsonCache();
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import java.io.File;
|
|||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
// TODO ljacqu 20151124: This class is a weird mix between singleton and POJO
|
// TODO ljacqu 20151124: This class is a weird mix between singleton and POJO
|
||||||
|
// TODO: change it into POJO
|
||||||
public class Messages extends CustomConfiguration {
|
public class Messages extends CustomConfiguration {
|
||||||
|
|
||||||
/** The section symbol, used in Minecraft for formatting codes. */
|
/** The section symbol, used in Minecraft for formatting codes. */
|
||||||
|
@ -42,7 +42,7 @@ public class ChangePasswordTask implements Runnable {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Messages m = Messages.getInstance();
|
Messages m = plugin.getMessages();
|
||||||
try {
|
try {
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
String hashNew = PasswordSecurity.getHash(Settings.getPasswordHash, newPassword, name);
|
String hashNew = PasswordSecurity.getHash(Settings.getPasswordHash, newPassword, name);
|
||||||
|
@ -12,7 +12,7 @@ public class TimeoutTask implements Runnable {
|
|||||||
|
|
||||||
private final AuthMe plugin;
|
private final AuthMe plugin;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final Messages m = Messages.getInstance();
|
private final Messages m;
|
||||||
private final Player player;
|
private final Player player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,6 +23,7 @@ public class TimeoutTask implements Runnable {
|
|||||||
* @param player Player
|
* @param player Player
|
||||||
*/
|
*/
|
||||||
public TimeoutTask(AuthMe plugin, String name, Player player) {
|
public TimeoutTask(AuthMe plugin, String name, Player player) {
|
||||||
|
this.m = plugin.getMessages();
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
@ -44,16 +45,17 @@ public class TimeoutTask implements Runnable {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (player.isOnline())
|
if (player.isOnline()) {
|
||||||
player.kickPlayer(m.send("timeout")[0]);
|
player.kickPlayer(m.send("timeout")[0]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user