#765 Don't teleport after registration; make UnregisterAdminCommand use the unregister process

This commit is contained in:
ljacqu
2016-07-03 21:57:44 +02:00
parent 7788ad6230
commit 06322f37bf
3 changed files with 7 additions and 39 deletions
@@ -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<String> 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));
}
}
}