Implement AuthMeBungee autologin (#1402)
* Implement AuthMeBungee autologin There is a failing test due to cyclic dependency injection, @ljacqu could you take a quick look at this? * Try to fix recursive dependency injection * Fix codestyle * Fix the subchannel name, again... * Split BungeeService into BungeeSender and BungeeReceiver
This commit is contained in:
@@ -6,10 +6,10 @@ import fr.xephi.authme.data.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.process.AsynchronousProcess;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeService;
|
||||
import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||
import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeSender;
|
||||
import fr.xephi.authme.service.bungeecord.MessageType;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -31,7 +31,7 @@ public class AsyncChangePassword implements AsynchronousProcess {
|
||||
private PlayerCache playerCache;
|
||||
|
||||
@Inject
|
||||
private BungeeService bungeeService;
|
||||
private BungeeSender bungeeSender;
|
||||
|
||||
AsyncChangePassword() {
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class AsyncChangePassword implements AsynchronousProcess {
|
||||
commonService.send(player, MessageKey.ERROR);
|
||||
return;
|
||||
}
|
||||
bungeeService.sendAuthMeBungeecordMessage(MessageType.REFRESH_PASSWORD, name);
|
||||
bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_PASSWORD, name);
|
||||
|
||||
playerCache.updatePlayer(auth);
|
||||
commonService.send(player, MessageKey.PASSWORD_CHANGED_SUCCESS);
|
||||
@@ -84,7 +84,7 @@ public class AsyncChangePassword implements AsynchronousProcess {
|
||||
|
||||
HashedPassword hashedPassword = passwordSecurity.computeHash(newPassword, lowerCaseName);
|
||||
if (dataSource.updatePassword(lowerCaseName, hashedPassword)) {
|
||||
bungeeService.sendAuthMeBungeecordMessage(MessageType.REFRESH_PASSWORD, lowerCaseName);
|
||||
bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_PASSWORD, lowerCaseName);
|
||||
if (sender != null) {
|
||||
commonService.send(sender, MessageKey.PASSWORD_CHANGED_SUCCESS);
|
||||
ConsoleLogger.info(sender.getName() + " changed password of " + lowerCaseName);
|
||||
|
||||
@@ -6,9 +6,9 @@ import fr.xephi.authme.data.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.process.AsynchronousProcess;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeService;
|
||||
import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.service.ValidationService;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeSender;
|
||||
import fr.xephi.authme.service.bungeecord.MessageType;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -33,7 +33,7 @@ public class AsyncAddEmail implements AsynchronousProcess {
|
||||
private ValidationService validationService;
|
||||
|
||||
@Inject
|
||||
private BungeeService bungeeService;
|
||||
private BungeeSender bungeeSender;
|
||||
|
||||
AsyncAddEmail() { }
|
||||
|
||||
@@ -60,7 +60,7 @@ public class AsyncAddEmail implements AsynchronousProcess {
|
||||
auth.setEmail(email);
|
||||
if (dataSource.updateEmail(auth)) {
|
||||
playerCache.updatePlayer(auth);
|
||||
bungeeService.sendAuthMeBungeecordMessage(MessageType.REFRESH_EMAIL, playerName);
|
||||
bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_EMAIL, playerName);
|
||||
service.send(player, MessageKey.EMAIL_ADDED_SUCCESS);
|
||||
} else {
|
||||
ConsoleLogger.warning("Could not save email for player '" + player + "'");
|
||||
|
||||
@@ -5,9 +5,9 @@ import fr.xephi.authme.data.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.process.AsynchronousProcess;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeService;
|
||||
import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.service.ValidationService;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeSender;
|
||||
import fr.xephi.authme.service.bungeecord.MessageType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -31,7 +31,7 @@ public class AsyncChangeEmail implements AsynchronousProcess {
|
||||
private ValidationService validationService;
|
||||
|
||||
@Inject
|
||||
private BungeeService bungeeService;
|
||||
private BungeeSender bungeeSender;
|
||||
|
||||
AsyncChangeEmail() { }
|
||||
|
||||
@@ -68,7 +68,7 @@ public class AsyncChangeEmail implements AsynchronousProcess {
|
||||
auth.setEmail(newEmail);
|
||||
if (dataSource.updateEmail(auth)) {
|
||||
playerCache.updatePlayer(auth);
|
||||
bungeeService.sendAuthMeBungeecordMessage(MessageType.REFRESH_EMAIL, player.getName());
|
||||
bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_EMAIL, player.getName());
|
||||
service.send(player, MessageKey.EMAIL_CHANGED_SUCCESS);
|
||||
} else {
|
||||
service.send(player, MessageKey.ERROR);
|
||||
|
||||
@@ -19,9 +19,9 @@ import fr.xephi.authme.process.AsynchronousProcess;
|
||||
import fr.xephi.authme.process.SyncProcessManager;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.service.BukkitService;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeService;
|
||||
import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.service.SessionService;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeSender;
|
||||
import fr.xephi.authme.service.bungeecord.MessageType;
|
||||
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
||||
import fr.xephi.authme.settings.properties.EmailSettings;
|
||||
@@ -76,7 +76,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
||||
private SessionService sessionService;
|
||||
|
||||
@Inject
|
||||
private BungeeService bungeeService;
|
||||
private BungeeSender bungeeSender;
|
||||
|
||||
AsynchronousLogin() {
|
||||
}
|
||||
@@ -226,7 +226,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
||||
auth.setLastLogin(System.currentTimeMillis());
|
||||
auth.setLastIp(ip);
|
||||
dataSource.updateSession(auth);
|
||||
bungeeService.sendAuthMeBungeecordMessage(MessageType.REFRESH_SESSION, player.getName());
|
||||
bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_SESSION, player.getName());
|
||||
|
||||
// Successful login, so reset the captcha & temp ban count
|
||||
final String name = player.getName();
|
||||
@@ -252,7 +252,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
||||
playerCache.updatePlayer(auth);
|
||||
dataSource.setLogged(name);
|
||||
sessionService.grantSession(name);
|
||||
bungeeService.sendAuthMeBungeecordMessage(MessageType.LOGIN, name);
|
||||
bungeeSender.sendAuthMeBungeecordMessage(MessageType.LOGIN, name);
|
||||
|
||||
// As the scheduling executes the Task most likely after the current
|
||||
// task, we schedule it in the end
|
||||
|
||||
@@ -8,10 +8,10 @@ import fr.xephi.authme.events.LoginEvent;
|
||||
import fr.xephi.authme.events.RestoreInventoryEvent;
|
||||
import fr.xephi.authme.process.SynchronousProcess;
|
||||
import fr.xephi.authme.service.BukkitService;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeService;
|
||||
import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.service.JoinMessageService;
|
||||
import fr.xephi.authme.service.TeleportationService;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeSender;
|
||||
import fr.xephi.authme.settings.WelcomeMessageConfiguration;
|
||||
import fr.xephi.authme.settings.commandconfig.CommandManager;
|
||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||
@@ -25,7 +25,7 @@ import static fr.xephi.authme.settings.properties.RestrictionSettings.PROTECT_IN
|
||||
public class ProcessSyncPlayerLogin implements SynchronousProcess {
|
||||
|
||||
@Inject
|
||||
private BungeeService bungeeService;
|
||||
private BungeeSender bungeeSender;
|
||||
|
||||
@Inject
|
||||
private LimboService limboService;
|
||||
@@ -96,6 +96,6 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
|
||||
commandManager.runCommandsOnLogin(player);
|
||||
|
||||
// Send Bungee stuff. The service will check if it is enabled or not.
|
||||
bungeeService.connectPlayerOnLogin(player);
|
||||
bungeeSender.connectPlayerOnLogin(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.process.AsynchronousProcess;
|
||||
import fr.xephi.authme.process.SyncProcessManager;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeService;
|
||||
import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.service.SessionService;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeSender;
|
||||
import fr.xephi.authme.service.bungeecord.MessageType;
|
||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -40,7 +40,7 @@ public class AsynchronousLogout implements AsynchronousProcess {
|
||||
private SessionService sessionService;
|
||||
|
||||
@Inject
|
||||
private BungeeService bungeeService;
|
||||
private BungeeSender bungeeSender;
|
||||
|
||||
AsynchronousLogout() {
|
||||
}
|
||||
@@ -59,18 +59,18 @@ public class AsynchronousLogout implements AsynchronousProcess {
|
||||
|
||||
PlayerAuth auth = playerCache.getAuth(name);
|
||||
database.updateSession(auth);
|
||||
bungeeService.sendAuthMeBungeecordMessage(MessageType.REFRESH_SESSION, name);
|
||||
bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_SESSION, name);
|
||||
if (service.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) {
|
||||
auth.setQuitLocation(player.getLocation());
|
||||
database.updateQuitLoc(auth);
|
||||
bungeeService.sendAuthMeBungeecordMessage(MessageType.REFRESH_QUITLOC, name);
|
||||
bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_QUITLOC, name);
|
||||
}
|
||||
|
||||
playerCache.removePlayer(name);
|
||||
codeManager.unverify(name);
|
||||
database.setUnlogged(name);
|
||||
sessionService.revokeSession(name);
|
||||
bungeeService.sendAuthMeBungeecordMessage(MessageType.LOGOUT, name);
|
||||
bungeeSender.sendAuthMeBungeecordMessage(MessageType.LOGOUT, name);
|
||||
syncProcessManager.processSyncPlayerLogout(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import fr.xephi.authme.process.SyncProcessManager;
|
||||
import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.service.SessionService;
|
||||
import fr.xephi.authme.service.ValidationService;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeService;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeSender;
|
||||
import fr.xephi.authme.service.bungeecord.MessageType;
|
||||
import fr.xephi.authme.settings.SpawnLoader;
|
||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||
@@ -54,7 +54,7 @@ public class AsynchronousQuit implements AsynchronousProcess {
|
||||
private SessionService sessionService;
|
||||
|
||||
@Inject
|
||||
private BungeeService bungeeService;
|
||||
private BungeeSender bungeeSender;
|
||||
|
||||
AsynchronousQuit() {
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class AsynchronousQuit implements AsynchronousProcess {
|
||||
.lastLogin(System.currentTimeMillis())
|
||||
.build();
|
||||
database.updateSession(auth);
|
||||
bungeeService.sendAuthMeBungeecordMessage(MessageType.REFRESH_QUITLOC, name);
|
||||
bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_QUITLOC, name);
|
||||
}
|
||||
|
||||
//always unauthenticate the player - use session only for auto logins on the same ip
|
||||
|
||||
@@ -8,10 +8,10 @@ import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.process.AsynchronousProcess;
|
||||
import fr.xephi.authme.process.register.executors.RegistrationExecutor;
|
||||
import fr.xephi.authme.process.register.executors.RegistrationParameters;
|
||||
import fr.xephi.authme.process.register.executors.RegistrationMethod;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeService;
|
||||
import fr.xephi.authme.process.register.executors.RegistrationParameters;
|
||||
import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeSender;
|
||||
import fr.xephi.authme.service.bungeecord.MessageType;
|
||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||
@@ -39,7 +39,7 @@ public class AsyncRegister implements AsynchronousProcess {
|
||||
@Inject
|
||||
private SingletonStore<RegistrationExecutor> registrationExecutorFactory;
|
||||
@Inject
|
||||
private BungeeService bungeeService;
|
||||
private BungeeSender bungeeSender;
|
||||
|
||||
AsyncRegister() {
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class AsyncRegister implements AsynchronousProcess {
|
||||
PlayerAuth auth = executor.buildPlayerAuth(parameters);
|
||||
if (database.saveAuth(auth)) {
|
||||
executor.executePostPersistAction(parameters);
|
||||
bungeeService.sendAuthMeBungeecordMessage(MessageType.REGISTER, parameters.getPlayerName());
|
||||
bungeeSender.sendAuthMeBungeecordMessage(MessageType.REGISTER, parameters.getPlayerName());
|
||||
} else {
|
||||
service.send(parameters.getPlayer(), MessageKey.ERROR);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.data.limbo.LimboService;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.process.SynchronousProcess;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeService;
|
||||
import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeSender;
|
||||
import fr.xephi.authme.settings.commandconfig.CommandManager;
|
||||
import fr.xephi.authme.settings.properties.EmailSettings;
|
||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||
@@ -19,7 +19,7 @@ import javax.inject.Inject;
|
||||
public class ProcessSyncPasswordRegister implements SynchronousProcess {
|
||||
|
||||
@Inject
|
||||
private BungeeService bungeeService;
|
||||
private BungeeSender bungeeSender;
|
||||
|
||||
@Inject
|
||||
private CommonService service;
|
||||
@@ -72,6 +72,6 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
|
||||
}
|
||||
|
||||
// Send Bungee stuff. The service will check if it is enabled or not.
|
||||
bungeeService.connectPlayerOnLogin(player);
|
||||
bungeeSender.connectPlayerOnLogin(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.process.AsynchronousProcess;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.service.BukkitService;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeService;
|
||||
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;
|
||||
@@ -54,7 +54,7 @@ public class AsynchronousUnregister implements AsynchronousProcess {
|
||||
private CommandManager commandManager;
|
||||
|
||||
@Inject
|
||||
private BungeeService bungeeService;
|
||||
private BungeeSender bungeeSender;
|
||||
|
||||
AsynchronousUnregister() {
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class AsynchronousUnregister implements AsynchronousProcess {
|
||||
*/
|
||||
private void performPostUnregisterActions(String name, Player player) {
|
||||
playerCache.removePlayer(name);
|
||||
bungeeService.sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name);
|
||||
bungeeSender.sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name);
|
||||
|
||||
if (player == null || !player.isOnline()) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user