Codestyle cleanup

This commit is contained in:
Gabriele C 2017-11-02 13:00:48 +01:00
parent 273c318e96
commit ff53ff1ce6
2 changed files with 17 additions and 5 deletions

View File

@ -71,7 +71,7 @@ public class AsynchronousUnregister implements AsynchronousProcess {
final PlayerAuth cachedAuth = playerCache.getAuth(name); final PlayerAuth cachedAuth = playerCache.getAuth(name);
if (passwordSecurity.comparePassword(password, cachedAuth.getPassword(), name)) { if (passwordSecurity.comparePassword(password, cachedAuth.getPassword(), name)) {
if (dataSource.removeAuth(name)) { if (dataSource.removeAuth(name)) {
performUnregister(name, player); performPostUnregisterActions(name, player);
ConsoleLogger.info(name + " unregistered himself"); ConsoleLogger.info(name + " unregistered himself");
bukkitService.createAndCallEvent(isAsync -> new UnregisterByPlayerEvent(player, isAsync)); bukkitService.createAndCallEvent(isAsync -> new UnregisterByPlayerEvent(player, isAsync));
} else { } 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 initiator the initiator of this process (nullable)
* @param name the name of the player * @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 // 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) { public void adminUnregister(CommandSender initiator, String name, Player player) {
if (dataSource.removeAuth(name)) { if (dataSource.removeAuth(name)) {
performUnregister(name, player); performPostUnregisterActions(name, player);
bukkitService.createAndCallEvent(isAsync -> new UnregisterByAdminEvent(player, name, isAsync, initiator)); bukkitService.createAndCallEvent(isAsync -> new UnregisterByAdminEvent(player, name, isAsync, initiator));
if (initiator == null) { 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); playerCache.removePlayer(name);
bungeeService.sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name); bungeeService.sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name);
@ -134,4 +140,5 @@ public class AsynchronousUnregister implements AsynchronousProcess {
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2)); player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2));
} }
} }
} }

View File

@ -5,7 +5,6 @@ import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.datasource.CacheDataSource;
import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.initialization.SettingsDependent; import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.service.BukkitService;
@ -80,6 +79,12 @@ public class BungeeService implements SettingsDependent, PluginMessageListener {
sendBungeecordMessage("Connect", player.getName(), destinationServerOnLogin), 20L); 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) { public void sendAuthMeBungeecordMessage(String type, String playerName) {
if(!isEnabled) { if(!isEnabled) {
return; return;