From ff53ff1ce62b09b15cbfb3562ee041fd0cba3a2c Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Thu, 2 Nov 2017 13:00:48 +0100 Subject: [PATCH] Codestyle cleanup --- .../unregister/AsynchronousUnregister.java | 15 +++++++++++---- .../authme/service/bungeecord/BungeeService.java | 7 ++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java b/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java index 89105c76..d4845c93 100644 --- a/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java +++ b/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java @@ -71,7 +71,7 @@ public class AsynchronousUnregister implements AsynchronousProcess { final PlayerAuth cachedAuth = playerCache.getAuth(name); if (passwordSecurity.comparePassword(password, cachedAuth.getPassword(), name)) { if (dataSource.removeAuth(name)) { - performUnregister(name, player); + performPostUnregisterActions(name, player); ConsoleLogger.info(name + " unregistered himself"); bukkitService.createAndCallEvent(isAsync -> new UnregisterByPlayerEvent(player, isAsync)); } else { @@ -83,7 +83,7 @@ public class AsynchronousUnregister implements AsynchronousProcess { } /** - * Unregisters a player. + * Unregisters a player as administrator or console. * * @param initiator the initiator of this process (nullable) * @param name the name of the player @@ -93,7 +93,7 @@ public class AsynchronousUnregister implements AsynchronousProcess { // we might have some player in the database that has never been online on the server public void adminUnregister(CommandSender initiator, String name, Player player) { if (dataSource.removeAuth(name)) { - performUnregister(name, player); + performPostUnregisterActions(name, player); bukkitService.createAndCallEvent(isAsync -> new UnregisterByAdminEvent(player, name, isAsync, initiator)); if (initiator == null) { @@ -107,7 +107,13 @@ public class AsynchronousUnregister implements AsynchronousProcess { } } - private void performUnregister(String name, Player player) { + /** + * Process the post unregister actions. Makes the user status consistent. + * + * @param name the name of the player + * @param player the according Player object (nullable) + */ + private void performPostUnregisterActions(String name, Player player) { playerCache.removePlayer(name); bungeeService.sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name); @@ -134,4 +140,5 @@ public class AsynchronousUnregister implements AsynchronousProcess { player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2)); } } + } diff --git a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeService.java b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeService.java index fb23771a..08058b39 100644 --- a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeService.java +++ b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeService.java @@ -5,7 +5,6 @@ import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; import fr.xephi.authme.AuthMe; import fr.xephi.authme.ConsoleLogger; -import fr.xephi.authme.datasource.CacheDataSource; import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.initialization.SettingsDependent; import fr.xephi.authme.service.BukkitService; @@ -80,6 +79,12 @@ public class BungeeService implements SettingsDependent, PluginMessageListener { sendBungeecordMessage("Connect", player.getName(), destinationServerOnLogin), 20L); } + /** + * Sends a message to the AuthMe plugin messaging channel, if enabled. + * + * @param type The message type, {@see MessageType} + * @param playerName the player related to the message + */ public void sendAuthMeBungeecordMessage(String type, String playerName) { if(!isEnabled) { return;