diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/UnregisterAdminCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/UnregisterAdminCommand.java index 89f714ef..94f8ca15 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/UnregisterAdminCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/UnregisterAdminCommand.java @@ -9,22 +9,16 @@ import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.permission.AuthGroupHandler; import fr.xephi.authme.permission.AuthGroupType; -import fr.xephi.authme.settings.properties.RegistrationSettings; -import fr.xephi.authme.settings.properties.RestrictionSettings; +import fr.xephi.authme.process.Management; import fr.xephi.authme.task.LimboPlayerTaskManager; import fr.xephi.authme.util.BukkitService; import fr.xephi.authme.util.TeleportationService; -import fr.xephi.authme.util.Utils; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; import javax.inject.Inject; import java.util.List; -import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND; - /** * Admin command to unregister a player. */ @@ -54,6 +48,9 @@ public class UnregisterAdminCommand implements ExecutableCommand { @Inject private TeleportationService teleportationService; + @Inject + private Management management; + @Override public void executeCommand(final CommandSender sender, List arguments) { @@ -78,34 +75,11 @@ public class UnregisterAdminCommand implements ExecutableCommand { playerCache.removePlayer(playerNameLowerCase); authGroupHandler.setGroup(target, AuthGroupType.UNREGISTERED); if (target != null && target.isOnline()) { - if (commandService.getProperty(RegistrationSettings.FORCE)) { - applyUnregisteredEffectsAndTasks(target); - } - commandService.send(target, MessageKey.UNREGISTERED_SUCCESS); + management.performUnregister(target, "dontneed", true); } // Show a status message commandService.send(sender, MessageKey.UNREGISTERED_SUCCESS); ConsoleLogger.info(sender.getName() + " unregistered " + playerName); } - - /** - * When registration is forced, applies the configured "unregistered effects" to the player as he - * would encounter when joining the server before logging on - reminder task to log in, - * timeout kick, blindness. - * - * @param target the player that was unregistered - */ - private void applyUnregisteredEffectsAndTasks(Player target) { - teleportationService.teleportOnJoin(target); - - limboCache.addLimboPlayer(target); - limboPlayerTaskManager.registerTimeoutTask(target); - limboPlayerTaskManager.registerMessageTask(target.getName(), false); - - final int timeout = commandService.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND; - if (commandService.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) { - target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2)); - } - } } diff --git a/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java b/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java index 8d5653b9..92392b01 100644 --- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java @@ -80,9 +80,6 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess { */ private void requestLogin(Player player) { final String name = player.getName().toLowerCase(); - // TODO #765: Check if teleportation is needed here, and how - // Utils.teleportToSpawn(player); - limboCache.updateLimboPlayer(player); limboPlayerTaskManager.registerTimeoutTask(player); limboPlayerTaskManager.registerMessageTask(name, true); @@ -96,9 +93,6 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess { final String name = player.getName().toLowerCase(); LimboPlayer limbo = limboCache.getLimboPlayer(name); if (limbo != null) { - // TODO #765: Check if teleportation is needed here, and how - // Utils.teleportToSpawn(player); - if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN)) { RestoreInventoryEvent event = new RestoreInventoryEvent(player); bukkitService.callEvent(event); diff --git a/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java b/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java index f83e95be..5ca54488 100644 --- a/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java +++ b/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java @@ -70,7 +70,7 @@ public class AsynchronousUnregister implements AsynchronousProcess { limboPlayerTaskManager.registerMessageTask(name, false); service.send(player, MessageKey.UNREGISTERED_SUCCESS); - ConsoleLogger.info(player.getDisplayName() + " unregistered himself"); + ConsoleLogger.info(player.getName() + " unregistered himself"); return; // TODO ljacqu 20160612: Why return here? No blind effect? Player not removed from PlayerCache? } if (!Settings.unRegisteredGroup.isEmpty()) { @@ -84,7 +84,7 @@ public class AsynchronousUnregister implements AsynchronousProcess { player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2)); } service.send(player, MessageKey.UNREGISTERED_SUCCESS); - ConsoleLogger.info(player.getDisplayName() + " unregistered himself"); + ConsoleLogger.info(player.getName() + " unregistered himself"); } else { service.send(player, MessageKey.WRONG_PASSWORD); }