#1113 Create LimboService (work in progress)

- Introduce new LimboService with a higher level abstraction for outside classes to trigger LimboPlayer actions
- Add methods to LimboPlayerTaskManager for muting the MessagesTask safely
This commit is contained in:
ljacqu
2017-03-05 19:25:35 +01:00
parent 6db778387d
commit 22ccf582b8
21 changed files with 171 additions and 115 deletions
@@ -1,9 +1,9 @@
package fr.xephi.authme.command.executable.authme;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.limbo.LimboCache;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.limbo.LimboService;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.security.PasswordSecurity;
@@ -39,7 +39,7 @@ public class RegisterAdminCommand implements ExecutableCommand {
private ValidationService validationService;
@Inject
private LimboCache limboCache;
private LimboService limboService;
@Override
public void executeCommand(final CommandSender sender, List<String> arguments) {
@@ -83,7 +83,8 @@ public class RegisterAdminCommand implements ExecutableCommand {
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(new Runnable() {
@Override
public void run() {
limboCache.restoreData(player);
// TODO #1113: Is it necessary to restore here or is this covered by the quit process?
limboService.restoreData(player);
player.kickPlayer(commonService.retrieveSingleMessage(MessageKey.KICK_FOR_ADMIN_REGISTER));
}
});
@@ -3,9 +3,9 @@ package fr.xephi.authme.command.executable.captcha;
import fr.xephi.authme.command.PlayerCommand;
import fr.xephi.authme.data.CaptchaManager;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.data.limbo.LimboCache;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.task.LimboPlayerTaskManager;
import org.bukkit.entity.Player;
import javax.inject.Inject;
@@ -23,7 +23,7 @@ public class CaptchaCommand extends PlayerCommand {
private CommonService commonService;
@Inject
private LimboCache limboCache;
private LimboPlayerTaskManager limboPlayerTaskManager;
@Override
public void runCommand(Player player, List<String> arguments) {
@@ -43,7 +43,7 @@ public class CaptchaCommand extends PlayerCommand {
if (isCorrectCode) {
commonService.send(player, MessageKey.CAPTCHA_SUCCESS);
commonService.send(player, MessageKey.LOGIN_MESSAGE);
limboCache.getPlayerData(player.getName()).getMessageTask().setMuted(false);
limboPlayerTaskManager.unmuteMessageTask(player);
} else {
String newCode = captchaManager.generateCode(player.getName());
commonService.send(player, MessageKey.CAPTCHA_WRONG_ERROR, newCode);