This commit is contained in:
Gabriele C 2017-11-02 11:24:17 +01:00
parent 6505538240
commit 273c318e96
22 changed files with 105 additions and 118 deletions

View File

@ -4,8 +4,9 @@ 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.bungeecord.BungeeService;
import fr.xephi.authme.service.CommonService; import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.service.bungeecord.MessageType;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import javax.inject.Inject; import javax.inject.Inject;
@ -33,7 +34,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); bungeeService.sendAuthMeBungeecordMessage(MessageType.REFRESH_QUITLOC, playerName);
} }
sender.sendMessage("All players last position locations are now reset"); sender.sendMessage("All players last position locations are now reset");
} else { } else {
@ -46,7 +47,7 @@ public class PurgeLastPositionCommand implements ExecutableCommand {
resetLastPosition(auth); resetLastPosition(auth);
dataSource.updateQuitLoc(auth); dataSource.updateQuitLoc(auth);
bungeeService.sendRefreshQuitLoc(playerName); bungeeService.sendAuthMeBungeecordMessage(MessageType.REFRESH_QUITLOC, playerName);
sender.sendMessage(playerName + "'s last position location is now reset"); sender.sendMessage(playerName + "'s last position location is now reset");
} }
} }

View File

@ -262,4 +262,18 @@ public class CacheDataSource implements DataSource {
.map(PlayerAuth::getRealName) .map(PlayerAuth::getRealName)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@Override
public void invalidateCache(String playerName) {
cachedAuths.invalidate(playerName);
}
@Override
public void refreshCache(String playerName) {
if (cachedAuths.getIfPresent(playerName) == null) {
return;
}
cachedAuths.refresh(playerName);
}
} }

View File

@ -231,4 +231,20 @@ public interface DataSource extends Reloadable {
@Override @Override
void reload(); void reload();
/**
* Invalidate any cached data related to the specified player name.
*
* @param playerName the player name
*/
default void invalidateCache(String playerName) {
}
/**
* Refresh any cached data (if present) related to the specified player name.
*
* @param playerName the player name
*/
default void refreshCache(String playerName) {
}
} }

View File

@ -5,8 +5,9 @@ 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.bungeecord.BungeeService;
import fr.xephi.authme.service.ValidationService; import fr.xephi.authme.service.ValidationService;
import fr.xephi.authme.service.bungeecord.MessageType;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.SpawnLoader; import fr.xephi.authme.settings.SpawnLoader;
import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.settings.properties.RestrictionSettings;
@ -71,7 +72,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()); bungeeService.sendAuthMeBungeecordMessage(MessageType.REFRESH_QUITLOC, player.getName());
} }
} }
} }

View File

@ -8,7 +8,8 @@ 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.bungeecord.MessageType;
import fr.xephi.authme.service.bungeecord.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;
@ -424,7 +425,7 @@ public class PlayerListener implements Listener {
.location(spawn) .location(spawn)
.build(); .build();
dataSource.updateQuitLoc(auth); dataSource.updateQuitLoc(auth);
bungeeService.sendRefreshQuitLoc(name); bungeeService.sendAuthMeBungeecordMessage(MessageType.REFRESH_QUITLOC, name);
} }
if (spawn != null && spawn.getWorld() != null) { if (spawn != null && spawn.getWorld() != null) {
event.setRespawnLocation(spawn); event.setRespawnLocation(spawn);

View File

@ -6,10 +6,11 @@ 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.bungeecord.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;
import fr.xephi.authme.service.bungeecord.MessageType;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -53,7 +54,7 @@ public class AsyncChangePassword implements AsynchronousProcess {
commonService.send(player, MessageKey.ERROR); commonService.send(player, MessageKey.ERROR);
return; return;
} }
bungeeService.sendRefreshPassword(name); bungeeService.sendAuthMeBungeecordMessage(MessageType.REFRESH_PASSWORD, name);
playerCache.updatePlayer(auth); playerCache.updatePlayer(auth);
commonService.send(player, MessageKey.PASSWORD_CHANGED_SUCCESS); commonService.send(player, MessageKey.PASSWORD_CHANGED_SUCCESS);
@ -83,7 +84,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); bungeeService.sendAuthMeBungeecordMessage(MessageType.REFRESH_PASSWORD, 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);

View File

@ -6,9 +6,10 @@ 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.bungeecord.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.service.bungeecord.MessageType;
import fr.xephi.authme.util.Utils; import fr.xephi.authme.util.Utils;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -59,7 +60,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); bungeeService.sendAuthMeBungeecordMessage(MessageType.REFRESH_EMAIL, 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 + "'");

View File

@ -5,9 +5,10 @@ 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.bungeecord.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.service.bungeecord.MessageType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import javax.inject.Inject; import javax.inject.Inject;
@ -67,7 +68,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()); bungeeService.sendAuthMeBungeecordMessage(MessageType.REFRESH_EMAIL, 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);

View File

@ -19,9 +19,10 @@ 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.bungeecord.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.service.bungeecord.MessageType;
import fr.xephi.authme.settings.properties.DatabaseSettings; import fr.xephi.authme.settings.properties.DatabaseSettings;
import fr.xephi.authme.settings.properties.EmailSettings; import fr.xephi.authme.settings.properties.EmailSettings;
import fr.xephi.authme.settings.properties.HooksSettings; import fr.xephi.authme.settings.properties.HooksSettings;
@ -225,7 +226,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()); bungeeService.sendAuthMeBungeecordMessage(MessageType.REFRESH_SESSION, 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();
@ -251,7 +252,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); bungeeService.sendAuthMeBungeecordMessage(MessageType.LOGIN, 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

View File

@ -8,7 +8,7 @@ import fr.xephi.authme.events.LoginEvent;
import fr.xephi.authme.events.RestoreInventoryEvent; import fr.xephi.authme.events.RestoreInventoryEvent;
import fr.xephi.authme.process.SynchronousProcess; import fr.xephi.authme.process.SynchronousProcess;
import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.BungeeService; import fr.xephi.authme.service.bungeecord.BungeeService;
import fr.xephi.authme.service.CommonService; import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.service.JoinMessageService; import fr.xephi.authme.service.JoinMessageService;
import fr.xephi.authme.service.TeleportationService; import fr.xephi.authme.service.TeleportationService;

View File

@ -7,9 +7,10 @@ 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.bungeecord.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.service.bungeecord.MessageType;
import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.settings.properties.RestrictionSettings;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -58,18 +59,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); bungeeService.sendAuthMeBungeecordMessage(MessageType.REFRESH_SESSION, 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); bungeeService.sendAuthMeBungeecordMessage(MessageType.REFRESH_QUITLOC, name);
} }
playerCache.removePlayer(name); playerCache.removePlayer(name);
codeManager.unverify(name); codeManager.unverify(name);
database.setUnlogged(name); database.setUnlogged(name);
sessionService.revokeSession(name); sessionService.revokeSession(name);
bungeeService.sendLogout(name); bungeeService.sendAuthMeBungeecordMessage(MessageType.LOGOUT, name);
syncProcessManager.processSyncPlayerLogout(player); syncProcessManager.processSyncPlayerLogout(player);
} }
} }

View File

@ -7,10 +7,11 @@ 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.bungeecord.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.service.SessionService;
import fr.xephi.authme.service.bungeecord.MessageType;
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;
@ -78,7 +79,6 @@ 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);
@ -89,7 +89,7 @@ public class AsynchronousQuit implements AsynchronousProcess {
.lastLogin(System.currentTimeMillis()) .lastLogin(System.currentTimeMillis())
.build(); .build();
database.updateSession(auth); database.updateSession(auth);
bungeeService.sendRefreshSession(name); bungeeService.sendAuthMeBungeecordMessage(MessageType.REFRESH_QUITLOC, 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

View File

@ -10,8 +10,9 @@ 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.bungeecord.BungeeService;
import fr.xephi.authme.service.CommonService; import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.service.bungeecord.MessageType;
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;
import fr.xephi.authme.util.PlayerUtils; import fr.xephi.authme.util.PlayerUtils;
@ -87,7 +88,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()); bungeeService.sendAuthMeBungeecordMessage(MessageType.REGISTER, parameters.getPlayerName());
} else { } else {
service.send(parameters.getPlayer(), MessageKey.ERROR); service.send(parameters.getPlayer(), MessageKey.ERROR);
} }

View File

@ -4,7 +4,7 @@ import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.data.limbo.LimboService; import fr.xephi.authme.data.limbo.LimboService;
import fr.xephi.authme.message.MessageKey; import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.process.SynchronousProcess; import fr.xephi.authme.process.SynchronousProcess;
import fr.xephi.authme.service.BungeeService; import fr.xephi.authme.service.bungeecord.BungeeService;
import fr.xephi.authme.service.CommonService; import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.settings.commandconfig.CommandManager; import fr.xephi.authme.settings.commandconfig.CommandManager;
import fr.xephi.authme.settings.properties.EmailSettings; import fr.xephi.authme.settings.properties.EmailSettings;

View File

@ -11,9 +11,10 @@ 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.bungeecord.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.service.bungeecord.MessageType;
import fr.xephi.authme.settings.commandconfig.CommandManager; import fr.xephi.authme.settings.commandconfig.CommandManager;
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;
@ -108,7 +109,7 @@ 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); bungeeService.sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name);
if (player == null || !player.isOnline()) { if (player == null || !player.isOnline()) {
return; return;

View File

@ -1,4 +1,4 @@
package fr.xephi.authme.service; package fr.xephi.authme.service.bungeecord;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteArrayDataOutput;
@ -8,6 +8,7 @@ import fr.xephi.authme.ConsoleLogger;
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.initialization.SettingsDependent; import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.service.BukkitService;
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;
@ -15,8 +16,6 @@ import org.bukkit.plugin.messaging.Messenger;
import org.bukkit.plugin.messaging.PluginMessageListener; 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.
@ -81,47 +80,12 @@ public class BungeeService implements SettingsDependent, PluginMessageListener {
sendBungeecordMessage("Connect", player.getName(), destinationServerOnLogin), 20L); sendBungeecordMessage("Connect", player.getName(), destinationServerOnLogin), 20L);
} }
private void sendAuthMeBungeecordMessage(String type, String... data) { public void sendAuthMeBungeecordMessage(String type, String playerName) {
if(!isEnabled) { if(!isEnabled) {
return; return;
} }
List<String> dataList = Arrays.asList(data); sendBungeecordMessage("AuthMe", type, playerName.toLowerCase());
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
@ -137,55 +101,20 @@ public class BungeeService implements SettingsDependent, PluginMessageListener {
} }
String type = in.readUTF(); String type = in.readUTF();
String name = in.readUTF();
switch (type) { switch (type) {
case AuthMeBungeeMessageType.UNREGISTER: case MessageType.UNREGISTER:
handleRemove(in.readUTF()); dataSource.invalidateCache(name);
break; break;
case AuthMeBungeeMessageType.REFRESH_PASSWORD: case MessageType.REFRESH_PASSWORD:
case AuthMeBungeeMessageType.REFRESH_QUITLOC: case MessageType.REFRESH_QUITLOC:
case AuthMeBungeeMessageType.REFRESH_EMAIL: case MessageType.REFRESH_EMAIL:
case AuthMeBungeeMessageType.REFRESH: case MessageType.REFRESH:
handleRefresh(in.readUTF()); dataSource.refreshCache(name);
break; break;
default: default:
ConsoleLogger.debug("Received unsupported bungeecord message type! (" + type + ")"); ConsoleLogger.debug("Received unsupported bungeecord message type! (" + type + ")");
} }
} }
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);
}
public class AuthMeBungeeMessageType {
public static final String LOGIN = "login";
public static final String LOGOUT = "logout";
public static final String REGISTER = "register";
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 AuthMeBungeeMessageType() {
}
}
} }

View File

@ -0,0 +1,18 @@
package fr.xephi.authme.service.bungeecord;
public final class MessageType {
public static final String LOGIN = "login";
public static final String LOGOUT = "logout";
public static final String REGISTER = "register";
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 MessageType() {
}
}

View File

@ -3,7 +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.bungeecord.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;

View File

@ -6,7 +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.bungeecord.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;

View File

@ -5,7 +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.bungeecord.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;

View File

@ -4,7 +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.bungeecord.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;

View File

@ -10,7 +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.bungeecord.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;