mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-09-19 10:21:44 +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.output.MessageKey;
|
||||||
import fr.xephi.authme.permission.AuthGroupHandler;
|
import fr.xephi.authme.permission.AuthGroupHandler;
|
||||||
import fr.xephi.authme.permission.AuthGroupType;
|
import fr.xephi.authme.permission.AuthGroupType;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.process.Management;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
|
||||||
import fr.xephi.authme.task.LimboPlayerTaskManager;
|
import fr.xephi.authme.task.LimboPlayerTaskManager;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.util.BukkitService;
|
||||||
import fr.xephi.authme.util.TeleportationService;
|
import fr.xephi.authme.util.TeleportationService;
|
||||||
import fr.xephi.authme.util.Utils;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Admin command to unregister a player.
|
* Admin command to unregister a player.
|
||||||
*/
|
*/
|
||||||
@ -54,6 +48,9 @@ public class UnregisterAdminCommand implements ExecutableCommand {
|
|||||||
@Inject
|
@Inject
|
||||||
private TeleportationService teleportationService;
|
private TeleportationService teleportationService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Management management;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||||
@ -78,34 +75,11 @@ public class UnregisterAdminCommand implements ExecutableCommand {
|
|||||||
playerCache.removePlayer(playerNameLowerCase);
|
playerCache.removePlayer(playerNameLowerCase);
|
||||||
authGroupHandler.setGroup(target, AuthGroupType.UNREGISTERED);
|
authGroupHandler.setGroup(target, AuthGroupType.UNREGISTERED);
|
||||||
if (target != null && target.isOnline()) {
|
if (target != null && target.isOnline()) {
|
||||||
if (commandService.getProperty(RegistrationSettings.FORCE)) {
|
management.performUnregister(target, "dontneed", true);
|
||||||
applyUnregisteredEffectsAndTasks(target);
|
|
||||||
}
|
|
||||||
commandService.send(target, MessageKey.UNREGISTERED_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show a status message
|
// Show a status message
|
||||||
commandService.send(sender, MessageKey.UNREGISTERED_SUCCESS);
|
commandService.send(sender, MessageKey.UNREGISTERED_SUCCESS);
|
||||||
ConsoleLogger.info(sender.getName() + " unregistered " + playerName);
|
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) {
|
private void requestLogin(Player player) {
|
||||||
final String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
// TODO #765: Check if teleportation is needed here, and how
|
|
||||||
// Utils.teleportToSpawn(player);
|
|
||||||
|
|
||||||
limboCache.updateLimboPlayer(player);
|
limboCache.updateLimboPlayer(player);
|
||||||
limboPlayerTaskManager.registerTimeoutTask(player);
|
limboPlayerTaskManager.registerTimeoutTask(player);
|
||||||
limboPlayerTaskManager.registerMessageTask(name, true);
|
limboPlayerTaskManager.registerMessageTask(name, true);
|
||||||
@ -96,9 +93,6 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
|
|||||||
final String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
LimboPlayer limbo = limboCache.getLimboPlayer(name);
|
LimboPlayer limbo = limboCache.getLimboPlayer(name);
|
||||||
if (limbo != null) {
|
if (limbo != null) {
|
||||||
// TODO #765: Check if teleportation is needed here, and how
|
|
||||||
// Utils.teleportToSpawn(player);
|
|
||||||
|
|
||||||
if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN)) {
|
if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN)) {
|
||||||
RestoreInventoryEvent event = new RestoreInventoryEvent(player);
|
RestoreInventoryEvent event = new RestoreInventoryEvent(player);
|
||||||
bukkitService.callEvent(event);
|
bukkitService.callEvent(event);
|
||||||
|
@ -70,7 +70,7 @@ public class AsynchronousUnregister implements AsynchronousProcess {
|
|||||||
limboPlayerTaskManager.registerMessageTask(name, false);
|
limboPlayerTaskManager.registerMessageTask(name, false);
|
||||||
|
|
||||||
service.send(player, MessageKey.UNREGISTERED_SUCCESS);
|
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?
|
return; // TODO ljacqu 20160612: Why return here? No blind effect? Player not removed from PlayerCache?
|
||||||
}
|
}
|
||||||
if (!Settings.unRegisteredGroup.isEmpty()) {
|
if (!Settings.unRegisteredGroup.isEmpty()) {
|
||||||
@ -84,7 +84,7 @@ public class AsynchronousUnregister implements AsynchronousProcess {
|
|||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2));
|
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2));
|
||||||
}
|
}
|
||||||
service.send(player, MessageKey.UNREGISTERED_SUCCESS);
|
service.send(player, MessageKey.UNREGISTERED_SUCCESS);
|
||||||
ConsoleLogger.info(player.getDisplayName() + " unregistered himself");
|
ConsoleLogger.info(player.getName() + " unregistered himself");
|
||||||
} else {
|
} else {
|
||||||
service.send(player, MessageKey.WRONG_PASSWORD);
|
service.send(player, MessageKey.WRONG_PASSWORD);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user