mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-24 19:25:13 +01:00
Various code householding
- Adjust javadoc - Remove unused PlayerAuth constructor - Replace legacy Settings with NewSetting calls - Add process service to all (a)sync processes - Change IP manager to only cache the calls to the VeryGames API
This commit is contained in:
parent
9a412fac05
commit
31bac6964f
@ -52,6 +52,7 @@ 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;
|
||||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||||
|
import fr.xephi.authme.settings.properties.PurgeSettings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import fr.xephi.authme.util.CollectionUtils;
|
import fr.xephi.authme.util.CollectionUtils;
|
||||||
@ -301,7 +302,8 @@ public class AuthMe extends JavaPlugin {
|
|||||||
setupApi();
|
setupApi();
|
||||||
|
|
||||||
// Set up the management
|
// Set up the management
|
||||||
ProcessService processService = new ProcessService(newSettings, messages, this, ipAddressManager);
|
ProcessService processService = new ProcessService(newSettings, messages, this, ipAddressManager,
|
||||||
|
passwordSecurity);
|
||||||
management = new Management(this, processService, database, PlayerCache.getInstance());
|
management = new Management(this, processService, database, PlayerCache.getInstance());
|
||||||
|
|
||||||
// Set up the BungeeCord hook
|
// Set up the BungeeCord hook
|
||||||
@ -751,26 +753,26 @@ public class AuthMe extends JavaPlugin {
|
|||||||
|
|
||||||
// Purge inactive players from the database, as defined in the configuration
|
// Purge inactive players from the database, as defined in the configuration
|
||||||
private void autoPurge() {
|
private void autoPurge() {
|
||||||
if (!Settings.usePurge) {
|
if (!newSettings.getProperty(PurgeSettings.USE_AUTO_PURGE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.add(Calendar.DATE, -(Settings.purgeDelay));
|
calendar.add(Calendar.DATE, -newSettings.getProperty(PurgeSettings.DAYS_BEFORE_REMOVE_PLAYER));
|
||||||
long until = calendar.getTimeInMillis();
|
long until = calendar.getTimeInMillis();
|
||||||
List<String> cleared = database.autoPurgeDatabase(until);
|
List<String> cleared = database.autoPurgeDatabase(until);
|
||||||
if (CollectionUtils.isEmpty(cleared)) {
|
if (CollectionUtils.isEmpty(cleared)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ConsoleLogger.info("AutoPurging the Database: " + cleared.size() + " accounts removed!");
|
ConsoleLogger.info("AutoPurging the Database: " + cleared.size() + " accounts removed!");
|
||||||
if (Settings.purgeEssentialsFile && this.ess != null)
|
if (newSettings.getProperty(PurgeSettings.REMOVE_ESSENTIALS_FILES) && this.ess != null)
|
||||||
dataManager.purgeEssentials(cleared);
|
dataManager.purgeEssentials(cleared);
|
||||||
if (Settings.purgePlayerDat)
|
if (newSettings.getProperty(PurgeSettings.REMOVE_PLAYER_DAT))
|
||||||
dataManager.purgeDat(cleared);
|
dataManager.purgeDat(cleared);
|
||||||
if (Settings.purgeLimitedCreative)
|
if (newSettings.getProperty(PurgeSettings.REMOVE_LIMITED_CREATIVE_INVENTORIES))
|
||||||
dataManager.purgeLimitedCreative(cleared);
|
dataManager.purgeLimitedCreative(cleared);
|
||||||
if (Settings.purgeAntiXray)
|
if (newSettings.getProperty(PurgeSettings.REMOVE_ANTI_XRAY_FILE))
|
||||||
dataManager.purgeAntiXray(cleared);
|
dataManager.purgeAntiXray(cleared);
|
||||||
if (Settings.purgePermissions)
|
if (newSettings.getProperty(PurgeSettings.REMOVE_PERMISSIONS))
|
||||||
dataManager.purgePermissions(cleared);
|
dataManager.purgePermissions(cleared);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,10 +17,10 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
*/
|
*/
|
||||||
public class IpAddressManager {
|
public class IpAddressManager {
|
||||||
|
|
||||||
/** Cache for IP lookups per player. */
|
|
||||||
private final ConcurrentHashMap<String, String> ipCache;
|
|
||||||
/** Whether or not to use the VeryGames API for IP lookups. */
|
/** Whether or not to use the VeryGames API for IP lookups. */
|
||||||
private final boolean useVeryGamesIpCheck;
|
private final boolean useVeryGamesIpCheck;
|
||||||
|
/** Cache for lookups via the VeryGames API. */
|
||||||
|
private final ConcurrentHashMap<String, String> ipCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@ -32,7 +32,15 @@ public class IpAddressManager {
|
|||||||
this.ipCache = new ConcurrentHashMap<>();
|
this.ipCache = new ConcurrentHashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the player's IP address. If enabled in the settings, the IP address returned by the
|
||||||
|
* VeryGames API will be returned.
|
||||||
|
*
|
||||||
|
* @param player The player to look up
|
||||||
|
* @return The IP address of the player
|
||||||
|
*/
|
||||||
public String getPlayerIp(Player player) {
|
public String getPlayerIp(Player player) {
|
||||||
|
if (useVeryGamesIpCheck) {
|
||||||
final String playerName = player.getName().toLowerCase();
|
final String playerName = player.getName().toLowerCase();
|
||||||
final String cachedValue = ipCache.get(playerName);
|
final String cachedValue = ipCache.get(playerName);
|
||||||
if (cachedValue != null) {
|
if (cachedValue != null) {
|
||||||
@ -40,25 +48,37 @@ public class IpAddressManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final String plainIp = player.getAddress().getAddress().getHostAddress();
|
final String plainIp = player.getAddress().getAddress().getHostAddress();
|
||||||
if (useVeryGamesIpCheck) {
|
|
||||||
String veryGamesResult = getVeryGamesIp(plainIp, player.getAddress().getPort());
|
String veryGamesResult = getVeryGamesIp(plainIp, player.getAddress().getPort());
|
||||||
if (veryGamesResult != null) {
|
if (veryGamesResult != null) {
|
||||||
ipCache.put(playerName, veryGamesResult);
|
ipCache.put(playerName, veryGamesResult);
|
||||||
return veryGamesResult;
|
return veryGamesResult;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
ipCache.put(playerName, plainIp);
|
|
||||||
}
|
}
|
||||||
return plainIp;
|
return player.getAddress().getAddress().getHostAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a player to the IP address cache.
|
||||||
|
*
|
||||||
|
* @param player The player to add or update the cache entry for
|
||||||
|
* @param ip The IP address to add
|
||||||
|
*/
|
||||||
public void addCache(String player, String ip) {
|
public void addCache(String player, String ip) {
|
||||||
|
if (useVeryGamesIpCheck) {
|
||||||
ipCache.put(player.toLowerCase(), ip);
|
ipCache.put(player.toLowerCase(), ip);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a player's cache entry.
|
||||||
|
*
|
||||||
|
* @param player The player to remove
|
||||||
|
*/
|
||||||
public void removeCache(String player) {
|
public void removeCache(String player) {
|
||||||
|
if (useVeryGamesIpCheck) {
|
||||||
ipCache.remove(player.toLowerCase());
|
ipCache.remove(player.toLowerCase());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// returns null if IP could not be looked up
|
// returns null if IP could not be looked up
|
||||||
private String getVeryGamesIp(final String plainIp, final int port) {
|
private String getVeryGamesIp(final String plainIp, final int port) {
|
||||||
|
@ -30,18 +30,6 @@ public class PlayerAuth {
|
|||||||
this.deserialize(serialized);
|
this.deserialize(serialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for PlayerAuth.
|
|
||||||
*
|
|
||||||
* @param nickname String
|
|
||||||
* @param ip String
|
|
||||||
* @param lastLogin long
|
|
||||||
* @param realName String
|
|
||||||
*/
|
|
||||||
public PlayerAuth(String nickname, String ip, long lastLogin, String realName) {
|
|
||||||
this(nickname, new HashedPassword(""), -1, ip, lastLogin, 0, 0, 0, "world", "your@email.com", realName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for PlayerAuth.
|
* Constructor for PlayerAuth.
|
||||||
*
|
*
|
||||||
|
@ -41,6 +41,7 @@ public class CommandService {
|
|||||||
* @param passwordSecurity The Password Security instance
|
* @param passwordSecurity The Password Security instance
|
||||||
* @param permissionsManager The permissions manager
|
* @param permissionsManager The permissions manager
|
||||||
* @param settings The settings manager
|
* @param settings The settings manager
|
||||||
|
* @param ipAddressManager The IP address manager
|
||||||
*/
|
*/
|
||||||
public CommandService(AuthMe authMe, CommandMapper commandMapper, HelpProvider helpProvider, Messages messages,
|
public CommandService(AuthMe authMe, CommandMapper commandMapper, HelpProvider helpProvider, Messages messages,
|
||||||
PasswordSecurity passwordSecurity, PermissionsManager permissionsManager, NewSetting settings,
|
PasswordSecurity passwordSecurity, PermissionsManager permissionsManager, NewSetting settings,
|
||||||
|
@ -8,6 +8,9 @@ import java.util.List;
|
|||||||
|
|
||||||
public final class CommandUtils {
|
public final class CommandUtils {
|
||||||
|
|
||||||
|
private CommandUtils() {
|
||||||
|
}
|
||||||
|
|
||||||
public static int getMinNumberOfArguments(CommandDescription command) {
|
public static int getMinNumberOfArguments(CommandDescription command) {
|
||||||
int mandatoryArguments = 0;
|
int mandatoryArguments = 0;
|
||||||
for (CommandArgumentDescription argument : command.getArguments()) {
|
for (CommandArgumentDescription argument : command.getArguments()) {
|
||||||
|
@ -3,7 +3,7 @@ package fr.xephi.authme.command.executable.authme;
|
|||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.command.CommandService;
|
import fr.xephi.authme.command.CommandService;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.properties.PurgeSettings;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ public class PurgeBannedPlayersCommand implements ExecutableCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||||
// AuthMe plugin instance
|
// AuthMe plugin instance
|
||||||
final AuthMe plugin = AuthMe.getInstance();
|
final AuthMe plugin = commandService.getAuthMe();
|
||||||
|
|
||||||
// Get the list of banned players
|
// Get the list of banned players
|
||||||
List<String> bannedPlayers = new ArrayList<>();
|
List<String> bannedPlayers = new ArrayList<>();
|
||||||
@ -25,13 +25,13 @@ public class PurgeBannedPlayersCommand implements ExecutableCommand {
|
|||||||
|
|
||||||
// Purge the banned players
|
// Purge the banned players
|
||||||
plugin.getDataSource().purgeBanned(bannedPlayers);
|
plugin.getDataSource().purgeBanned(bannedPlayers);
|
||||||
if (Settings.purgeEssentialsFile && plugin.ess != null)
|
if (commandService.getProperty(PurgeSettings.REMOVE_ESSENTIALS_FILES) && plugin.ess != null)
|
||||||
plugin.dataManager.purgeEssentials(bannedPlayers);
|
plugin.dataManager.purgeEssentials(bannedPlayers);
|
||||||
if (Settings.purgePlayerDat)
|
if (commandService.getProperty(PurgeSettings.REMOVE_PLAYER_DAT))
|
||||||
plugin.dataManager.purgeDat(bannedPlayers);
|
plugin.dataManager.purgeDat(bannedPlayers);
|
||||||
if (Settings.purgeLimitedCreative)
|
if (commandService.getProperty(PurgeSettings.REMOVE_LIMITED_CREATIVE_INVENTORIES))
|
||||||
plugin.dataManager.purgeLimitedCreative(bannedPlayers);
|
plugin.dataManager.purgeLimitedCreative(bannedPlayers);
|
||||||
if (Settings.purgeAntiXray)
|
if (commandService.getProperty(PurgeSettings.REMOVE_ANTI_XRAY_FILE))
|
||||||
plugin.dataManager.purgeAntiXray(bannedPlayers);
|
plugin.dataManager.purgeAntiXray(bannedPlayers);
|
||||||
|
|
||||||
// Show a status message
|
// Show a status message
|
||||||
|
@ -3,7 +3,7 @@ package fr.xephi.authme.command.executable.authme;
|
|||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.command.CommandService;
|
import fr.xephi.authme.command.CommandService;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.properties.PurgeSettings;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ public class PurgeCommand implements ExecutableCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||||
// AuthMe plugin instance
|
// AuthMe plugin instance
|
||||||
AuthMe plugin = AuthMe.getInstance();
|
AuthMe plugin = commandService.getAuthMe();
|
||||||
|
|
||||||
// Get the days parameter
|
// Get the days parameter
|
||||||
String daysStr = arguments.get(0);
|
String daysStr = arguments.get(0);
|
||||||
@ -47,13 +47,13 @@ public class PurgeCommand implements ExecutableCommand {
|
|||||||
sender.sendMessage(ChatColor.GOLD + "Deleted " + purged.size() + " user accounts");
|
sender.sendMessage(ChatColor.GOLD + "Deleted " + purged.size() + " user accounts");
|
||||||
|
|
||||||
// Purge other data
|
// Purge other data
|
||||||
if (Settings.purgeEssentialsFile && plugin.ess != null)
|
if (commandService.getProperty(PurgeSettings.REMOVE_ESSENTIALS_FILES) && plugin.ess != null)
|
||||||
plugin.dataManager.purgeEssentials(purged);
|
plugin.dataManager.purgeEssentials(purged);
|
||||||
if (Settings.purgePlayerDat)
|
if (commandService.getProperty(PurgeSettings.REMOVE_PLAYER_DAT))
|
||||||
plugin.dataManager.purgeDat(purged);
|
plugin.dataManager.purgeDat(purged);
|
||||||
if (Settings.purgeLimitedCreative)
|
if (commandService.getProperty(PurgeSettings.REMOVE_LIMITED_CREATIVE_INVENTORIES))
|
||||||
plugin.dataManager.purgeLimitedCreative(purged);
|
plugin.dataManager.purgeLimitedCreative(purged);
|
||||||
if (Settings.purgeAntiXray)
|
if (commandService.getProperty(PurgeSettings.REMOVE_ANTI_XRAY_FILE))
|
||||||
plugin.dataManager.purgeAntiXray(purged);
|
plugin.dataManager.purgeAntiXray(purged);
|
||||||
|
|
||||||
// Show a status message
|
// Show a status message
|
||||||
|
@ -8,6 +8,7 @@ import fr.xephi.authme.command.CommandService;
|
|||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
import fr.xephi.authme.task.MessageTask;
|
import fr.xephi.authme.task.MessageTask;
|
||||||
import fr.xephi.authme.task.TimeoutTask;
|
import fr.xephi.authme.task.TimeoutTask;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
@ -66,7 +67,7 @@ public class UnregisterAdminCommand implements ExecutableCommand {
|
|||||||
plugin, new MessageTask(plugin, playerNameLowerCase, MessageKey.REGISTER_MESSAGE, interval)
|
plugin, new MessageTask(plugin, playerNameLowerCase, MessageKey.REGISTER_MESSAGE, interval)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if (Settings.applyBlindEffect) {
|
if (commandService.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
|
||||||
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeOut, 2));
|
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeOut, 2));
|
||||||
}
|
}
|
||||||
commandService.send(target, MessageKey.UNREGISTERED_SUCCESS);
|
commandService.send(target, MessageKey.UNREGISTERED_SUCCESS);
|
||||||
|
@ -3,15 +3,15 @@ package fr.xephi.authme.command.executable.authme;
|
|||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.command.CommandService;
|
import fr.xephi.authme.command.CommandService;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import static fr.xephi.authme.settings.properties.PluginSettings.HELP_HEADER;
|
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static fr.xephi.authme.settings.properties.PluginSettings.HELP_HEADER;
|
||||||
|
|
||||||
public class VersionCommand implements ExecutableCommand {
|
public class VersionCommand implements ExecutableCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -71,8 +71,6 @@ public class VersionCommand implements ExecutableCommand {
|
|||||||
* @return True if the player is online, false otherwise.
|
* @return True if the player is online, false otherwise.
|
||||||
*/
|
*/
|
||||||
private static boolean isPlayerOnline(String minecraftName) {
|
private static boolean isPlayerOnline(String minecraftName) {
|
||||||
// Note ljacqu 20151121: Generally you should use Utils#getOnlinePlayers to retrieve the list of online players.
|
|
||||||
// If it's only used in a for-each loop such as here, it's fine. For other purposes, go through the Utils class.
|
|
||||||
for (Player player : Utils.getOnlinePlayers()) {
|
for (Player player : Utils.getOnlinePlayers()) {
|
||||||
if (player.getName().equalsIgnoreCase(minecraftName)) {
|
if (player.getName().equalsIgnoreCase(minecraftName)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -7,6 +7,7 @@ import fr.xephi.authme.process.Management;
|
|||||||
import fr.xephi.authme.security.HashAlgorithm;
|
import fr.xephi.authme.security.HashAlgorithm;
|
||||||
import fr.xephi.authme.security.RandomString;
|
import fr.xephi.authme.security.RandomString;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -17,7 +18,7 @@ public class RegisterCommand extends PlayerCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
|
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
|
||||||
if (Settings.getPasswordHash == HashAlgorithm.TWO_FACTOR) {
|
if (commandService.getProperty(SecuritySettings.PASSWORD_HASH) == HashAlgorithm.TWO_FACTOR) {
|
||||||
//for two factor auth we don't need to check the usage
|
//for two factor auth we don't need to check the usage
|
||||||
commandService.getManagement().performRegister(player, "", "");
|
commandService.getManagement().performRegister(player, "", "");
|
||||||
return;
|
return;
|
||||||
|
@ -11,7 +11,6 @@ import fr.xephi.authme.process.logout.AsynchronousLogout;
|
|||||||
import fr.xephi.authme.process.quit.AsynchronousQuit;
|
import fr.xephi.authme.process.quit.AsynchronousQuit;
|
||||||
import fr.xephi.authme.process.register.AsyncRegister;
|
import fr.xephi.authme.process.register.AsyncRegister;
|
||||||
import fr.xephi.authme.process.unregister.AsynchronousUnregister;
|
import fr.xephi.authme.process.unregister.AsynchronousUnregister;
|
||||||
import fr.xephi.authme.settings.NewSetting;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
|
|
||||||
@ -24,22 +23,13 @@ public class Management {
|
|||||||
private final ProcessService processService;
|
private final ProcessService processService;
|
||||||
private final DataSource dataSource;
|
private final DataSource dataSource;
|
||||||
private final PlayerCache playerCache;
|
private final PlayerCache playerCache;
|
||||||
private final NewSetting settings;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for Management.
|
|
||||||
*
|
|
||||||
* @param plugin AuthMe
|
|
||||||
*/
|
|
||||||
public Management(AuthMe plugin, ProcessService processService, DataSource dataSource, PlayerCache playerCache) {
|
public Management(AuthMe plugin, ProcessService processService, DataSource dataSource, PlayerCache playerCache) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.sched = this.plugin.getServer().getScheduler();
|
this.sched = this.plugin.getServer().getScheduler();
|
||||||
this.processService = processService;
|
this.processService = processService;
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
this.playerCache = playerCache;
|
this.playerCache = playerCache;
|
||||||
|
|
||||||
// FIXME don't pass settings anymore -> go through the service in the processes
|
|
||||||
this.settings = processService.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void performLogin(final Player player, final String password, final boolean forceLogin) {
|
public void performLogin(final Player player, final String password, final boolean forceLogin) {
|
||||||
@ -47,13 +37,7 @@ public class Management {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void performLogout(final Player player) {
|
public void performLogout(final Player player) {
|
||||||
sched.runTaskAsynchronously(plugin, new Runnable() {
|
runTask(new AsynchronousLogout(player, plugin, dataSource, processService));
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
new AsynchronousLogout(player, plugin, plugin.getDataSource()).process();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void performRegister(final Player player, final String password, final String email) {
|
public void performRegister(final Player player, final String password, final String email) {
|
||||||
@ -77,7 +61,7 @@ public class Management {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void performChangeEmail(final Player player, final String oldEmail, final String newEmail) {
|
public void performChangeEmail(final Player player, final String oldEmail, final String newEmail) {
|
||||||
runTask(new AsyncChangeEmail(player, plugin, oldEmail, newEmail, dataSource, playerCache, settings));
|
runTask(new AsyncChangeEmail(player, oldEmail, newEmail, dataSource, playerCache, processService));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runTask(Process process) {
|
private void runTask(Process process) {
|
||||||
|
@ -4,6 +4,8 @@ import fr.xephi.authme.AuthMe;
|
|||||||
import fr.xephi.authme.cache.IpAddressManager;
|
import fr.xephi.authme.cache.IpAddressManager;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
import fr.xephi.authme.settings.NewSetting;
|
import fr.xephi.authme.settings.NewSetting;
|
||||||
import fr.xephi.authme.settings.domain.Property;
|
import fr.xephi.authme.settings.domain.Property;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -19,12 +21,15 @@ public class ProcessService {
|
|||||||
private final Messages messages;
|
private final Messages messages;
|
||||||
private final AuthMe authMe;
|
private final AuthMe authMe;
|
||||||
private final IpAddressManager ipAddressManager;
|
private final IpAddressManager ipAddressManager;
|
||||||
|
private final PasswordSecurity passwordSecurity;
|
||||||
|
|
||||||
public ProcessService(NewSetting settings, Messages messages, AuthMe authMe, IpAddressManager ipAddressManager) {
|
public ProcessService(NewSetting settings, Messages messages, AuthMe authMe, IpAddressManager ipAddressManager,
|
||||||
|
PasswordSecurity passwordSecurity) {
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.messages = messages;
|
this.messages = messages;
|
||||||
this.authMe = authMe;
|
this.authMe = authMe;
|
||||||
this.ipAddressManager = ipAddressManager;
|
this.ipAddressManager = ipAddressManager;
|
||||||
|
this.passwordSecurity = passwordSecurity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T getProperty(Property<T> property) {
|
public <T> T getProperty(Property<T> property) {
|
||||||
@ -75,4 +80,8 @@ public class ProcessService {
|
|||||||
return ipAddressManager;
|
return ipAddressManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HashedPassword computeHash(String password, String username) {
|
||||||
|
return passwordSecurity.computeHash(password, username);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package fr.xephi.authme.process.email;
|
package fr.xephi.authme.process.email;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
|
||||||
import fr.xephi.authme.process.Process;
|
import fr.xephi.authme.process.Process;
|
||||||
import fr.xephi.authme.settings.NewSetting;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -20,20 +18,18 @@ public class AsyncChangeEmail implements Process {
|
|||||||
private final Player player;
|
private final Player player;
|
||||||
private final String oldEmail;
|
private final String oldEmail;
|
||||||
private final String newEmail;
|
private final String newEmail;
|
||||||
private final Messages m;
|
private final ProcessService service;
|
||||||
private final NewSetting settings;
|
|
||||||
private final PlayerCache playerCache;
|
private final PlayerCache playerCache;
|
||||||
private final DataSource dataSource;
|
private final DataSource dataSource;
|
||||||
|
|
||||||
public AsyncChangeEmail(Player player, AuthMe plugin, String oldEmail, String newEmail, DataSource dataSource,
|
public AsyncChangeEmail(Player player, String oldEmail, String newEmail, DataSource dataSource,
|
||||||
PlayerCache playerCache, NewSetting settings) {
|
PlayerCache playerCache, ProcessService service) {
|
||||||
this.m = plugin.getMessages();
|
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.oldEmail = oldEmail;
|
this.oldEmail = oldEmail;
|
||||||
this.newEmail = newEmail;
|
this.newEmail = newEmail;
|
||||||
this.playerCache = playerCache;
|
this.playerCache = playerCache;
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
this.settings = settings;
|
this.service = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -44,13 +40,13 @@ public class AsyncChangeEmail implements Process {
|
|||||||
final String currentEmail = auth.getEmail();
|
final String currentEmail = auth.getEmail();
|
||||||
|
|
||||||
if (currentEmail == null) {
|
if (currentEmail == null) {
|
||||||
m.send(player, MessageKey.USAGE_ADD_EMAIL);
|
service.send(player, MessageKey.USAGE_ADD_EMAIL);
|
||||||
} else if (newEmail == null || !Utils.isEmailCorrect(newEmail, settings)) {
|
} else if (newEmail == null || !Utils.isEmailCorrect(newEmail, service.getSettings())) {
|
||||||
m.send(player, MessageKey.INVALID_NEW_EMAIL);
|
service.send(player, MessageKey.INVALID_NEW_EMAIL);
|
||||||
} else if (!oldEmail.equals(currentEmail)) {
|
} else if (!oldEmail.equals(currentEmail)) {
|
||||||
m.send(player, MessageKey.INVALID_OLD_EMAIL);
|
service.send(player, MessageKey.INVALID_OLD_EMAIL);
|
||||||
} else if (dataSource.isEmailStored(newEmail)) {
|
} else if (dataSource.isEmailStored(newEmail)) {
|
||||||
m.send(player, MessageKey.EMAIL_ALREADY_USED_ERROR);
|
service.send(player, MessageKey.EMAIL_ALREADY_USED_ERROR);
|
||||||
} else {
|
} else {
|
||||||
saveNewEmail(auth);
|
saveNewEmail(auth);
|
||||||
}
|
}
|
||||||
@ -63,20 +59,20 @@ public class AsyncChangeEmail implements Process {
|
|||||||
auth.setEmail(newEmail);
|
auth.setEmail(newEmail);
|
||||||
if (dataSource.updateEmail(auth)) {
|
if (dataSource.updateEmail(auth)) {
|
||||||
playerCache.updatePlayer(auth);
|
playerCache.updatePlayer(auth);
|
||||||
m.send(player, MessageKey.EMAIL_CHANGED_SUCCESS);
|
service.send(player, MessageKey.EMAIL_CHANGED_SUCCESS);
|
||||||
} else {
|
} else {
|
||||||
m.send(player, MessageKey.ERROR);
|
service.send(player, MessageKey.ERROR);
|
||||||
auth.setEmail(newEmail);
|
auth.setEmail(newEmail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void outputUnloggedMessage() {
|
private void outputUnloggedMessage() {
|
||||||
if (dataSource.isAuthAvailable(player.getName())) {
|
if (dataSource.isAuthAvailable(player.getName())) {
|
||||||
m.send(player, MessageKey.LOGIN_MESSAGE);
|
service.send(player, MessageKey.LOGIN_MESSAGE);
|
||||||
} else if (Settings.emailRegistration) {
|
} else if (service.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)) {
|
||||||
m.send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
|
service.send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
|
||||||
} else {
|
} else {
|
||||||
m.send(player, MessageKey.REGISTER_MESSAGE);
|
service.send(player, MessageKey.REGISTER_MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import fr.xephi.authme.process.Process;
|
|||||||
import fr.xephi.authme.process.ProcessService;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
import fr.xephi.authme.security.RandomString;
|
import fr.xephi.authme.security.RandomString;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import fr.xephi.authme.task.MessageTask;
|
import fr.xephi.authme.task.MessageTask;
|
||||||
@ -98,7 +99,7 @@ public class AsynchronousLogin implements Process {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Settings.getMySQLColumnGroup.isEmpty() && pAuth.getGroupId() == Settings.getNonActivatedGroup) {
|
if (!service.getProperty(DatabaseSettings.MYSQL_COL_GROUP).isEmpty() && pAuth.getGroupId() == Settings.getNonActivatedGroup) {
|
||||||
service.send(player, MessageKey.ACCOUNT_NOT_ACTIVATED);
|
service.send(player, MessageKey.ACCOUNT_NOT_ACTIVATED);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -146,7 +147,7 @@ public class AsynchronousLogin implements Process {
|
|||||||
.build();
|
.build();
|
||||||
database.updateSession(auth);
|
database.updateSession(auth);
|
||||||
|
|
||||||
if (Settings.useCaptcha) {
|
if (service.getProperty(SecuritySettings.USE_CAPTCHA)) {
|
||||||
if (plugin.captcha.containsKey(name)) {
|
if (plugin.captcha.containsKey(name)) {
|
||||||
plugin.captcha.remove(name);
|
plugin.captcha.remove(name);
|
||||||
}
|
}
|
||||||
|
@ -6,22 +6,22 @@ import fr.xephi.authme.cache.auth.PlayerCache;
|
|||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.process.Process;
|
||||||
|
import fr.xephi.authme.process.ProcessService;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
import fr.xephi.authme.util.Utils.GroupType;
|
import fr.xephi.authme.util.Utils.GroupType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class AsynchronousLogout {
|
public class AsynchronousLogout implements Process {
|
||||||
|
|
||||||
protected final Player player;
|
private final Player player;
|
||||||
protected final String name;
|
private final String name;
|
||||||
protected final AuthMe plugin;
|
private final AuthMe plugin;
|
||||||
protected final DataSource database;
|
private final DataSource database;
|
||||||
protected boolean canLogout = true;
|
private boolean canLogout = true;
|
||||||
private final Messages m;
|
private final ProcessService service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for AsynchronousLogout.
|
* Constructor for AsynchronousLogout.
|
||||||
@ -29,29 +29,30 @@ public class AsynchronousLogout {
|
|||||||
* @param player Player
|
* @param player Player
|
||||||
* @param plugin AuthMe
|
* @param plugin AuthMe
|
||||||
* @param database DataSource
|
* @param database DataSource
|
||||||
|
* @param service The process service
|
||||||
*/
|
*/
|
||||||
public AsynchronousLogout(Player player, AuthMe plugin, DataSource database) {
|
public AsynchronousLogout(Player player, AuthMe plugin, DataSource database, ProcessService service) {
|
||||||
this.m = plugin.getMessages();
|
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.database = database;
|
this.database = database;
|
||||||
this.name = player.getName().toLowerCase();
|
this.name = player.getName().toLowerCase();
|
||||||
|
this.service = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void preLogout() {
|
private void preLogout() {
|
||||||
if (!PlayerCache.getInstance().isAuthenticated(name)) {
|
if (!PlayerCache.getInstance().isAuthenticated(name)) {
|
||||||
m.send(player, MessageKey.NOT_LOGGED_IN);
|
service.send(player, MessageKey.NOT_LOGGED_IN);
|
||||||
canLogout = false;
|
canLogout = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void process() {
|
@Override
|
||||||
|
public void run() {
|
||||||
preLogout();
|
preLogout();
|
||||||
if (!canLogout) {
|
if (!canLogout) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Player p = player;
|
final Player p = player;
|
||||||
BukkitScheduler scheduler = p.getServer().getScheduler();
|
|
||||||
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
|
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
|
||||||
database.updateSession(auth);
|
database.updateSession(auth);
|
||||||
auth.setQuitLocX(p.getLocation().getX());
|
auth.setQuitLocX(p.getLocation().getX());
|
||||||
@ -62,7 +63,7 @@ public class AsynchronousLogout {
|
|||||||
|
|
||||||
PlayerCache.getInstance().removePlayer(name);
|
PlayerCache.getInstance().removePlayer(name);
|
||||||
database.setUnlogged(name);
|
database.setUnlogged(name);
|
||||||
scheduler.scheduleSyncDelayedTask(plugin, new Runnable() {
|
service.scheduleSyncDelayedTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Utils.teleportToSpawn(p);
|
Utils.teleportToSpawn(p);
|
||||||
@ -73,6 +74,6 @@ public class AsynchronousLogout {
|
|||||||
}
|
}
|
||||||
LimboCache.getInstance().addLimboPlayer(player);
|
LimboCache.getInstance().addLimboPlayer(player);
|
||||||
Utils.setGroup(player, GroupType.NOTLOGGEDIN);
|
Utils.setGroup(player, GroupType.NOTLOGGEDIN);
|
||||||
scheduler.scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerLogout(p, plugin));
|
service.scheduleSyncDelayedTask(new ProcessSynchronousPlayerLogout(p, plugin, service));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,37 +7,40 @@ import fr.xephi.authme.ConsoleLogger;
|
|||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
import fr.xephi.authme.events.LogoutEvent;
|
import fr.xephi.authme.events.LogoutEvent;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.process.Process;
|
||||||
|
import fr.xephi.authme.process.ProcessService;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import fr.xephi.authme.task.MessageTask;
|
import fr.xephi.authme.task.MessageTask;
|
||||||
import fr.xephi.authme.task.TimeoutTask;
|
import fr.xephi.authme.task.TimeoutTask;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class ProcessSyncronousPlayerLogout implements Runnable {
|
public class ProcessSynchronousPlayerLogout implements Process {
|
||||||
|
|
||||||
protected final Player player;
|
private final Player player;
|
||||||
protected final AuthMe plugin;
|
private final AuthMe plugin;
|
||||||
protected final String name;
|
private final String name;
|
||||||
private final Messages m;
|
private final ProcessService service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for ProcessSyncronousPlayerLogout.
|
* Constructor for ProcessSynchronousPlayerLogout.
|
||||||
*
|
*
|
||||||
* @param player Player
|
* @param player Player
|
||||||
* @param plugin AuthMe
|
* @param plugin AuthMe
|
||||||
|
* @param service The process service
|
||||||
*/
|
*/
|
||||||
public ProcessSyncronousPlayerLogout(Player player, AuthMe plugin) {
|
public ProcessSynchronousPlayerLogout(Player player, AuthMe plugin, ProcessService service) {
|
||||||
this.m = plugin.getMessages();
|
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.name = player.getName().toLowerCase();
|
this.name = player.getName().toLowerCase();
|
||||||
|
this.service = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void sendBungeeMessage() {
|
protected void sendBungeeMessage() {
|
||||||
@ -56,11 +59,6 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method run.
|
|
||||||
*
|
|
||||||
* @see java.lang.Runnable#run()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (plugin.sessions.containsKey(name)) {
|
if (plugin.sessions.containsKey(name)) {
|
||||||
@ -70,19 +68,18 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
|
|||||||
if (Settings.protectInventoryBeforeLogInEnabled) {
|
if (Settings.protectInventoryBeforeLogInEnabled) {
|
||||||
plugin.inventoryProtector.sendBlankInventoryPacket(player);
|
plugin.inventoryProtector.sendBlankInventoryPacket(player);
|
||||||
}
|
}
|
||||||
int timeOut = Settings.getRegistrationTimeout * 20;
|
int timeOut = service.getProperty(RestrictionSettings.TIMEOUT) * 20;
|
||||||
int interval = Settings.getWarnMessageInterval;
|
int interval = service.getProperty(RegistrationSettings.MESSAGE_INTERVAL);
|
||||||
BukkitScheduler sched = player.getServer().getScheduler();
|
|
||||||
if (timeOut != 0) {
|
if (timeOut != 0) {
|
||||||
BukkitTask id = sched.runTaskLater(plugin, new TimeoutTask(plugin, name, player), timeOut);
|
BukkitTask id = service.runTaskLater(new TimeoutTask(plugin, name, player), timeOut);
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||||
}
|
}
|
||||||
BukkitTask msgT = sched.runTask(plugin, new MessageTask(plugin, name, MessageKey.LOGIN_MESSAGE, interval));
|
BukkitTask msgT = service.runTask(new MessageTask(plugin, name, MessageKey.LOGIN_MESSAGE, interval));
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||||
if (player.isInsideVehicle() && player.getVehicle() != null) {
|
if (player.isInsideVehicle() && player.getVehicle() != null) {
|
||||||
player.getVehicle().eject();
|
player.getVehicle().eject();
|
||||||
}
|
}
|
||||||
if (Settings.applyBlindEffect) {
|
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeOut, 2));
|
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeOut, 2));
|
||||||
}
|
}
|
||||||
player.setOp(false);
|
player.setOp(false);
|
||||||
@ -92,7 +89,7 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
|
|||||||
if (Settings.bungee) {
|
if (Settings.bungee) {
|
||||||
sendBungeeMessage();
|
sendBungeeMessage();
|
||||||
}
|
}
|
||||||
m.send(player, MessageKey.LOGOUT_SUCCESS);
|
service.send(player, MessageKey.LOGOUT_SUCCESS);
|
||||||
ConsoleLogger.info(player.getName() + " logged out");
|
ConsoleLogger.info(player.getName() + " logged out");
|
||||||
}
|
}
|
||||||
|
|
@ -13,7 +13,6 @@ import fr.xephi.authme.settings.Settings;
|
|||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
@ -54,7 +53,12 @@ public class AsynchronousQuit implements Process {
|
|||||||
.realName(player.getName()).build();
|
.realName(player.getName()).build();
|
||||||
database.updateQuitLoc(auth);
|
database.updateQuitLoc(auth);
|
||||||
}
|
}
|
||||||
PlayerAuth auth = new PlayerAuth(name, ip, System.currentTimeMillis(), player.getName());
|
PlayerAuth auth = PlayerAuth.builder()
|
||||||
|
.name(name)
|
||||||
|
.realName(player.getName())
|
||||||
|
.ip(ip)
|
||||||
|
.lastLogin(System.currentTimeMillis())
|
||||||
|
.build();
|
||||||
database.updateSession(auth);
|
database.updateSession(auth);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +96,7 @@ public class AsynchronousQuit implements Process {
|
|||||||
|
|
||||||
service.getIpAddressManager().removeCache(player.getName());
|
service.getIpAddressManager().removeCache(player.getName());
|
||||||
if (plugin.isEnabled()) {
|
if (plugin.isEnabled()) {
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, player, isOp, needToChange));
|
service.scheduleSyncDelayedTask(new ProcessSyncronousPlayerQuit(plugin, player, isOp, needToChange));
|
||||||
}
|
}
|
||||||
// remove player from cache
|
// remove player from cache
|
||||||
if (database instanceof CacheDataSource) {
|
if (database instanceof CacheDataSource) {
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
package fr.xephi.authme.process.register;
|
package fr.xephi.authme.process.register;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
@ -22,6 +17,8 @@ import fr.xephi.authme.util.StringUtils;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class AsyncRegister implements Process {
|
public class AsyncRegister implements Process {
|
||||||
@ -82,10 +79,11 @@ public class AsyncRegister implements Process {
|
|||||||
&& !ip.equalsIgnoreCase("127.0.0.1")
|
&& !ip.equalsIgnoreCase("127.0.0.1")
|
||||||
&& !ip.equalsIgnoreCase("localhost")
|
&& !ip.equalsIgnoreCase("localhost")
|
||||||
&& !plugin.getPermissionsManager().hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS)) {
|
&& !plugin.getPermissionsManager().hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS)) {
|
||||||
Integer maxReg = Settings.getmaxRegPerIp;
|
int maxReg = Settings.getmaxRegPerIp;
|
||||||
List<String> otherAccounts = database.getAllAuthsByIp(ip);
|
List<String> otherAccounts = database.getAllAuthsByIp(ip);
|
||||||
if (otherAccounts.size() >= maxReg) {
|
if (otherAccounts.size() >= maxReg) {
|
||||||
m.send(player, MessageKey.MAX_REGISTER_EXCEEDED, maxReg.toString(), Integer.toString(otherAccounts.size()), otherAccounts.toString());
|
service.send(player, MessageKey.MAX_REGISTER_EXCEEDED, Integer.toString(maxReg),
|
||||||
|
Integer.toString(otherAccounts.size()), StringUtils.join(", ", otherAccounts.toString()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,14 +106,15 @@ public class AsyncRegister implements Process {
|
|||||||
&& !ip.equalsIgnoreCase("127.0.0.1")
|
&& !ip.equalsIgnoreCase("127.0.0.1")
|
||||||
&& !ip.equalsIgnoreCase("localhost")
|
&& !ip.equalsIgnoreCase("localhost")
|
||||||
&& !plugin.getPermissionsManager().hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS)) {
|
&& !plugin.getPermissionsManager().hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS)) {
|
||||||
Integer maxReg = Settings.getmaxRegPerIp;
|
int maxReg = Settings.getmaxRegPerIp;
|
||||||
List<String> otherAccounts = database.getAllAuthsByIp(ip);
|
List<String> otherAccounts = database.getAllAuthsByIp(ip);
|
||||||
if (otherAccounts.size() >= maxReg) {
|
if (otherAccounts.size() >= maxReg) {
|
||||||
m.send(player, MessageKey.MAX_REGISTER_EXCEEDED, maxReg.toString(), Integer.toString(otherAccounts.size()), otherAccounts.toString());
|
service.send(player, MessageKey.MAX_REGISTER_EXCEEDED, Integer.toString(maxReg),
|
||||||
|
Integer.toString(otherAccounts.size()), StringUtils.join(", ", otherAccounts.toString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final HashedPassword hashedPassword = plugin.getPasswordSecurity().computeHash(password, name);
|
final HashedPassword hashedPassword = service.computeHash(password, name);
|
||||||
PlayerAuth auth = PlayerAuth.builder()
|
PlayerAuth auth = PlayerAuth.builder()
|
||||||
.name(name)
|
.name(name)
|
||||||
.realName(player.getName())
|
.realName(player.getName())
|
||||||
@ -133,12 +132,12 @@ public class AsyncRegister implements Process {
|
|||||||
database.updateSession(auth);
|
database.updateSession(auth);
|
||||||
plugin.mail.main(auth, password);
|
plugin.mail.main(auth, password);
|
||||||
ProcessSyncEmailRegister sync = new ProcessSyncEmailRegister(player, service);
|
ProcessSyncEmailRegister sync = new ProcessSyncEmailRegister(player, service);
|
||||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, sync);
|
service.scheduleSyncDelayedTask(sync);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void passwordRegister() {
|
private void passwordRegister() {
|
||||||
final HashedPassword hashedPassword = plugin.getPasswordSecurity().computeHash(password, name);
|
final HashedPassword hashedPassword = service.computeHash(password, name);
|
||||||
PlayerAuth auth = PlayerAuth.builder()
|
PlayerAuth auth = PlayerAuth.builder()
|
||||||
.name(name)
|
.name(name)
|
||||||
.realName(player.getName())
|
.realName(player.getName())
|
||||||
@ -163,7 +162,7 @@ public class AsyncRegister implements Process {
|
|||||||
service.scheduleSyncDelayedTask(sync);
|
service.scheduleSyncDelayedTask(sync);
|
||||||
|
|
||||||
//give the user the secret code to setup their app code generation
|
//give the user the secret code to setup their app code generation
|
||||||
if (Settings.getPasswordHash == HashAlgorithm.TWO_FACTOR) {
|
if (service.getProperty(SecuritySettings.PASSWORD_HASH) == HashAlgorithm.TWO_FACTOR) {
|
||||||
String qrCodeUrl = TwoFactor.getQRBarcodeURL(player.getName(), Bukkit.getIp(), hashedPassword.getHash());
|
String qrCodeUrl = TwoFactor.getQRBarcodeURL(player.getName(), Bukkit.getIp(), hashedPassword.getHash());
|
||||||
service.send(player, MessageKey.TWO_FACTOR_CREATE, hashedPassword.getHash(), qrCodeUrl);
|
service.send(player, MessageKey.TWO_FACTOR_CREATE, hashedPassword.getHash(), qrCodeUrl);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import fr.xephi.authme.ConsoleLogger;
|
|||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
|
import fr.xephi.authme.process.Process;
|
||||||
import fr.xephi.authme.process.ProcessService;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
@ -17,10 +18,10 @@ import org.bukkit.scheduler.BukkitTask;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class ProcessSyncEmailRegister implements Runnable {
|
public class ProcessSyncEmailRegister implements Process {
|
||||||
|
|
||||||
protected final Player player;
|
private final Player player;
|
||||||
protected final String name;
|
private final String name;
|
||||||
private final ProcessService service;
|
private final ProcessService service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package fr.xephi.authme.settings;
|
package fr.xephi.authme.settings;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.datasource.DataSourceType;
|
|
||||||
import fr.xephi.authme.security.HashAlgorithm;
|
import fr.xephi.authme.security.HashAlgorithm;
|
||||||
import fr.xephi.authme.settings.domain.Property;
|
import fr.xephi.authme.settings.domain.Property;
|
||||||
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
|
||||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
@ -41,13 +39,9 @@ public final class Settings {
|
|||||||
public static List<String> forceRegisterCommands;
|
public static List<String> forceRegisterCommands;
|
||||||
public static List<String> forceRegisterCommandsAsConsole;
|
public static List<String> forceRegisterCommandsAsConsole;
|
||||||
public static List<String> unsafePasswords;
|
public static List<String> unsafePasswords;
|
||||||
public static List<String> emailBlacklist;
|
|
||||||
public static List<String> emailWhitelist;
|
|
||||||
public static DataSourceType getDataSource;
|
|
||||||
public static HashAlgorithm getPasswordHash;
|
public static HashAlgorithm getPasswordHash;
|
||||||
public static Pattern nickPattern;
|
public static Pattern nickPattern;
|
||||||
public static boolean useLogging = false;
|
public static boolean useLogging = false;
|
||||||
public static int purgeDelay = 60;
|
|
||||||
public static boolean isChatAllowed, isPermissionCheckEnabled, isRegistrationEnabled,
|
public static boolean isChatAllowed, isPermissionCheckEnabled, isRegistrationEnabled,
|
||||||
isForcedRegistrationEnabled, isTeleportToSpawnEnabled,
|
isForcedRegistrationEnabled, isTeleportToSpawnEnabled,
|
||||||
isSessionsEnabled, isAllowRestrictedIp,
|
isSessionsEnabled, isAllowRestrictedIp,
|
||||||
@ -57,19 +51,17 @@ public final class Settings {
|
|||||||
isKickOnWrongPasswordEnabled, enablePasswordConfirmation,
|
isKickOnWrongPasswordEnabled, enablePasswordConfirmation,
|
||||||
protectInventoryBeforeLogInEnabled, isStopEnabled, reloadSupport,
|
protectInventoryBeforeLogInEnabled, isStopEnabled, reloadSupport,
|
||||||
rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts,
|
rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts,
|
||||||
useCaptcha, emailRegistration, multiverse, bungee,
|
emailRegistration, multiverse, bungee,
|
||||||
banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange,
|
banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange,
|
||||||
disableSocialSpy, useEssentialsMotd, usePurge,
|
disableSocialSpy, useEssentialsMotd,
|
||||||
purgePlayerDat, purgeEssentialsFile,
|
|
||||||
purgeLimitedCreative, purgeAntiXray, purgePermissions,
|
|
||||||
enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
|
enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
|
||||||
broadcastWelcomeMessage, forceRegKick, forceRegLogin,
|
broadcastWelcomeMessage, forceRegKick, forceRegLogin,
|
||||||
checkVeryGames, removeJoinMessage, removeLeaveMessage, delayJoinMessage,
|
checkVeryGames, removeJoinMessage, removeLeaveMessage, delayJoinMessage,
|
||||||
noTeleport, applyBlindEffect, hideTablistBeforeLogin, denyTabcompleteBeforeLogin,
|
noTeleport, hideTablistBeforeLogin, denyTabcompleteBeforeLogin,
|
||||||
kickPlayersBeforeStopping, allowAllCommandsIfRegIsOptional,
|
kickPlayersBeforeStopping, allowAllCommandsIfRegIsOptional,
|
||||||
customAttributes, generateImage, isRemoveSpeedEnabled, preventOtherCase;
|
customAttributes, isRemoveSpeedEnabled, preventOtherCase;
|
||||||
public static String getNickRegex, getUnloggedinGroup,
|
public static String getNickRegex, getUnloggedinGroup,
|
||||||
getMySQLColumnGroup, unRegisteredGroup,
|
unRegisteredGroup,
|
||||||
backupWindowsPath, getRegisteredGroup,
|
backupWindowsPath, getRegisteredGroup,
|
||||||
rakamakUsers, rakamakUsersIp, getmailAccount, defaultWorld,
|
rakamakUsers, rakamakUsersIp, getmailAccount, defaultWorld,
|
||||||
spawnPriority, crazyloginFileName, getPassRegex, sendPlayerTo;
|
spawnPriority, crazyloginFileName, getPassRegex, sendPlayerTo;
|
||||||
@ -79,7 +71,7 @@ public final class Settings {
|
|||||||
getNonActivatedGroup, passwordMaxLength, getRecoveryPassLength,
|
getNonActivatedGroup, passwordMaxLength, getRecoveryPassLength,
|
||||||
getMailPort, maxLoginTry, captchaLength, saltLength,
|
getMailPort, maxLoginTry, captchaLength, saltLength,
|
||||||
getmaxRegPerEmail, bCryptLog2Rounds,
|
getmaxRegPerEmail, bCryptLog2Rounds,
|
||||||
antiBotSensibility, antiBotDuration, delayRecall, getMaxLoginPerIp,
|
antiBotSensibility, antiBotDuration, getMaxLoginPerIp,
|
||||||
getMaxJoinPerIp;
|
getMaxJoinPerIp;
|
||||||
protected static FileConfiguration configFile;
|
protected static FileConfiguration configFile;
|
||||||
|
|
||||||
@ -123,8 +115,6 @@ public final class Settings {
|
|||||||
getmaxRegPerIp = configFile.getInt("settings.restrictions.maxRegPerIp", 1);
|
getmaxRegPerIp = configFile.getInt("settings.restrictions.maxRegPerIp", 1);
|
||||||
getPasswordHash = load(SecuritySettings.PASSWORD_HASH);
|
getPasswordHash = load(SecuritySettings.PASSWORD_HASH);
|
||||||
getUnloggedinGroup = load(SecuritySettings.UNLOGGEDIN_GROUP);
|
getUnloggedinGroup = load(SecuritySettings.UNLOGGEDIN_GROUP);
|
||||||
getDataSource = load(DatabaseSettings.BACKEND);
|
|
||||||
getMySQLColumnGroup = configFile.getString("ExternalBoardOptions.mySQLColumnGroup", "");
|
|
||||||
getNonActivatedGroup = configFile.getInt("ExternalBoardOptions.nonActivedUserGroup", -1);
|
getNonActivatedGroup = configFile.getInt("ExternalBoardOptions.nonActivedUserGroup", -1);
|
||||||
unRegisteredGroup = configFile.getString("GroupOptions.UnregisteredPlayerGroup", "");
|
unRegisteredGroup = configFile.getString("GroupOptions.UnregisteredPlayerGroup", "");
|
||||||
|
|
||||||
@ -164,7 +154,6 @@ public final class Settings {
|
|||||||
getMailPort = configFile.getInt("Email.mailPort", 465);
|
getMailPort = configFile.getInt("Email.mailPort", 465);
|
||||||
getRecoveryPassLength = configFile.getInt("Email.RecoveryPasswordLength", 8);
|
getRecoveryPassLength = configFile.getInt("Email.RecoveryPasswordLength", 8);
|
||||||
displayOtherAccounts = configFile.getBoolean("settings.restrictions.displayOtherAccounts", true);
|
displayOtherAccounts = configFile.getBoolean("settings.restrictions.displayOtherAccounts", true);
|
||||||
useCaptcha = configFile.getBoolean("Security.captcha.useCaptcha", false);
|
|
||||||
maxLoginTry = configFile.getInt("Security.captcha.maxLoginTry", 5);
|
maxLoginTry = configFile.getInt("Security.captcha.maxLoginTry", 5);
|
||||||
captchaLength = configFile.getInt("Security.captcha.captchaLength", 5);
|
captchaLength = configFile.getInt("Security.captcha.captchaLength", 5);
|
||||||
emailRegistration = load(RegistrationSettings.USE_EMAIL_REGISTRATION);
|
emailRegistration = load(RegistrationSettings.USE_EMAIL_REGISTRATION);
|
||||||
@ -180,14 +169,7 @@ public final class Settings {
|
|||||||
disableSocialSpy = configFile.getBoolean("Hooks.disableSocialSpy", true);
|
disableSocialSpy = configFile.getBoolean("Hooks.disableSocialSpy", true);
|
||||||
bCryptLog2Rounds = configFile.getInt("ExternalBoardOptions.bCryptLog2Round", 10);
|
bCryptLog2Rounds = configFile.getInt("ExternalBoardOptions.bCryptLog2Round", 10);
|
||||||
useEssentialsMotd = configFile.getBoolean("Hooks.useEssentialsMotd", false);
|
useEssentialsMotd = configFile.getBoolean("Hooks.useEssentialsMotd", false);
|
||||||
usePurge = configFile.getBoolean("Purge.useAutoPurge", false);
|
|
||||||
purgeDelay = configFile.getInt("Purge.daysBeforeRemovePlayer", 60);
|
|
||||||
purgePlayerDat = configFile.getBoolean("Purge.removePlayerDat", false);
|
|
||||||
purgeEssentialsFile = configFile.getBoolean("Purge.removeEssentialsFile", false);
|
|
||||||
defaultWorld = configFile.getString("Purge.defaultWorld", "world");
|
defaultWorld = configFile.getString("Purge.defaultWorld", "world");
|
||||||
purgeLimitedCreative = configFile.getBoolean("Purge.removeLimitedCreativesInventories", false);
|
|
||||||
purgeAntiXray = configFile.getBoolean("Purge.removeAntiXRayFile", false);
|
|
||||||
purgePermissions = configFile.getBoolean("Purge.removePermissions", false);
|
|
||||||
enableProtection = configFile.getBoolean("Protection.enableProtection", false);
|
enableProtection = configFile.getBoolean("Protection.enableProtection", false);
|
||||||
countries = configFile.getStringList("Protection.countries");
|
countries = configFile.getStringList("Protection.countries");
|
||||||
enableAntiBot = configFile.getBoolean("Protection.enableAntiBot", false);
|
enableAntiBot = configFile.getBoolean("Protection.enableAntiBot", false);
|
||||||
@ -196,7 +178,6 @@ public final class Settings {
|
|||||||
forceCommands = configFile.getStringList("settings.forceCommands");
|
forceCommands = configFile.getStringList("settings.forceCommands");
|
||||||
forceCommandsAsConsole = configFile.getStringList("settings.forceCommandsAsConsole");
|
forceCommandsAsConsole = configFile.getStringList("settings.forceCommandsAsConsole");
|
||||||
recallEmail = configFile.getBoolean("Email.recallPlayers", false);
|
recallEmail = configFile.getBoolean("Email.recallPlayers", false);
|
||||||
delayRecall = configFile.getInt("Email.delayRecall", 5);
|
|
||||||
useWelcomeMessage = load(RegistrationSettings.USE_WELCOME_MESSAGE);
|
useWelcomeMessage = load(RegistrationSettings.USE_WELCOME_MESSAGE);
|
||||||
unsafePasswords = configFile.getStringList("settings.security.unsafePasswords");
|
unsafePasswords = configFile.getStringList("settings.security.unsafePasswords");
|
||||||
countriesBlacklist = configFile.getStringList("Protection.countriesBlacklist");
|
countriesBlacklist = configFile.getStringList("Protection.countriesBlacklist");
|
||||||
@ -213,13 +194,9 @@ public final class Settings {
|
|||||||
noTeleport = load(RestrictionSettings.NO_TELEPORT);
|
noTeleport = load(RestrictionSettings.NO_TELEPORT);
|
||||||
crazyloginFileName = configFile.getString("Converter.CrazyLogin.fileName", "accounts.db");
|
crazyloginFileName = configFile.getString("Converter.CrazyLogin.fileName", "accounts.db");
|
||||||
getPassRegex = configFile.getString("settings.restrictions.allowedPasswordCharacters", "[\\x21-\\x7E]*");
|
getPassRegex = configFile.getString("settings.restrictions.allowedPasswordCharacters", "[\\x21-\\x7E]*");
|
||||||
applyBlindEffect = configFile.getBoolean("settings.applyBlindEffect", false);
|
|
||||||
emailBlacklist = configFile.getStringList("Email.emailBlacklisted");
|
|
||||||
emailWhitelist = configFile.getStringList("Email.emailWhitelisted");
|
|
||||||
forceRegisterCommands = configFile.getStringList("settings.forceRegisterCommands");
|
forceRegisterCommands = configFile.getStringList("settings.forceRegisterCommands");
|
||||||
forceRegisterCommandsAsConsole = configFile.getStringList("settings.forceRegisterCommandsAsConsole");
|
forceRegisterCommandsAsConsole = configFile.getStringList("settings.forceRegisterCommandsAsConsole");
|
||||||
customAttributes = configFile.getBoolean("Hooks.customAttributes");
|
customAttributes = configFile.getBoolean("Hooks.customAttributes");
|
||||||
generateImage = configFile.getBoolean("Email.generateImage", false);
|
|
||||||
preventOtherCase = configFile.getBoolean("settings.preventOtherCase", false);
|
preventOtherCase = configFile.getBoolean("settings.preventOtherCase", false);
|
||||||
kickPlayersBeforeStopping = configFile.getBoolean("Security.stop.kickPlayersBeforeStopping", true);
|
kickPlayersBeforeStopping = configFile.getBoolean("Security.stop.kickPlayersBeforeStopping", true);
|
||||||
sendPlayerTo = configFile.getString("Hooks.sendPlayerTo", "");
|
sendPlayerTo = configFile.getString("Hooks.sendPlayerTo", "");
|
||||||
|
@ -5,43 +5,40 @@ import fr.xephi.authme.settings.domain.Property;
|
|||||||
import fr.xephi.authme.settings.domain.SettingsClass;
|
import fr.xephi.authme.settings.domain.SettingsClass;
|
||||||
|
|
||||||
import static fr.xephi.authme.settings.domain.Property.newProperty;
|
import static fr.xephi.authme.settings.domain.Property.newProperty;
|
||||||
import static fr.xephi.authme.settings.domain.PropertyType.BOOLEAN;
|
|
||||||
import static fr.xephi.authme.settings.domain.PropertyType.INTEGER;
|
|
||||||
import static fr.xephi.authme.settings.domain.PropertyType.STRING;
|
|
||||||
|
|
||||||
public class PurgeSettings implements SettingsClass {
|
public class PurgeSettings implements SettingsClass {
|
||||||
|
|
||||||
@Comment("If enabled, AuthMe automatically purges old, unused accounts")
|
@Comment("If enabled, AuthMe automatically purges old, unused accounts")
|
||||||
public static final Property<Boolean> USE_AUTO_PURGE =
|
public static final Property<Boolean> USE_AUTO_PURGE =
|
||||||
newProperty(BOOLEAN, "Purge.useAutoPurge", false);
|
newProperty("Purge.useAutoPurge", false);
|
||||||
|
|
||||||
@Comment("Number of Days an account become Unused")
|
@Comment("Number of Days an account become Unused")
|
||||||
public static final Property<Integer> DAYS_BEFORE_REMOVE_PLAYER =
|
public static final Property<Integer> DAYS_BEFORE_REMOVE_PLAYER =
|
||||||
newProperty(INTEGER, "Purge.daysBeforeRemovePlayer", 60);
|
newProperty("Purge.daysBeforeRemovePlayer", 60);
|
||||||
|
|
||||||
@Comment("Do we need to remove the player.dat file during purge process?")
|
@Comment("Do we need to remove the player.dat file during purge process?")
|
||||||
public static final Property<Boolean> REMOVE_PLAYER_DAT =
|
public static final Property<Boolean> REMOVE_PLAYER_DAT =
|
||||||
newProperty(BOOLEAN, "Purge.removePlayerDat", false);
|
newProperty("Purge.removePlayerDat", false);
|
||||||
|
|
||||||
@Comment("Do we need to remove the Essentials/users/player.yml file during purge process?")
|
@Comment("Do we need to remove the Essentials/users/player.yml file during purge process?")
|
||||||
public static final Property<Boolean> REMOVE_ESSENTIALS_FILES =
|
public static final Property<Boolean> REMOVE_ESSENTIALS_FILES =
|
||||||
newProperty(BOOLEAN, "Purge.removeEssentialsFile", false);
|
newProperty("Purge.removeEssentialsFile", false);
|
||||||
|
|
||||||
@Comment("World where are players.dat stores")
|
@Comment("World where are players.dat stores")
|
||||||
public static final Property<String> DEFAULT_WORLD =
|
public static final Property<String> DEFAULT_WORLD =
|
||||||
newProperty(STRING, "Purge.defaultWorld", "world");
|
newProperty("Purge.defaultWorld", "world");
|
||||||
|
|
||||||
@Comment("Do we need to remove LimitedCreative/inventories/player.yml, player_creative.yml files during purge process ?")
|
@Comment("Do we need to remove LimitedCreative/inventories/player.yml, player_creative.yml files during purge process ?")
|
||||||
public static final Property<Boolean> REMOVE_LIMITED_CREATIVE_INVENTORIES =
|
public static final Property<Boolean> REMOVE_LIMITED_CREATIVE_INVENTORIES =
|
||||||
newProperty(BOOLEAN, "Purge.removeLimitedCreativesInventories", false);
|
newProperty("Purge.removeLimitedCreativesInventories", false);
|
||||||
|
|
||||||
@Comment("Do we need to remove the AntiXRayData/PlayerData/player file during purge process?")
|
@Comment("Do we need to remove the AntiXRayData/PlayerData/player file during purge process?")
|
||||||
public static final Property<Boolean> REMOVE_ANTI_XRAY_FILE =
|
public static final Property<Boolean> REMOVE_ANTI_XRAY_FILE =
|
||||||
newProperty(BOOLEAN, "Purge.removeAntiXRayFile", false);
|
newProperty("Purge.removeAntiXRayFile", false);
|
||||||
|
|
||||||
@Comment("Do we need to remove permissions?")
|
@Comment("Do we need to remove permissions?")
|
||||||
public static final Property<Boolean> REMOVE_PERMISSIONS =
|
public static final Property<Boolean> REMOVE_PERMISSIONS =
|
||||||
newProperty(BOOLEAN, "Purge.removePermissions", false);
|
newProperty("Purge.removePermissions", false);
|
||||||
|
|
||||||
private PurgeSettings() {
|
private PurgeSettings() {
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ import static org.mockito.Mockito.verify;
|
|||||||
public abstract class AbstractResourceClosingTest {
|
public abstract class AbstractResourceClosingTest {
|
||||||
|
|
||||||
/** List of DataSource method names not to test. */
|
/** List of DataSource method names not to test. */
|
||||||
private static final Set<String> IGNORED_METHODS = ImmutableSet.of("reload", "close", "getType");
|
private static final Set<String> IGNORED_METHODS = ImmutableSet.of("close", "getType");
|
||||||
|
|
||||||
/** Collection of values to use to call methods with the parameters they expect. */
|
/** Collection of values to use to call methods with the parameters they expect. */
|
||||||
private static final Map<Class<?>, Object> PARAM_VALUES = getDefaultParameters();
|
private static final Map<Class<?>, Object> PARAM_VALUES = getDefaultParameters();
|
||||||
|
@ -22,7 +22,7 @@ public class IpAddressManagerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldRetrieveFromCache() {
|
public void shouldRetrieveFromCache() {
|
||||||
// given
|
// given
|
||||||
IpAddressManager ipAddressManager = new IpAddressManager(mockSettings(false));
|
IpAddressManager ipAddressManager = new IpAddressManager(mockSettings(true));
|
||||||
ipAddressManager.addCache("Test", "my test IP");
|
ipAddressManager.addCache("Test", "my test IP");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package fr.xephi.authme.process.email;
|
package fr.xephi.authme.process.email;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
import fr.xephi.authme.settings.NewSetting;
|
import fr.xephi.authme.settings.NewSetting;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
import fr.xephi.authme.util.WrapperMock;
|
import fr.xephi.authme.util.WrapperMock;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@ -27,9 +26,9 @@ import static org.mockito.Mockito.when;
|
|||||||
public class AsyncChangeEmailTest {
|
public class AsyncChangeEmailTest {
|
||||||
|
|
||||||
private Player player;
|
private Player player;
|
||||||
private Messages messages;
|
|
||||||
private PlayerCache playerCache;
|
private PlayerCache playerCache;
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
|
private ProcessService service;
|
||||||
private NewSetting settings;
|
private NewSetting settings;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
@ -41,9 +40,10 @@ public class AsyncChangeEmailTest {
|
|||||||
@After
|
@After
|
||||||
public void cleanFields() {
|
public void cleanFields() {
|
||||||
player = null;
|
player = null;
|
||||||
messages = null;
|
|
||||||
playerCache = null;
|
playerCache = null;
|
||||||
dataSource = null;
|
dataSource = null;
|
||||||
|
service = null;
|
||||||
|
settings = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -62,7 +62,7 @@ public class AsyncChangeEmailTest {
|
|||||||
// then
|
// then
|
||||||
verify(dataSource).updateEmail(auth);
|
verify(dataSource).updateEmail(auth);
|
||||||
verify(playerCache).updatePlayer(auth);
|
verify(playerCache).updatePlayer(auth);
|
||||||
verify(messages).send(player, MessageKey.EMAIL_CHANGED_SUCCESS);
|
verify(service).send(player, MessageKey.EMAIL_CHANGED_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -81,7 +81,7 @@ public class AsyncChangeEmailTest {
|
|||||||
// then
|
// then
|
||||||
verify(dataSource).updateEmail(auth);
|
verify(dataSource).updateEmail(auth);
|
||||||
verify(playerCache, never()).updatePlayer(auth);
|
verify(playerCache, never()).updatePlayer(auth);
|
||||||
verify(messages).send(player, MessageKey.ERROR);
|
verify(service).send(player, MessageKey.ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -99,7 +99,7 @@ public class AsyncChangeEmailTest {
|
|||||||
// then
|
// then
|
||||||
verify(dataSource, never()).updateEmail(any(PlayerAuth.class));
|
verify(dataSource, never()).updateEmail(any(PlayerAuth.class));
|
||||||
verify(playerCache, never()).updatePlayer(any(PlayerAuth.class));
|
verify(playerCache, never()).updatePlayer(any(PlayerAuth.class));
|
||||||
verify(messages).send(player, MessageKey.USAGE_ADD_EMAIL);
|
verify(service).send(player, MessageKey.USAGE_ADD_EMAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -117,7 +117,7 @@ public class AsyncChangeEmailTest {
|
|||||||
// then
|
// then
|
||||||
verify(dataSource, never()).updateEmail(any(PlayerAuth.class));
|
verify(dataSource, never()).updateEmail(any(PlayerAuth.class));
|
||||||
verify(playerCache, never()).updatePlayer(any(PlayerAuth.class));
|
verify(playerCache, never()).updatePlayer(any(PlayerAuth.class));
|
||||||
verify(messages).send(player, MessageKey.INVALID_NEW_EMAIL);
|
verify(service).send(player, MessageKey.INVALID_NEW_EMAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -135,7 +135,7 @@ public class AsyncChangeEmailTest {
|
|||||||
// then
|
// then
|
||||||
verify(dataSource, never()).updateEmail(any(PlayerAuth.class));
|
verify(dataSource, never()).updateEmail(any(PlayerAuth.class));
|
||||||
verify(playerCache, never()).updatePlayer(any(PlayerAuth.class));
|
verify(playerCache, never()).updatePlayer(any(PlayerAuth.class));
|
||||||
verify(messages).send(player, MessageKey.INVALID_OLD_EMAIL);
|
verify(service).send(player, MessageKey.INVALID_OLD_EMAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -154,7 +154,7 @@ public class AsyncChangeEmailTest {
|
|||||||
// then
|
// then
|
||||||
verify(dataSource, never()).updateEmail(any(PlayerAuth.class));
|
verify(dataSource, never()).updateEmail(any(PlayerAuth.class));
|
||||||
verify(playerCache, never()).updatePlayer(any(PlayerAuth.class));
|
verify(playerCache, never()).updatePlayer(any(PlayerAuth.class));
|
||||||
verify(messages).send(player, MessageKey.EMAIL_ALREADY_USED_ERROR);
|
verify(service).send(player, MessageKey.EMAIL_ALREADY_USED_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -171,7 +171,7 @@ public class AsyncChangeEmailTest {
|
|||||||
// then
|
// then
|
||||||
verify(dataSource, never()).updateEmail(any(PlayerAuth.class));
|
verify(dataSource, never()).updateEmail(any(PlayerAuth.class));
|
||||||
verify(playerCache, never()).updatePlayer(any(PlayerAuth.class));
|
verify(playerCache, never()).updatePlayer(any(PlayerAuth.class));
|
||||||
verify(messages).send(player, MessageKey.LOGIN_MESSAGE);
|
verify(service).send(player, MessageKey.LOGIN_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -181,7 +181,7 @@ public class AsyncChangeEmailTest {
|
|||||||
given(player.getName()).willReturn("Bobby");
|
given(player.getName()).willReturn("Bobby");
|
||||||
given(playerCache.isAuthenticated("bobby")).willReturn(false);
|
given(playerCache.isAuthenticated("bobby")).willReturn(false);
|
||||||
given(dataSource.isAuthAvailable("Bobby")).willReturn(false);
|
given(dataSource.isAuthAvailable("Bobby")).willReturn(false);
|
||||||
Settings.emailRegistration = true;
|
given(service.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)).willReturn(true);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
process.run();
|
process.run();
|
||||||
@ -189,7 +189,7 @@ public class AsyncChangeEmailTest {
|
|||||||
// then
|
// then
|
||||||
verify(dataSource, never()).updateEmail(any(PlayerAuth.class));
|
verify(dataSource, never()).updateEmail(any(PlayerAuth.class));
|
||||||
verify(playerCache, never()).updatePlayer(any(PlayerAuth.class));
|
verify(playerCache, never()).updatePlayer(any(PlayerAuth.class));
|
||||||
verify(messages).send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
|
verify(service).send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -199,7 +199,7 @@ public class AsyncChangeEmailTest {
|
|||||||
given(player.getName()).willReturn("Bobby");
|
given(player.getName()).willReturn("Bobby");
|
||||||
given(playerCache.isAuthenticated("bobby")).willReturn(false);
|
given(playerCache.isAuthenticated("bobby")).willReturn(false);
|
||||||
given(dataSource.isAuthAvailable("Bobby")).willReturn(false);
|
given(dataSource.isAuthAvailable("Bobby")).willReturn(false);
|
||||||
Settings.emailRegistration = false;
|
given(service.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)).willReturn(false);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
process.run();
|
process.run();
|
||||||
@ -207,7 +207,7 @@ public class AsyncChangeEmailTest {
|
|||||||
// then
|
// then
|
||||||
verify(dataSource, never()).updateEmail(any(PlayerAuth.class));
|
verify(dataSource, never()).updateEmail(any(PlayerAuth.class));
|
||||||
verify(playerCache, never()).updatePlayer(any(PlayerAuth.class));
|
verify(playerCache, never()).updatePlayer(any(PlayerAuth.class));
|
||||||
verify(messages).send(player, MessageKey.REGISTER_MESSAGE);
|
verify(service).send(player, MessageKey.REGISTER_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PlayerAuth authWithMail(String email) {
|
private static PlayerAuth authWithMail(String email) {
|
||||||
@ -218,12 +218,11 @@ public class AsyncChangeEmailTest {
|
|||||||
|
|
||||||
private AsyncChangeEmail createProcess(String oldEmail, String newEmail) {
|
private AsyncChangeEmail createProcess(String oldEmail, String newEmail) {
|
||||||
player = mock(Player.class);
|
player = mock(Player.class);
|
||||||
messages = mock(Messages.class);
|
|
||||||
AuthMe authMe = mock(AuthMe.class);
|
|
||||||
when(authMe.getMessages()).thenReturn(messages);
|
|
||||||
playerCache = mock(PlayerCache.class);
|
playerCache = mock(PlayerCache.class);
|
||||||
dataSource = mock(DataSource.class);
|
dataSource = mock(DataSource.class);
|
||||||
|
service = mock(ProcessService.class);
|
||||||
settings = mock(NewSetting.class);
|
settings = mock(NewSetting.class);
|
||||||
return new AsyncChangeEmail(player, authMe, oldEmail, newEmail, dataSource, playerCache, settings);
|
given(service.getSettings()).willReturn(settings);
|
||||||
|
return new AsyncChangeEmail(player, oldEmail, newEmail, dataSource, playerCache, service);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user