Merge 765-teleport-handling into jsoncache-fix
This commit is contained in:
+9
-32
@@ -9,21 +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.PlayerDataTaskManager;
|
||||
import fr.xephi.authme.util.BukkitService;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import fr.xephi.authme.util.TeleportationService;
|
||||
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.
|
||||
*/
|
||||
@@ -50,6 +45,12 @@ public class UnregisterAdminCommand implements ExecutableCommand {
|
||||
@Inject
|
||||
private AuthGroupHandler authGroupHandler;
|
||||
|
||||
@Inject
|
||||
private TeleportationService teleportationService;
|
||||
|
||||
@Inject
|
||||
private Management management;
|
||||
|
||||
|
||||
@Override
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||
@@ -74,35 +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) {
|
||||
// TODO #765: Remove use of Utils method and behave according to settings
|
||||
Utils.teleportToSpawn(target);
|
||||
|
||||
limboCache.addPlayerData(target);
|
||||
playerDataTaskManager.registerTimeoutTask(target);
|
||||
playerDataTaskManager.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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user