mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-27 12:45:57 +01:00
Implement bungee messaging, CacheDataSource sync
This commit is contained in:
parent
a5542051f4
commit
2d2eb740e3
@ -4,6 +4,7 @@ import fr.xephi.authme.command.ExecutableCommand;
|
|||||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.message.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
|
import fr.xephi.authme.service.BungeeService;
|
||||||
import fr.xephi.authme.service.CommonService;
|
import fr.xephi.authme.service.CommonService;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
@ -21,6 +22,9 @@ public class PurgeLastPositionCommand implements ExecutableCommand {
|
|||||||
@Inject
|
@Inject
|
||||||
private CommonService commonService;
|
private CommonService commonService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private BungeeService bungeeService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||||
String playerName = arguments.isEmpty() ? sender.getName() : arguments.get(0);
|
String playerName = arguments.isEmpty() ? sender.getName() : arguments.get(0);
|
||||||
@ -29,6 +33,7 @@ public class PurgeLastPositionCommand implements ExecutableCommand {
|
|||||||
for (PlayerAuth auth : dataSource.getAllAuths()) {
|
for (PlayerAuth auth : dataSource.getAllAuths()) {
|
||||||
resetLastPosition(auth);
|
resetLastPosition(auth);
|
||||||
dataSource.updateQuitLoc(auth);
|
dataSource.updateQuitLoc(auth);
|
||||||
|
bungeeService.sendRefreshQuitLoc(playerName);
|
||||||
}
|
}
|
||||||
sender.sendMessage("All players last position locations are now reset");
|
sender.sendMessage("All players last position locations are now reset");
|
||||||
} else {
|
} else {
|
||||||
@ -41,6 +46,7 @@ public class PurgeLastPositionCommand implements ExecutableCommand {
|
|||||||
|
|
||||||
resetLastPosition(auth);
|
resetLastPosition(auth);
|
||||||
dataSource.updateQuitLoc(auth);
|
dataSource.updateQuitLoc(auth);
|
||||||
|
bungeeService.sendRefreshQuitLoc(playerName);
|
||||||
sender.sendMessage(playerName + "'s last position location is now reset");
|
sender.sendMessage(playerName + "'s last position location is now reset");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import fr.xephi.authme.data.auth.PlayerCache;
|
|||||||
import fr.xephi.authme.data.limbo.LimboService;
|
import fr.xephi.authme.data.limbo.LimboService;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.service.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
|
import fr.xephi.authme.service.BungeeService;
|
||||||
import fr.xephi.authme.service.ValidationService;
|
import fr.xephi.authme.service.ValidationService;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.SpawnLoader;
|
import fr.xephi.authme.settings.SpawnLoader;
|
||||||
@ -34,6 +35,8 @@ public class OnShutdownPlayerSaver {
|
|||||||
private PlayerCache playerCache;
|
private PlayerCache playerCache;
|
||||||
@Inject
|
@Inject
|
||||||
private LimboService limboService;
|
private LimboService limboService;
|
||||||
|
@Inject
|
||||||
|
private BungeeService bungeeService;
|
||||||
|
|
||||||
OnShutdownPlayerSaver() {
|
OnShutdownPlayerSaver() {
|
||||||
}
|
}
|
||||||
@ -68,6 +71,7 @@ public class OnShutdownPlayerSaver {
|
|||||||
.realName(player.getName())
|
.realName(player.getName())
|
||||||
.location(loc).build();
|
.location(loc).build();
|
||||||
dataSource.updateQuitLoc(auth);
|
dataSource.updateQuitLoc(auth);
|
||||||
|
bungeeService.sendRefreshQuitLoc(player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import fr.xephi.authme.permission.PermissionsManager;
|
|||||||
import fr.xephi.authme.process.Management;
|
import fr.xephi.authme.process.Management;
|
||||||
import fr.xephi.authme.service.AntiBotService;
|
import fr.xephi.authme.service.AntiBotService;
|
||||||
import fr.xephi.authme.service.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
|
import fr.xephi.authme.service.BungeeService;
|
||||||
import fr.xephi.authme.service.JoinMessageService;
|
import fr.xephi.authme.service.JoinMessageService;
|
||||||
import fr.xephi.authme.service.TeleportationService;
|
import fr.xephi.authme.service.TeleportationService;
|
||||||
import fr.xephi.authme.service.ValidationService;
|
import fr.xephi.authme.service.ValidationService;
|
||||||
@ -82,6 +83,8 @@ public class PlayerListener implements Listener {
|
|||||||
private JoinMessageService joinMessageService;
|
private JoinMessageService joinMessageService;
|
||||||
@Inject
|
@Inject
|
||||||
private PermissionsManager permissionsManager;
|
private PermissionsManager permissionsManager;
|
||||||
|
@Inject
|
||||||
|
private BungeeService bungeeService;
|
||||||
|
|
||||||
private static boolean isAsyncPlayerPreLoginEventCalled = false;
|
private static boolean isAsyncPlayerPreLoginEventCalled = false;
|
||||||
|
|
||||||
@ -421,6 +424,7 @@ public class PlayerListener implements Listener {
|
|||||||
.location(spawn)
|
.location(spawn)
|
||||||
.build();
|
.build();
|
||||||
dataSource.updateQuitLoc(auth);
|
dataSource.updateQuitLoc(auth);
|
||||||
|
bungeeService.sendRefreshQuitLoc(name);
|
||||||
}
|
}
|
||||||
if (spawn != null && spawn.getWorld() != null) {
|
if (spawn != null && spawn.getWorld() != null) {
|
||||||
event.setRespawnLocation(spawn);
|
event.setRespawnLocation(spawn);
|
||||||
|
@ -6,6 +6,7 @@ import fr.xephi.authme.data.auth.PlayerCache;
|
|||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.message.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import fr.xephi.authme.process.AsynchronousProcess;
|
import fr.xephi.authme.process.AsynchronousProcess;
|
||||||
|
import fr.xephi.authme.service.BungeeService;
|
||||||
import fr.xephi.authme.service.CommonService;
|
import fr.xephi.authme.service.CommonService;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
@ -28,6 +29,9 @@ public class AsyncChangePassword implements AsynchronousProcess {
|
|||||||
@Inject
|
@Inject
|
||||||
private PlayerCache playerCache;
|
private PlayerCache playerCache;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private BungeeService bungeeService;
|
||||||
|
|
||||||
AsyncChangePassword() {
|
AsyncChangePassword() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,6 +53,7 @@ public class AsyncChangePassword implements AsynchronousProcess {
|
|||||||
commonService.send(player, MessageKey.ERROR);
|
commonService.send(player, MessageKey.ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
bungeeService.sendRefreshPassword(name);
|
||||||
|
|
||||||
playerCache.updatePlayer(auth);
|
playerCache.updatePlayer(auth);
|
||||||
commonService.send(player, MessageKey.PASSWORD_CHANGED_SUCCESS);
|
commonService.send(player, MessageKey.PASSWORD_CHANGED_SUCCESS);
|
||||||
@ -78,6 +83,7 @@ public class AsyncChangePassword implements AsynchronousProcess {
|
|||||||
|
|
||||||
HashedPassword hashedPassword = passwordSecurity.computeHash(newPassword, lowerCaseName);
|
HashedPassword hashedPassword = passwordSecurity.computeHash(newPassword, lowerCaseName);
|
||||||
if (dataSource.updatePassword(lowerCaseName, hashedPassword)) {
|
if (dataSource.updatePassword(lowerCaseName, hashedPassword)) {
|
||||||
|
bungeeService.sendRefreshPassword(lowerCaseName);
|
||||||
if (sender != null) {
|
if (sender != null) {
|
||||||
commonService.send(sender, MessageKey.PASSWORD_CHANGED_SUCCESS);
|
commonService.send(sender, MessageKey.PASSWORD_CHANGED_SUCCESS);
|
||||||
ConsoleLogger.info(sender.getName() + " changed password of " + lowerCaseName);
|
ConsoleLogger.info(sender.getName() + " changed password of " + lowerCaseName);
|
||||||
|
@ -6,6 +6,7 @@ import fr.xephi.authme.data.auth.PlayerCache;
|
|||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.message.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import fr.xephi.authme.process.AsynchronousProcess;
|
import fr.xephi.authme.process.AsynchronousProcess;
|
||||||
|
import fr.xephi.authme.service.BungeeService;
|
||||||
import fr.xephi.authme.service.CommonService;
|
import fr.xephi.authme.service.CommonService;
|
||||||
import fr.xephi.authme.service.ValidationService;
|
import fr.xephi.authme.service.ValidationService;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
@ -30,6 +31,9 @@ public class AsyncAddEmail implements AsynchronousProcess {
|
|||||||
@Inject
|
@Inject
|
||||||
private ValidationService validationService;
|
private ValidationService validationService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private BungeeService bungeeService;
|
||||||
|
|
||||||
AsyncAddEmail() { }
|
AsyncAddEmail() { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,6 +59,7 @@ public class AsyncAddEmail implements AsynchronousProcess {
|
|||||||
auth.setEmail(email);
|
auth.setEmail(email);
|
||||||
if (dataSource.updateEmail(auth)) {
|
if (dataSource.updateEmail(auth)) {
|
||||||
playerCache.updatePlayer(auth);
|
playerCache.updatePlayer(auth);
|
||||||
|
bungeeService.sendRefreshEmail(playerName);
|
||||||
service.send(player, MessageKey.EMAIL_ADDED_SUCCESS);
|
service.send(player, MessageKey.EMAIL_ADDED_SUCCESS);
|
||||||
} else {
|
} else {
|
||||||
ConsoleLogger.warning("Could not save email for player '" + player + "'");
|
ConsoleLogger.warning("Could not save email for player '" + player + "'");
|
||||||
|
@ -5,6 +5,7 @@ import fr.xephi.authme.data.auth.PlayerCache;
|
|||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.message.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import fr.xephi.authme.process.AsynchronousProcess;
|
import fr.xephi.authme.process.AsynchronousProcess;
|
||||||
|
import fr.xephi.authme.service.BungeeService;
|
||||||
import fr.xephi.authme.service.CommonService;
|
import fr.xephi.authme.service.CommonService;
|
||||||
import fr.xephi.authme.service.ValidationService;
|
import fr.xephi.authme.service.ValidationService;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -28,6 +29,9 @@ public class AsyncChangeEmail implements AsynchronousProcess {
|
|||||||
@Inject
|
@Inject
|
||||||
private ValidationService validationService;
|
private ValidationService validationService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private BungeeService bungeeService;
|
||||||
|
|
||||||
AsyncChangeEmail() { }
|
AsyncChangeEmail() { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,6 +67,7 @@ public class AsyncChangeEmail implements AsynchronousProcess {
|
|||||||
auth.setEmail(newEmail);
|
auth.setEmail(newEmail);
|
||||||
if (dataSource.updateEmail(auth)) {
|
if (dataSource.updateEmail(auth)) {
|
||||||
playerCache.updatePlayer(auth);
|
playerCache.updatePlayer(auth);
|
||||||
|
bungeeService.sendRefreshEmail(player.getName());
|
||||||
service.send(player, MessageKey.EMAIL_CHANGED_SUCCESS);
|
service.send(player, MessageKey.EMAIL_CHANGED_SUCCESS);
|
||||||
} else {
|
} else {
|
||||||
service.send(player, MessageKey.ERROR);
|
service.send(player, MessageKey.ERROR);
|
||||||
|
@ -19,6 +19,7 @@ import fr.xephi.authme.process.AsynchronousProcess;
|
|||||||
import fr.xephi.authme.process.SyncProcessManager;
|
import fr.xephi.authme.process.SyncProcessManager;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.service.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
|
import fr.xephi.authme.service.BungeeService;
|
||||||
import fr.xephi.authme.service.CommonService;
|
import fr.xephi.authme.service.CommonService;
|
||||||
import fr.xephi.authme.service.SessionService;
|
import fr.xephi.authme.service.SessionService;
|
||||||
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
||||||
@ -73,6 +74,9 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
|||||||
@Inject
|
@Inject
|
||||||
private SessionService sessionService;
|
private SessionService sessionService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private BungeeService bungeeService;
|
||||||
|
|
||||||
AsynchronousLogin() {
|
AsynchronousLogin() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,6 +225,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
|||||||
auth.setLastLogin(System.currentTimeMillis());
|
auth.setLastLogin(System.currentTimeMillis());
|
||||||
auth.setLastIp(ip);
|
auth.setLastIp(ip);
|
||||||
dataSource.updateSession(auth);
|
dataSource.updateSession(auth);
|
||||||
|
bungeeService.sendRefreshSession(player.getName());
|
||||||
|
|
||||||
// Successful login, so reset the captcha & temp ban count
|
// Successful login, so reset the captcha & temp ban count
|
||||||
final String name = player.getName();
|
final String name = player.getName();
|
||||||
@ -246,6 +251,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
|||||||
playerCache.updatePlayer(auth);
|
playerCache.updatePlayer(auth);
|
||||||
dataSource.setLogged(name);
|
dataSource.setLogged(name);
|
||||||
sessionService.grantSession(name);
|
sessionService.grantSession(name);
|
||||||
|
bungeeService.sendLogin(name);
|
||||||
|
|
||||||
// As the scheduling executes the Task most likely after the current
|
// As the scheduling executes the Task most likely after the current
|
||||||
// task, we schedule it in the end
|
// task, we schedule it in the end
|
||||||
|
@ -96,6 +96,6 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
|
|||||||
commandManager.runCommandsOnLogin(player);
|
commandManager.runCommandsOnLogin(player);
|
||||||
|
|
||||||
// Send Bungee stuff. The service will check if it is enabled or not.
|
// Send Bungee stuff. The service will check if it is enabled or not.
|
||||||
bungeeService.connectPlayer(player);
|
bungeeService.connectPlayerOnLogin(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,9 @@ import fr.xephi.authme.datasource.DataSource;
|
|||||||
import fr.xephi.authme.message.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import fr.xephi.authme.process.AsynchronousProcess;
|
import fr.xephi.authme.process.AsynchronousProcess;
|
||||||
import fr.xephi.authme.process.SyncProcessManager;
|
import fr.xephi.authme.process.SyncProcessManager;
|
||||||
|
import fr.xephi.authme.service.BungeeService;
|
||||||
import fr.xephi.authme.service.CommonService;
|
import fr.xephi.authme.service.CommonService;
|
||||||
|
import fr.xephi.authme.service.SessionService;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -33,6 +35,12 @@ public class AsynchronousLogout implements AsynchronousProcess {
|
|||||||
@Inject
|
@Inject
|
||||||
private SyncProcessManager syncProcessManager;
|
private SyncProcessManager syncProcessManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private SessionService sessionService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private BungeeService bungeeService;
|
||||||
|
|
||||||
AsynchronousLogout() {
|
AsynchronousLogout() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,15 +58,18 @@ public class AsynchronousLogout implements AsynchronousProcess {
|
|||||||
|
|
||||||
PlayerAuth auth = playerCache.getAuth(name);
|
PlayerAuth auth = playerCache.getAuth(name);
|
||||||
database.updateSession(auth);
|
database.updateSession(auth);
|
||||||
|
bungeeService.sendRefreshSession(name);
|
||||||
if (service.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) {
|
if (service.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) {
|
||||||
auth.setQuitLocation(player.getLocation());
|
auth.setQuitLocation(player.getLocation());
|
||||||
database.updateQuitLoc(auth);
|
database.updateQuitLoc(auth);
|
||||||
|
bungeeService.sendRefreshQuitLoc(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
playerCache.removePlayer(name);
|
playerCache.removePlayer(name);
|
||||||
codeManager.unverify(name);
|
codeManager.unverify(name);
|
||||||
database.setUnlogged(name);
|
database.setUnlogged(name);
|
||||||
database.revokeSession(name);
|
sessionService.revokeSession(name);
|
||||||
|
bungeeService.sendLogout(name);
|
||||||
syncProcessManager.processSyncPlayerLogout(player);
|
syncProcessManager.processSyncPlayerLogout(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,10 @@ import fr.xephi.authme.data.auth.PlayerCache;
|
|||||||
import fr.xephi.authme.datasource.CacheDataSource;
|
import fr.xephi.authme.datasource.CacheDataSource;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.process.AsynchronousProcess;
|
import fr.xephi.authme.process.AsynchronousProcess;
|
||||||
|
import fr.xephi.authme.service.BungeeService;
|
||||||
import fr.xephi.authme.service.CommonService;
|
import fr.xephi.authme.service.CommonService;
|
||||||
import fr.xephi.authme.process.SyncProcessManager;
|
import fr.xephi.authme.process.SyncProcessManager;
|
||||||
|
import fr.xephi.authme.service.SessionService;
|
||||||
import fr.xephi.authme.settings.SpawnLoader;
|
import fr.xephi.authme.settings.SpawnLoader;
|
||||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
@ -48,6 +50,12 @@ public class AsynchronousQuit implements AsynchronousProcess {
|
|||||||
@Inject
|
@Inject
|
||||||
private VerificationCodeManager codeManager;
|
private VerificationCodeManager codeManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private SessionService sessionService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private BungeeService bungeeService;
|
||||||
|
|
||||||
AsynchronousQuit() {
|
AsynchronousQuit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +78,7 @@ public class AsynchronousQuit implements AsynchronousProcess {
|
|||||||
.name(name).location(loc)
|
.name(name).location(loc)
|
||||||
.realName(player.getName()).build();
|
.realName(player.getName()).build();
|
||||||
database.updateQuitLoc(auth);
|
database.updateQuitLoc(auth);
|
||||||
|
bungeeService.sendRefreshQuitLoc(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String ip = PlayerUtils.getPlayerIp(player);
|
final String ip = PlayerUtils.getPlayerIp(player);
|
||||||
@ -80,6 +89,7 @@ public class AsynchronousQuit implements AsynchronousProcess {
|
|||||||
.lastLogin(System.currentTimeMillis())
|
.lastLogin(System.currentTimeMillis())
|
||||||
.build();
|
.build();
|
||||||
database.updateSession(auth);
|
database.updateSession(auth);
|
||||||
|
bungeeService.sendRefreshSession(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//always unauthenticate the player - use session only for auto logins on the same ip
|
//always unauthenticate the player - use session only for auto logins on the same ip
|
||||||
@ -90,7 +100,7 @@ public class AsynchronousQuit implements AsynchronousProcess {
|
|||||||
if (wasLoggedIn) {
|
if (wasLoggedIn) {
|
||||||
database.setUnlogged(name);
|
database.setUnlogged(name);
|
||||||
if (!service.getProperty(PluginSettings.SESSIONS_ENABLED)) {
|
if (!service.getProperty(PluginSettings.SESSIONS_ENABLED)) {
|
||||||
database.revokeSession(name);
|
sessionService.revokeSession(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import fr.xephi.authme.process.AsynchronousProcess;
|
|||||||
import fr.xephi.authme.process.register.executors.RegistrationExecutor;
|
import fr.xephi.authme.process.register.executors.RegistrationExecutor;
|
||||||
import fr.xephi.authme.process.register.executors.RegistrationParameters;
|
import fr.xephi.authme.process.register.executors.RegistrationParameters;
|
||||||
import fr.xephi.authme.process.register.executors.RegistrationMethod;
|
import fr.xephi.authme.process.register.executors.RegistrationMethod;
|
||||||
|
import fr.xephi.authme.service.BungeeService;
|
||||||
import fr.xephi.authme.service.CommonService;
|
import fr.xephi.authme.service.CommonService;
|
||||||
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;
|
||||||
@ -36,6 +37,8 @@ public class AsyncRegister implements AsynchronousProcess {
|
|||||||
private PermissionsManager permissionsManager;
|
private PermissionsManager permissionsManager;
|
||||||
@Inject
|
@Inject
|
||||||
private SingletonStore<RegistrationExecutor> registrationExecutorFactory;
|
private SingletonStore<RegistrationExecutor> registrationExecutorFactory;
|
||||||
|
@Inject
|
||||||
|
private BungeeService bungeeService;
|
||||||
|
|
||||||
AsyncRegister() {
|
AsyncRegister() {
|
||||||
}
|
}
|
||||||
@ -84,6 +87,7 @@ public class AsyncRegister implements AsynchronousProcess {
|
|||||||
PlayerAuth auth = executor.buildPlayerAuth(parameters);
|
PlayerAuth auth = executor.buildPlayerAuth(parameters);
|
||||||
if (database.saveAuth(auth)) {
|
if (database.saveAuth(auth)) {
|
||||||
executor.executePostPersistAction(parameters);
|
executor.executePostPersistAction(parameters);
|
||||||
|
bungeeService.sendRegister(parameters.getPlayerName());
|
||||||
} else {
|
} else {
|
||||||
service.send(parameters.getPlayer(), MessageKey.ERROR);
|
service.send(parameters.getPlayer(), MessageKey.ERROR);
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,6 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send Bungee stuff. The service will check if it is enabled or not.
|
// Send Bungee stuff. The service will check if it is enabled or not.
|
||||||
bungeeService.connectPlayer(player);
|
bungeeService.connectPlayerOnLogin(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import fr.xephi.authme.message.MessageKey;
|
|||||||
import fr.xephi.authme.process.AsynchronousProcess;
|
import fr.xephi.authme.process.AsynchronousProcess;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.service.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
|
import fr.xephi.authme.service.BungeeService;
|
||||||
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.settings.commandconfig.CommandManager;
|
import fr.xephi.authme.settings.commandconfig.CommandManager;
|
||||||
@ -51,6 +52,9 @@ public class AsynchronousUnregister implements AsynchronousProcess {
|
|||||||
@Inject
|
@Inject
|
||||||
private CommandManager commandManager;
|
private CommandManager commandManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private BungeeService bungeeService;
|
||||||
|
|
||||||
AsynchronousUnregister() {
|
AsynchronousUnregister() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,6 +108,8 @@ public class AsynchronousUnregister implements AsynchronousProcess {
|
|||||||
|
|
||||||
private void performUnregister(String name, Player player) {
|
private void performUnregister(String name, Player player) {
|
||||||
playerCache.removePlayer(name);
|
playerCache.removePlayer(name);
|
||||||
|
bungeeService.sendUnregister(name);
|
||||||
|
|
||||||
if (player == null || !player.isOnline()) {
|
if (player == null || !player.isOnline()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -363,4 +363,8 @@ public class BukkitService implements SettingsDependent {
|
|||||||
public BanEntry banIp(String ip, String reason, Date expires, String source) {
|
public BanEntry banIp(String ip, String reason, Date expires, String source) {
|
||||||
return Bukkit.getServer().getBanList(BanList.Type.IP).addBan(ip, reason, expires, source);
|
return Bukkit.getServer().getBanList(BanList.Type.IP).addBan(ip, reason, expires, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendPluginMessage(String channel, byte[] data) {
|
||||||
|
Bukkit.getServer().sendPluginMessage(authMe, channel, data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,69 +1,185 @@
|
|||||||
package fr.xephi.authme.service;
|
package fr.xephi.authme.service;
|
||||||
|
|
||||||
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
import com.google.common.io.ByteArrayDataOutput;
|
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.datasource.CacheDataSource;
|
||||||
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.initialization.SettingsDependent;
|
import fr.xephi.authme.initialization.SettingsDependent;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.messaging.Messenger;
|
import org.bukkit.plugin.messaging.Messenger;
|
||||||
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to manage all BungeeCord related processes.
|
* Class to manage all BungeeCord related processes.
|
||||||
*/
|
*/
|
||||||
public class BungeeService implements SettingsDependent {
|
public class BungeeService implements SettingsDependent, PluginMessageListener {
|
||||||
|
|
||||||
private AuthMe plugin;
|
private AuthMe plugin;
|
||||||
private BukkitService service;
|
private BukkitService service;
|
||||||
|
|
||||||
private boolean isEnabled;
|
private boolean isEnabled;
|
||||||
private String bungeeServer;
|
private String destinationServerOnLogin;
|
||||||
|
|
||||||
|
private DataSource dataSource;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
BungeeService(AuthMe plugin, BukkitService service, Settings settings) {
|
BungeeService(AuthMe plugin, BukkitService service, Settings settings, DataSource dataSource) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.service = service;
|
this.service = service;
|
||||||
|
this.dataSource = dataSource;
|
||||||
reload(settings);
|
reload(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reload(Settings settings) {
|
||||||
|
this.isEnabled = settings.getProperty(HooksSettings.BUNGEECORD);
|
||||||
|
this.destinationServerOnLogin = settings.getProperty(HooksSettings.BUNGEECORD_SERVER);
|
||||||
|
Messenger messenger = plugin.getServer().getMessenger();
|
||||||
|
if (!this.isEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!messenger.isOutgoingChannelRegistered(plugin, "BungeeCord")) {
|
||||||
|
messenger.registerOutgoingPluginChannel(plugin, "BungeeCord");
|
||||||
|
}
|
||||||
|
if (!messenger.isIncomingChannelRegistered(plugin, "BungeeCord")) {
|
||||||
|
messenger.registerIncomingPluginChannel(plugin, "BungeeCord", this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendBungeecordMessage(String... data) {
|
||||||
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
|
for(String element : data) {
|
||||||
|
out.writeUTF(element);
|
||||||
|
}
|
||||||
|
service.sendPluginMessage("BungeeCord", out.toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a player to a specified server. If no server is configured, this will
|
* Send a player to a specified server. If no server is configured, this will
|
||||||
* do nothing.
|
* do nothing.
|
||||||
*
|
*
|
||||||
* @param player The player to send.
|
* @param player The player to send.
|
||||||
*/
|
*/
|
||||||
public void connectPlayer(Player player) {
|
public void connectPlayerOnLogin(Player player) {
|
||||||
if (!isEnabled || bungeeServer.isEmpty()) {
|
if (!isEnabled || destinationServerOnLogin.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
service.scheduleSyncDelayedTask(new Runnable() {
|
service.scheduleSyncDelayedTask(() ->
|
||||||
@Override
|
sendBungeecordMessage("Connect", player.getName(), destinationServerOnLogin), 20L);
|
||||||
public void run() {
|
}
|
||||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
|
||||||
out.writeUTF("Connect");
|
public class AuthMeBungeeMessageType {
|
||||||
out.writeUTF(bungeeServer);
|
public static final String LOGIN = "login";
|
||||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
public static final String LOGOUT = "logout";
|
||||||
}
|
public static final String REGISTER = "register";
|
||||||
}, 20L);
|
public static final String UNREGISTER = "unregister";
|
||||||
|
public static final String REFRESH_PASSWORD = "refresh.password";
|
||||||
|
public static final String REFRESH_SESSION = "refresh.session";
|
||||||
|
public static final String REFRESH_QUITLOC = "refresh.quitloc";
|
||||||
|
public static final String REFRESH_EMAIL = "refresh.email";
|
||||||
|
public static final String REFRESH = "refresh";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendAuthMeBungeecordMessage(String type, String... data) {
|
||||||
|
if(!isEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> dataList = Arrays.asList(data);
|
||||||
|
dataList.add(0, "AuthMe");
|
||||||
|
dataList.add(1, type);
|
||||||
|
sendBungeecordMessage(dataList.toArray(new String[dataList.size()]));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendLogin(String name) {
|
||||||
|
sendAuthMeBungeecordMessage(AuthMeBungeeMessageType.LOGIN, name.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendLogout(String name) {
|
||||||
|
sendAuthMeBungeecordMessage(AuthMeBungeeMessageType.LOGOUT, name.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendRegister(String name) {
|
||||||
|
sendAuthMeBungeecordMessage(AuthMeBungeeMessageType.REGISTER, name.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendUnregister(String name) {
|
||||||
|
sendAuthMeBungeecordMessage(AuthMeBungeeMessageType.UNREGISTER, name.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendRefreshPassword(String name) {
|
||||||
|
sendAuthMeBungeecordMessage(AuthMeBungeeMessageType.REFRESH_PASSWORD, name.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendRefreshSession(String name) {
|
||||||
|
sendAuthMeBungeecordMessage(AuthMeBungeeMessageType.REFRESH_SESSION, name.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendRefreshQuitLoc(String name) {
|
||||||
|
sendAuthMeBungeecordMessage(AuthMeBungeeMessageType.REFRESH_QUITLOC, name.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendRefreshEmail(String name) {
|
||||||
|
sendAuthMeBungeecordMessage(AuthMeBungeeMessageType.REFRESH_EMAIL, name.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload(Settings settings) {
|
public void onPluginMessageReceived(String channel, Player player, byte[] data) {
|
||||||
this.isEnabled = settings.getProperty(HooksSettings.BUNGEECORD);
|
if(!isEnabled) {
|
||||||
this.bungeeServer = settings.getProperty(HooksSettings.BUNGEECORD_SERVER);
|
|
||||||
Messenger messenger = plugin.getServer().getMessenger();
|
|
||||||
if (!this.isEnabled) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!messenger.isOutgoingChannelRegistered(plugin, "BungeeCord")) {
|
|
||||||
messenger.registerOutgoingPluginChannel(plugin, "BungeeCord");
|
ByteArrayDataInput in = ByteStreams.newDataInput(data);
|
||||||
|
String subchannel = in.readUTF();
|
||||||
|
if(!subchannel.equals("AuthMe")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String type = in.readUTF();
|
||||||
|
switch (type) {
|
||||||
|
case AuthMeBungeeMessageType.UNREGISTER:
|
||||||
|
handleRemove(in.readUTF());
|
||||||
|
break;
|
||||||
|
case AuthMeBungeeMessageType.REFRESH_PASSWORD:
|
||||||
|
case AuthMeBungeeMessageType.REFRESH_QUITLOC:
|
||||||
|
case AuthMeBungeeMessageType.REFRESH_EMAIL:
|
||||||
|
case AuthMeBungeeMessageType.REFRESH:
|
||||||
|
handleRefresh(in.readUTF());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleRefresh(String name) {
|
||||||
|
if(!(dataSource instanceof CacheDataSource)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CacheDataSource cacheDataSource = (CacheDataSource) dataSource;
|
||||||
|
|
||||||
|
if (cacheDataSource.getCachedAuths().getIfPresent(name) == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cacheDataSource.getCachedAuths().refresh(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleRemove(String name) {
|
||||||
|
if(!(dataSource instanceof CacheDataSource)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CacheDataSource cacheDataSource = (CacheDataSource) dataSource;
|
||||||
|
|
||||||
|
cacheDataSource.getCachedAuths().invalidate(name);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,10 @@ public class SessionService implements Reloadable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void revokeSession(String name) {
|
||||||
|
database.revokeSession(name);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload() {
|
public void reload() {
|
||||||
this.isEnabled = service.getProperty(PluginSettings.SESSIONS_ENABLED);
|
this.isEnabled = service.getProperty(PluginSettings.SESSIONS_ENABLED);
|
||||||
|
@ -3,6 +3,7 @@ package fr.xephi.authme.command.executable.authme;
|
|||||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.message.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
|
import fr.xephi.authme.service.BungeeService;
|
||||||
import fr.xephi.authme.service.CommonService;
|
import fr.xephi.authme.service.CommonService;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -35,6 +36,8 @@ public class PurgeLastPositionCommandTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private CommonService service;
|
private CommonService service;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private BungeeService bungeeService;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldPurgeLastPosOfUser() {
|
public void shouldPurgeLastPosOfUser() {
|
||||||
|
@ -6,6 +6,7 @@ import fr.xephi.authme.datasource.DataSource;
|
|||||||
import fr.xephi.authme.message.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
|
import fr.xephi.authme.service.BungeeService;
|
||||||
import fr.xephi.authme.service.CommonService;
|
import fr.xephi.authme.service.CommonService;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@ -37,6 +38,8 @@ public class AsyncChangePasswordTest {
|
|||||||
private PlayerCache playerCache;
|
private PlayerCache playerCache;
|
||||||
@Mock
|
@Mock
|
||||||
private PasswordSecurity passwordSecurity;
|
private PasswordSecurity passwordSecurity;
|
||||||
|
@Mock
|
||||||
|
private BungeeService bungeeService;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUpLogger() {
|
public void setUpLogger() {
|
||||||
|
@ -5,6 +5,7 @@ import fr.xephi.authme.data.auth.PlayerAuth;
|
|||||||
import fr.xephi.authme.data.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.message.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
|
import fr.xephi.authme.service.BungeeService;
|
||||||
import fr.xephi.authme.service.CommonService;
|
import fr.xephi.authme.service.CommonService;
|
||||||
import fr.xephi.authme.service.ValidationService;
|
import fr.xephi.authme.service.ValidationService;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -45,6 +46,9 @@ public class AsyncAddEmailTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private ValidationService validationService;
|
private ValidationService validationService;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private BungeeService bungeeService;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() {
|
public static void setUp() {
|
||||||
TestHelper.setupLogger();
|
TestHelper.setupLogger();
|
||||||
|
@ -4,6 +4,7 @@ import fr.xephi.authme.data.auth.PlayerAuth;
|
|||||||
import fr.xephi.authme.data.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.message.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
|
import fr.xephi.authme.service.BungeeService;
|
||||||
import fr.xephi.authme.service.CommonService;
|
import fr.xephi.authme.service.CommonService;
|
||||||
import fr.xephi.authme.service.ValidationService;
|
import fr.xephi.authme.service.ValidationService;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -44,6 +45,9 @@ public class AsyncChangeEmailTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private ValidationService validationService;
|
private ValidationService validationService;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private BungeeService bungeeService;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldChangeEmail() {
|
public void shouldChangeEmail() {
|
||||||
// given
|
// given
|
||||||
|
@ -10,6 +10,7 @@ import fr.xephi.authme.message.MessageKey;
|
|||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
import fr.xephi.authme.service.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
|
import fr.xephi.authme.service.BungeeService;
|
||||||
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.settings.commandconfig.CommandManager;
|
import fr.xephi.authme.settings.commandconfig.CommandManager;
|
||||||
@ -61,6 +62,8 @@ public class AsynchronousUnregisterTest {
|
|||||||
private TeleportationService teleportationService;
|
private TeleportationService teleportationService;
|
||||||
@Mock
|
@Mock
|
||||||
private CommandManager commandManager;
|
private CommandManager commandManager;
|
||||||
|
@Mock
|
||||||
|
private BungeeService bungeeService;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void initLogger() {
|
public static void initLogger() {
|
||||||
|
Loading…
Reference in New Issue
Block a user