#1113 Handle LimboPlayer tasks via LimboService
- Add methods to LimboService for handling messages to make it the only relevant Limbo class for outside classes - Move LimboPlayerTaskManager to limbo package and make it package-private - Create MessageTask and TimeoutTask immediately when LimboPlayer is created - #1112 MessageTask: improve efficiency by keeping reference to Player
This commit is contained in:
@@ -20,7 +20,6 @@ import fr.xephi.authme.settings.properties.HooksSettings;
|
||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||
import fr.xephi.authme.task.LimboPlayerTaskManager;
|
||||
import fr.xephi.authme.util.PlayerUtils;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Server;
|
||||
@@ -62,9 +61,6 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
||||
@Inject
|
||||
private BukkitService bukkitService;
|
||||
|
||||
@Inject
|
||||
private LimboPlayerTaskManager limboPlayerTaskManager;
|
||||
|
||||
@Inject
|
||||
private AsynchronousLogin asynchronousLogin;
|
||||
|
||||
@@ -153,9 +149,7 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
||||
|
||||
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(() -> {
|
||||
// TODO #1113: Find an elegant way to deop unregistered players (and disable fly status etc.?)
|
||||
limboService.createLimboPlayer(player);
|
||||
limboPlayerTaskManager.registerTimeoutTask(player);
|
||||
limboPlayerTaskManager.registerMessageTask(name, isAuthAvailable);
|
||||
limboService.createLimboPlayer(player, isAuthAvailable);
|
||||
|
||||
player.setNoDamageTicks(registrationTimeout);
|
||||
if (pluginHookService.isEssentialsAvailable() && service.getProperty(HooksSettings.USE_ESSENTIALS_MOTD)) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import fr.xephi.authme.data.CaptchaManager;
|
||||
import fr.xephi.authme.data.TempbanManager;
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.data.auth.PlayerCache;
|
||||
import fr.xephi.authme.data.limbo.LimboService;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.events.AuthMeAsyncPreLoginEvent;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
@@ -23,7 +24,6 @@ import fr.xephi.authme.settings.properties.EmailSettings;
|
||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||
import fr.xephi.authme.task.LimboPlayerTaskManager;
|
||||
import fr.xephi.authme.util.PlayerUtils;
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -66,7 +66,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
||||
private TempbanManager tempbanManager;
|
||||
|
||||
@Inject
|
||||
private LimboPlayerTaskManager limboPlayerTaskManager;
|
||||
private LimboService limboService;
|
||||
|
||||
AsynchronousLogin() {
|
||||
}
|
||||
@@ -114,8 +114,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
||||
if (auth == null) {
|
||||
service.send(player, MessageKey.UNKNOWN_USER);
|
||||
// Recreate the message task to immediately send the message again as response
|
||||
// and to make sure we send the right register message (password vs. email registration)
|
||||
limboPlayerTaskManager.registerMessageTask(name, false);
|
||||
limboService.resetMessageTask(player, false);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -190,7 +189,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
||||
|
||||
// If the authentication fails check if Captcha is required and send a message to the player
|
||||
if (captchaManager.isCaptchaRequired(player.getName())) {
|
||||
limboPlayerTaskManager.muteMessageTask(player);
|
||||
limboService.muteMessageTask(player);
|
||||
service.send(player, MessageKey.USAGE_CAPTCHA,
|
||||
captchaManager.getCaptchaCodeOrGenerateNew(player.getName()));
|
||||
}
|
||||
@@ -241,7 +240,6 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
||||
// task, we schedule it in the end
|
||||
// so that we can be sure, and have not to care if it might be
|
||||
// processed in other order.
|
||||
limboPlayerTaskManager.clearTasks(player);
|
||||
syncProcessManager.processSyncPlayerLogin(player);
|
||||
} else {
|
||||
ConsoleLogger.warning("Player '" + player.getName() + "' wasn't online during login process, aborted...");
|
||||
|
||||
@@ -7,13 +7,12 @@ import fr.xephi.authme.events.LogoutEvent;
|
||||
import fr.xephi.authme.listener.protocollib.ProtocolLibService;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.permission.AuthGroupType;
|
||||
import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.process.SynchronousProcess;
|
||||
import fr.xephi.authme.service.BukkitService;
|
||||
import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.service.TeleportationService;
|
||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||
import fr.xephi.authme.task.LimboPlayerTaskManager;
|
||||
import fr.xephi.authme.service.BukkitService;
|
||||
import fr.xephi.authme.service.TeleportationService;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
@@ -34,9 +33,6 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
|
||||
@Inject
|
||||
private ProtocolLibService protocolLibService;
|
||||
|
||||
@Inject
|
||||
private LimboPlayerTaskManager limboPlayerTaskManager;
|
||||
|
||||
@Inject
|
||||
private LimboService limboService;
|
||||
|
||||
@@ -59,9 +55,6 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
|
||||
|
||||
applyLogoutEffect(player);
|
||||
|
||||
limboPlayerTaskManager.registerTimeoutTask(player);
|
||||
limboPlayerTaskManager.registerMessageTask(name, true);
|
||||
|
||||
// Player is now logout... Time to fire event !
|
||||
bukkitService.callEvent(new LogoutEvent(player));
|
||||
|
||||
@@ -81,7 +74,7 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
|
||||
}
|
||||
|
||||
// Set player's data to unauthenticated
|
||||
limboService.createLimboPlayer(player);
|
||||
limboService.createLimboPlayer(player, true);
|
||||
service.setGroup(player, AuthGroupType.REGISTERED_UNAUTHENTICATED);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package fr.xephi.authme.process.register;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.data.limbo.LimboService;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.permission.AuthGroupType;
|
||||
import fr.xephi.authme.process.SynchronousProcess;
|
||||
import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.task.LimboPlayerTaskManager;
|
||||
import fr.xephi.authme.util.PlayerUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -18,7 +18,7 @@ public class ProcessSyncEmailRegister implements SynchronousProcess {
|
||||
private CommonService service;
|
||||
|
||||
@Inject
|
||||
private LimboPlayerTaskManager limboPlayerTaskManager;
|
||||
private LimboService limboService;
|
||||
|
||||
ProcessSyncEmailRegister() {
|
||||
}
|
||||
@@ -27,9 +27,7 @@ public class ProcessSyncEmailRegister implements SynchronousProcess {
|
||||
service.setGroup(player, AuthGroupType.REGISTERED_UNAUTHENTICATED);
|
||||
service.send(player, MessageKey.ACCOUNT_NOT_ACTIVATED);
|
||||
|
||||
final String name = player.getName().toLowerCase();
|
||||
limboPlayerTaskManager.registerTimeoutTask(player);
|
||||
limboPlayerTaskManager.registerMessageTask(name, true);
|
||||
limboService.replaceTasksAfterRegistration(player);
|
||||
|
||||
player.saveData();
|
||||
ConsoleLogger.fine(player.getName() + " registered " + PlayerUtils.getPlayerIp(player));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.process.register;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.data.limbo.LimboService;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.permission.AuthGroupType;
|
||||
import fr.xephi.authme.process.SynchronousProcess;
|
||||
@@ -9,7 +10,6 @@ import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.settings.commandconfig.CommandManager;
|
||||
import fr.xephi.authme.settings.properties.EmailSettings;
|
||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||
import fr.xephi.authme.task.LimboPlayerTaskManager;
|
||||
import fr.xephi.authme.util.PlayerUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
|
||||
private CommonService service;
|
||||
|
||||
@Inject
|
||||
private LimboPlayerTaskManager limboPlayerTaskManager;
|
||||
private LimboService limboService;
|
||||
|
||||
@Inject
|
||||
private CommandManager commandManager;
|
||||
@@ -40,9 +40,7 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
|
||||
* @param player the player
|
||||
*/
|
||||
private void requestLogin(Player player) {
|
||||
final String name = player.getName().toLowerCase();
|
||||
limboPlayerTaskManager.registerTimeoutTask(player);
|
||||
limboPlayerTaskManager.registerMessageTask(name, true);
|
||||
limboService.replaceTasksAfterRegistration(player);
|
||||
|
||||
if (player.isInsideVehicle() && player.getVehicle() != null) {
|
||||
player.getVehicle().eject();
|
||||
|
||||
@@ -15,7 +15,6 @@ import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.service.TeleportationService;
|
||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||
import fr.xephi.authme.task.LimboPlayerTaskManager;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
@@ -45,9 +44,6 @@ public class AsynchronousUnregister implements AsynchronousProcess {
|
||||
@Inject
|
||||
private LimboService limboService;
|
||||
|
||||
@Inject
|
||||
private LimboPlayerTaskManager limboPlayerTaskManager;
|
||||
|
||||
@Inject
|
||||
private TeleportationService teleportationService;
|
||||
|
||||
@@ -112,10 +108,7 @@ public class AsynchronousUnregister implements AsynchronousProcess {
|
||||
player.saveData();
|
||||
|
||||
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(() -> {
|
||||
limboService.createLimboPlayer(player);
|
||||
limboPlayerTaskManager.registerTimeoutTask(player);
|
||||
limboPlayerTaskManager.registerMessageTask(name, false);
|
||||
|
||||
limboService.createLimboPlayer(player, false);
|
||||
applyBlindEffect(player);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user