Remove cache-update bungee messages, always use the player in the context to send bungee messages, minor codestyle changes

This commit is contained in:
Gabriele C
2022-08-18 01:48:34 +02:00
parent fd0a0a1155
commit 7c8bbe6294
16 changed files with 112 additions and 186 deletions
@@ -14,8 +14,6 @@ import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.service.TeleportationService;
import fr.xephi.authme.service.bungeecord.BungeeSender;
import fr.xephi.authme.service.bungeecord.MessageType;
import fr.xephi.authme.settings.commandconfig.CommandManager;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
@@ -56,9 +54,6 @@ public class AsynchronousUnregister implements AsynchronousProcess {
@Inject
private CommandManager commandManager;
@Inject
private BungeeSender bungeeSender;
AsynchronousUnregister() {
}
@@ -70,8 +65,8 @@ public class AsynchronousUnregister implements AsynchronousProcess {
* @param password the input password to check before unregister
*/
public void unregister(Player player, String password) {
final String name = player.getName();
final PlayerAuth cachedAuth = playerCache.getAuth(name);
String name = player.getName();
PlayerAuth cachedAuth = playerCache.getAuth(name);
if (passwordSecurity.comparePassword(password, cachedAuth.getPassword(), name)) {
if (dataSource.removeAuth(name)) {
performPostUnregisterActions(name, player);
@@ -118,7 +113,8 @@ public class AsynchronousUnregister implements AsynchronousProcess {
*/
private void performPostUnregisterActions(String name, Player player) {
playerCache.removePlayer(name);
bungeeSender.sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name);
// TODO: send an update when a messaging service will be implemented (UNREGISTER)
if (player == null || !player.isOnline()) {
return;
@@ -137,7 +133,7 @@ public class AsynchronousUnregister implements AsynchronousProcess {
service.send(player, MessageKey.UNREGISTERED_SUCCESS);
}
private void applyBlindEffect(final Player player) {
private void applyBlindEffect(Player player) {
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
int timeout = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2));