mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-04-11 06:25:55 +02:00
#765 Don't teleport after registration; make UnregisterAdminCommand use the unregister process
This commit is contained in:
parent
7788ad6230
commit
06322f37bf
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user