Send logout message to bungee on self-unregister

This commit is contained in:
Gabriele C 2022-08-18 02:04:08 +02:00
parent 7c8bbe6294
commit b65ffd7c74
2 changed files with 9 additions and 1 deletions

View File

@ -31,7 +31,7 @@ public class UnregisterCommand extends PlayerCommand {
@Override @Override
public void runCommand(Player player, List<String> arguments) { public void runCommand(Player player, List<String> arguments) {
String playerPass = arguments.get(0); String playerPass = arguments.get(0);
final String playerName = player.getName(); String playerName = player.getName();
// Make sure the player is authenticated // Make sure the player is authenticated
if (!playerCache.isAuthenticated(playerName)) { if (!playerCache.isAuthenticated(playerName)) {

View File

@ -14,9 +14,11 @@ import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.CommonService; import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.service.TeleportationService; import fr.xephi.authme.service.TeleportationService;
import fr.xephi.authme.service.bungeecord.MessageType;
import fr.xephi.authme.settings.commandconfig.CommandManager; import fr.xephi.authme.settings.commandconfig.CommandManager;
import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.service.bungeecord.BungeeSender;
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.PotionEffect;
@ -54,6 +56,9 @@ public class AsynchronousUnregister implements AsynchronousProcess {
@Inject @Inject
private CommandManager commandManager; private CommandManager commandManager;
@Inject
private BungeeSender bungeeSender;
AsynchronousUnregister() { AsynchronousUnregister() {
} }
@ -112,6 +117,9 @@ public class AsynchronousUnregister implements AsynchronousProcess {
* @param player the according Player object (nullable) * @param player the according Player object (nullable)
*/ */
private void performPostUnregisterActions(String name, Player player) { private void performPostUnregisterActions(String name, Player player) {
if (player != null && playerCache.isAuthenticated(name)) {
bungeeSender.sendAuthMeBungeecordMessage(player, MessageType.LOGOUT);
}
playerCache.removePlayer(name); playerCache.removePlayer(name);
// TODO: send an update when a messaging service will be implemented (UNREGISTER) // TODO: send an update when a messaging service will be implemented (UNREGISTER)