Minor - rename LimboPlayer methods + code householding
- Rename *taskId methods to *task to reflect what they handle - Remove usages of Wrapper where applicable - Replace some uses of legacy Settings with NewSetting calls
This commit is contained in:
@@ -64,8 +64,6 @@ public class AsynchronousJoin implements Process {
|
||||
}
|
||||
|
||||
final String ip = service.getIpAddressManager().getPlayerIp(player);
|
||||
|
||||
|
||||
if (isNameRestricted(name, ip, player.getAddress().getHostName(), service.getSettings())) {
|
||||
service.scheduleSyncDelayedTask(new Runnable() {
|
||||
@Override
|
||||
@@ -196,7 +194,7 @@ public class AsynchronousJoin implements Process {
|
||||
int msgInterval = service.getProperty(RegistrationSettings.MESSAGE_INTERVAL);
|
||||
if (registrationTimeout > 0) {
|
||||
BukkitTask id = service.runTaskLater(new TimeoutTask(plugin, name, player), registrationTimeout);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTask(id);
|
||||
}
|
||||
|
||||
MessageKey msg;
|
||||
@@ -209,7 +207,7 @@ public class AsynchronousJoin implements Process {
|
||||
}
|
||||
if (msgInterval > 0 && LimboCache.getInstance().getLimboPlayer(name) != null) {
|
||||
BukkitTask msgTask = service.runTask(new MessageTask(plugin, name, msg, msgInterval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgTask);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTask(msgTask);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
@@ -88,13 +89,13 @@ public class AsynchronousLogin implements Process {
|
||||
if (pAuth == null) {
|
||||
service.send(player, MessageKey.USER_NOT_REGISTERED);
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||
LimboCache.getInstance().getLimboPlayer(name).getMessageTaskId().cancel();
|
||||
LimboCache.getInstance().getLimboPlayer(name).getMessageTask().cancel();
|
||||
String[] msg = service.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)
|
||||
? service.retrieveMessage(MessageKey.REGISTER_EMAIL_MESSAGE)
|
||||
: service.retrieveMessage(MessageKey.REGISTER_MESSAGE);
|
||||
BukkitTask messageTask = service.runTask(
|
||||
new MessageTask(plugin, name, msg, service.getProperty(RegistrationSettings.MESSAGE_INTERVAL)));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(messageTask);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTask(messageTask);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -128,7 +129,7 @@ public class AsynchronousLogin implements Process {
|
||||
return;
|
||||
}
|
||||
|
||||
if (pAuth.getIp().equals("127.0.0.1") && !pAuth.getIp().equals(ip)) {
|
||||
if ("127.0.0.1".equals(pAuth.getIp()) && !pAuth.getIp().equals(ip)) {
|
||||
pAuth.setIp(ip);
|
||||
database.updateIp(pAuth.getNickname(), ip);
|
||||
}
|
||||
@@ -181,19 +182,20 @@ public class AsynchronousLogin implements Process {
|
||||
ProcessSyncPlayerLogin syncPlayerLogin = new ProcessSyncPlayerLogin(
|
||||
player, plugin, database, service.getSettings());
|
||||
if (syncPlayerLogin.getLimbo() != null) {
|
||||
if (syncPlayerLogin.getLimbo().getTimeoutTaskId() != null) {
|
||||
syncPlayerLogin.getLimbo().getTimeoutTaskId().cancel();
|
||||
if (syncPlayerLogin.getLimbo().getTimeoutTask() != null) {
|
||||
syncPlayerLogin.getLimbo().getTimeoutTask().cancel();
|
||||
}
|
||||
if (syncPlayerLogin.getLimbo().getMessageTaskId() != null) {
|
||||
syncPlayerLogin.getLimbo().getMessageTaskId().cancel();
|
||||
if (syncPlayerLogin.getLimbo().getMessageTask() != null) {
|
||||
syncPlayerLogin.getLimbo().getMessageTask().cancel();
|
||||
}
|
||||
}
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, syncPlayerLogin);
|
||||
} else if (player.isOnline()) {
|
||||
if (!Settings.noConsoleSpam)
|
||||
if (!service.getProperty(SecuritySettings.REMOVE_SPAM_FROM_CONSOLE)) {
|
||||
ConsoleLogger.info(realName + " used the wrong password");
|
||||
if (Settings.isKickOnWrongPasswordEnabled) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
}
|
||||
if (service.getProperty(RestrictionSettings.KICK_ON_WRONG_PASSWORD)) {
|
||||
service.scheduleSyncDelayedTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.kickPlayer(service.retrieveSingleMessage(MessageKey.WRONG_PASSWORD));
|
||||
|
||||
@@ -67,7 +67,7 @@ public class ProcessSyncPlayerLogin implements Runnable {
|
||||
}
|
||||
|
||||
private void restoreOpState() {
|
||||
player.setOp(limbo.getOperator());
|
||||
player.setOp(limbo.isOperator());
|
||||
}
|
||||
|
||||
private void packQuitLocation() {
|
||||
|
||||
@@ -72,10 +72,10 @@ public class ProcessSynchronousPlayerLogout implements Process {
|
||||
int interval = service.getProperty(RegistrationSettings.MESSAGE_INTERVAL);
|
||||
if (timeOut != 0) {
|
||||
BukkitTask id = service.runTaskLater(new TimeoutTask(plugin, name, player), timeOut);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTask(id);
|
||||
}
|
||||
BukkitTask msgT = service.runTask(new MessageTask(plugin, name, MessageKey.LOGIN_MESSAGE, interval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTask(msgT);
|
||||
if (player.isInsideVehicle() && player.getVehicle() != null) {
|
||||
player.getVehicle().eject();
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class AsynchronousQuit implements Process {
|
||||
Utils.addNormal(player, limbo.getGroup());
|
||||
}
|
||||
needToChange = true;
|
||||
isOp = limbo.getOperator();
|
||||
isOp = limbo.isOperator();
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
}
|
||||
if (Settings.isSessionsEnabled && !isKick) {
|
||||
|
||||
@@ -49,11 +49,11 @@ public class ProcessSyncEmailRegister implements Process {
|
||||
if (limbo != null) {
|
||||
if (time != 0) {
|
||||
BukkitTask id = service.runTaskLater(new TimeoutTask(service.getAuthMe(), name, player), time);
|
||||
limbo.setTimeoutTaskId(id);
|
||||
limbo.setTimeoutTask(id);
|
||||
}
|
||||
BukkitTask messageTask = service.runTask(new MessageTask(
|
||||
service.getAuthMe(), name, service.retrieveMessage(MessageKey.LOGIN_MESSAGE), msgInterval));
|
||||
limbo.setMessageTaskId(messageTask);
|
||||
limbo.setMessageTask(messageTask);
|
||||
}
|
||||
|
||||
player.saveData();
|
||||
|
||||
@@ -67,10 +67,10 @@ public class ProcessSyncPasswordRegister implements Process {
|
||||
BukkitTask task;
|
||||
if (delay != 0) {
|
||||
task = service.runTaskLater(new TimeoutTask(service.getAuthMe(), name, player), delay);
|
||||
cache.getLimboPlayer(name).setTimeoutTaskId(task);
|
||||
cache.getLimboPlayer(name).setTimeoutTask(task);
|
||||
}
|
||||
task = service.runTask(new MessageTask(plugin, name, MessageKey.LOGIN_MESSAGE, interval));
|
||||
cache.getLimboPlayer(name).setMessageTaskId(task);
|
||||
cache.getLimboPlayer(name).setMessageTask(task);
|
||||
if (player.isInsideVehicle() && player.getVehicle() != null) {
|
||||
player.getVehicle().eject();
|
||||
}
|
||||
|
||||
@@ -75,9 +75,9 @@ public class AsynchronousUnregister implements Process {
|
||||
BukkitScheduler scheduler = plugin.getServer().getScheduler();
|
||||
if (timeOut != 0) {
|
||||
BukkitTask id = scheduler.runTaskLater(plugin, new TimeoutTask(plugin, name, player), timeOut);
|
||||
limboPlayer.setTimeoutTaskId(id);
|
||||
limboPlayer.setTimeoutTask(id);
|
||||
}
|
||||
limboPlayer.setMessageTaskId(scheduler.runTask(plugin,
|
||||
limboPlayer.setMessageTask(scheduler.runTask(plugin,
|
||||
new MessageTask(plugin, name, MessageKey.REGISTER_MESSAGE, interval)));
|
||||
service.send(player, MessageKey.UNREGISTERED_SUCCESS);
|
||||
ConsoleLogger.info(player.getDisplayName() + " unregistered himself");
|
||||
|
||||
Reference in New Issue
Block a user