From 42dbb2772805d4707f363c725302f71db792c253 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Tue, 4 Oct 2016 19:08:18 +0200 Subject: [PATCH] Service cleanup --- src/main/java/fr/xephi/authme/AuthMe.java | 17 ++--- src/main/java/fr/xephi/authme/api/API.java | 2 +- src/main/java/fr/xephi/authme/api/NewAPI.java | 2 +- .../fr/xephi/authme/cache/TempbanManager.java | 6 +- .../cache/backup/PlayerDataStorage.java | 12 ++-- .../xephi/authme/command/CommandService.java | 2 +- .../executable/authme/AccountsCommand.java | 2 +- .../authme/ChangePasswordAdminCommand.java | 6 +- .../executable/authme/ConverterCommand.java | 2 +- .../executable/authme/ForceLoginCommand.java | 2 +- .../executable/authme/GetIpCommand.java | 2 +- .../authme/PurgeBannedPlayersCommand.java | 2 +- .../authme/RegisterAdminCommand.java | 6 +- .../executable/authme/SetEmailCommand.java | 2 +- .../authme/UnregisterAdminCommand.java | 2 +- .../executable/authme/VersionCommand.java | 2 +- .../changepassword/ChangePasswordCommand.java | 4 +- .../executable/email/RecoverEmailCommand.java | 12 ++-- .../authme/{util => geoip}/GeoLiteAPI.java | 3 +- .../authme/initialization/Initializer.java | 6 +- .../initialization/OnShutdownPlayerSaver.java | 4 +- .../authme/listener/ListenerService.java | 2 +- .../xephi/authme/listener/OnJoinVerifier.java | 4 +- .../xephi/authme/listener/PlayerListener.java | 6 +- .../protocollib/ProtocolLibService.java | 2 +- .../fr/xephi/authme/mail/SendMailSSL.java | 2 +- .../fr/xephi/authme/process/Management.java | 2 +- .../xephi/authme/process/ProcessService.java | 2 +- .../authme/process/SyncProcessManager.java | 2 +- .../authme/process/join/AsynchronousJoin.java | 10 +-- .../process/login/AsynchronousLogin.java | 12 ++-- .../process/login/ProcessSyncPlayerLogin.java | 4 +- .../ProcessSynchronousPlayerLogout.java | 6 +- .../authme/process/quit/AsynchronousQuit.java | 6 +- .../process/register/AsyncRegister.java | 14 ++-- .../register/ProcessSyncEmailRegister.java | 4 +- .../register/ProcessSyncPasswordRegister.java | 4 +- .../unregister/AsynchronousUnregister.java | 6 +- .../xephi/authme/service/AntiBotService.java | 5 +- .../BackupService.java} | 8 ++- .../{util => service}/BukkitService.java | 2 +- .../{util => service}/MigrationService.java | 2 +- ...eManager.java => RecoveryCodeService.java} | 4 +- .../TeleportationService.java | 2 +- .../{util => service}/ValidationService.java | 5 +- .../fr/xephi/authme/task/MessageTask.java | 4 +- .../authme/task/PlayerDataTaskManager.java | 4 +- .../authme/task/purge/PurgeExecutor.java | 8 +-- .../xephi/authme/task/purge/PurgeService.java | 2 +- .../fr/xephi/authme/util/CollectionUtils.java | 1 + .../java/fr/xephi/authme/util/FileUtils.java | 1 + .../fr/xephi/authme/util/PlayerUtils.java | 42 +++++++++++ .../fr/xephi/authme/util/RuntimeUtils.java | 13 ++++ .../fr/xephi/authme/util/StringUtils.java | 2 +- src/main/java/fr/xephi/authme/util/Utils.java | 29 +------- .../authme/AuthMeInitializationTest.java | 2 +- src/test/java/fr/xephi/authme/TestHelper.java | 2 +- .../java/fr/xephi/authme/api/NewAPITest.java | 2 +- .../authme/cache/TempbanManagerTest.java | 2 +- .../cache/backup/PlayerDataStorageTest.java | 2 +- .../authme/command/CommandServiceTest.java | 2 +- .../authme/AccountsCommandTest.java | 2 +- .../ChangePasswordAdminCommandTest.java | 6 +- .../authme/ConverterCommandTest.java | 2 +- .../authme/ForceLoginCommandTest.java | 2 +- .../executable/authme/GetIpCommandTest.java | 2 +- .../authme/PurgeBannedPlayersCommandTest.java | 2 +- .../authme/RegisterAdminCommandTest.java | 6 +- .../authme/SetEmailCommandTest.java | 2 +- .../authme/UnregisterAdminCommandTest.java | 2 +- .../ChangePasswordCommandTest.java | 4 +- .../email/RecoverEmailCommandTest.java | 22 +++--- .../GeoIpManagerTest.java} | 5 +- .../authme/listener/ListenerServiceTest.java | 2 +- .../authme/listener/OnJoinVerifierTest.java | 4 +- .../authme/listener/PlayerListenerTest.java | 6 +- .../authme/process/ProcessServiceTest.java | 2 +- .../process/login/AsynchronousLoginTest.java | 2 +- .../AsynchronousUnregisterTest.java | 4 +- .../authme/service/AntiBotServiceTest.java | 1 - .../{util => service}/BukkitServiceTest.java | 2 +- .../MigrationServiceTest.java | 3 +- ...Test.java => RecoveryCodeServiceTest.java} | 30 ++++---- .../TeleportationServiceTest.java | 4 +- .../ValidationServiceTest.java | 6 +- .../task/PlayerDataTaskManagerTest.java | 2 +- .../authme/task/purge/PurgeServiceTest.java | 2 +- .../fr/xephi/authme/util/PlayerUtilsTest.java | 69 +++++++++++++++++++ .../java/fr/xephi/authme/util/UtilsTest.java | 48 ------------- 89 files changed, 319 insertions(+), 257 deletions(-) rename src/main/java/fr/xephi/authme/{util => geoip}/GeoLiteAPI.java (98%) rename src/main/java/fr/xephi/authme/{PerformBackup.java => service/BackupService.java} (97%) rename src/main/java/fr/xephi/authme/{util => service}/BukkitService.java (99%) rename src/main/java/fr/xephi/authme/{util => service}/MigrationService.java (99%) rename src/main/java/fr/xephi/authme/service/{RecoveryCodeManager.java => RecoveryCodeService.java} (96%) rename src/main/java/fr/xephi/authme/{util => service}/TeleportationService.java (99%) rename src/main/java/fr/xephi/authme/{util => service}/ValidationService.java (98%) create mode 100644 src/main/java/fr/xephi/authme/util/PlayerUtils.java rename src/test/java/fr/xephi/authme/{util/GeoLiteAPITest.java => geoip/GeoIpManagerTest.java} (96%) rename src/test/java/fr/xephi/authme/{util => service}/BukkitServiceTest.java (98%) rename src/test/java/fr/xephi/authme/{util => service}/MigrationServiceTest.java (98%) rename src/test/java/fr/xephi/authme/service/{RecoveryCodeManagerTest.java => RecoveryCodeServiceTest.java} (73%) rename src/test/java/fr/xephi/authme/{util => service}/TeleportationServiceTest.java (99%) rename src/test/java/fr/xephi/authme/{util => service}/ValidationServiceTest.java (98%) create mode 100644 src/test/java/fr/xephi/authme/util/PlayerUtilsTest.java diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index b80130576..9c94bc8ea 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -25,16 +25,17 @@ import fr.xephi.authme.output.Messages; import fr.xephi.authme.permission.PermissionsManager; import fr.xephi.authme.permission.PermissionsSystemType; import fr.xephi.authme.security.crypts.SHA256; +import fr.xephi.authme.service.BackupService; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.PluginSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.settings.properties.SecuritySettings; import fr.xephi.authme.task.CleanupTask; import fr.xephi.authme.task.purge.PurgeService; -import fr.xephi.authme.util.BukkitService; -import fr.xephi.authme.util.GeoLiteAPI; -import fr.xephi.authme.util.MigrationService; -import fr.xephi.authme.util.Utils; +import fr.xephi.authme.service.BukkitService; +import fr.xephi.authme.geoip.GeoLiteAPI; +import fr.xephi.authme.service.MigrationService; +import fr.xephi.authme.util.PlayerUtils; import org.bukkit.Server; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -48,7 +49,7 @@ import org.bukkit.scheduler.BukkitScheduler; import java.io.File; import java.util.Date; -import static fr.xephi.authme.util.BukkitService.TICKS_PER_MINUTE; +import static fr.xephi.authme.service.BukkitService.TICKS_PER_MINUTE; import static fr.xephi.authme.util.Utils.isClassLoaded; /** @@ -150,7 +151,7 @@ public class AuthMe extends JavaPlugin { } // Do a backup on start - new PerformBackup(this, settings).doBackup(PerformBackup.BackupCause.START); + new BackupService(this, settings).doBackup(BackupService.BackupCause.START); // Set up Metrics MetricsManager.sendMetrics(this, settings); @@ -344,7 +345,7 @@ public class AuthMe extends JavaPlugin { // Do backup on stop if enabled if (settings != null) { - new PerformBackup(this, settings).doBackup(PerformBackup.BackupCause.STOP); + new BackupService(this, settings).doBackup(BackupService.BackupCause.STOP); } // Wait for tasks and close data source @@ -360,7 +361,7 @@ public class AuthMe extends JavaPlugin { public String replaceAllInfo(String message, Player player) { String playersOnline = Integer.toString(bukkitService.getOnlinePlayers().size()); - String ipAddress = Utils.getPlayerIp(player); + String ipAddress = PlayerUtils.getPlayerIp(player); Server server = getServer(); return message .replace("&", "\u00a7") diff --git a/src/main/java/fr/xephi/authme/api/API.java b/src/main/java/fr/xephi/authme/api/API.java index 0eafe3dac..8e16bd608 100644 --- a/src/main/java/fr/xephi/authme/api/API.java +++ b/src/main/java/fr/xephi/authme/api/API.java @@ -8,7 +8,7 @@ import fr.xephi.authme.hooks.PluginHooks; import fr.xephi.authme.process.Management; import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.crypts.HashedPassword; -import fr.xephi.authme.util.ValidationService; +import fr.xephi.authme.service.ValidationService; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/xephi/authme/api/NewAPI.java b/src/main/java/fr/xephi/authme/api/NewAPI.java index 68f973a82..5cee36e04 100644 --- a/src/main/java/fr/xephi/authme/api/NewAPI.java +++ b/src/main/java/fr/xephi/authme/api/NewAPI.java @@ -8,7 +8,7 @@ import fr.xephi.authme.hooks.PluginHooks; import fr.xephi.authme.process.Management; import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.crypts.HashedPassword; -import fr.xephi.authme.util.ValidationService; +import fr.xephi.authme.service.ValidationService; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/xephi/authme/cache/TempbanManager.java b/src/main/java/fr/xephi/authme/cache/TempbanManager.java index 832c650d1..c0cb39200 100644 --- a/src/main/java/fr/xephi/authme/cache/TempbanManager.java +++ b/src/main/java/fr/xephi/authme/cache/TempbanManager.java @@ -7,8 +7,8 @@ import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.output.Messages; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.SecuritySettings; -import fr.xephi.authme.util.BukkitService; -import fr.xephi.authme.util.Utils; +import fr.xephi.authme.service.BukkitService; +import fr.xephi.authme.util.PlayerUtils; import org.bukkit.entity.Player; import javax.inject.Inject; @@ -108,7 +108,7 @@ public class TempbanManager implements SettingsDependent, HasCleanup { */ public void tempbanPlayer(final Player player) { if (isEnabled) { - final String ip = Utils.getPlayerIp(player); + final String ip = PlayerUtils.getPlayerIp(player); final String reason = messages.retrieveSingle(MessageKey.TEMPBAN_MAX_LOGINS); final Date expires = new Date(); diff --git a/src/main/java/fr/xephi/authme/cache/backup/PlayerDataStorage.java b/src/main/java/fr/xephi/authme/cache/backup/PlayerDataStorage.java index e10e88efa..04015d844 100644 --- a/src/main/java/fr/xephi/authme/cache/backup/PlayerDataStorage.java +++ b/src/main/java/fr/xephi/authme/cache/backup/PlayerDataStorage.java @@ -14,9 +14,9 @@ import fr.xephi.authme.cache.limbo.PlayerData; import fr.xephi.authme.initialization.DataFolder; import fr.xephi.authme.permission.PermissionsManager; import fr.xephi.authme.settings.SpawnLoader; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.util.FileUtils; -import fr.xephi.authme.util.Utils; +import fr.xephi.authme.util.PlayerUtils; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; @@ -64,7 +64,7 @@ public class PlayerDataStorage { * @return PlayerData object if the data is exist, null otherwise. */ public PlayerData readData(Player player) { - String id = Utils.getUUIDorName(player); + String id = PlayerUtils.getUUIDorName(player); File file = new File(cacheDir, id + File.separator + "data.json"); if (!file.exists()) { return null; @@ -85,7 +85,7 @@ public class PlayerDataStorage { * @param player player to save */ public void saveData(Player player) { - String id = Utils.getUUIDorName(player); + String id = PlayerUtils.getUUIDorName(player); Location location = spawnLoader.getPlayerLocationOrSpawn(player); String group = ""; if (permissionsManager.hasGroupSupport()) { @@ -113,7 +113,7 @@ public class PlayerDataStorage { * @param player player to remove */ public void removeData(Player player) { - String id = Utils.getUUIDorName(player); + String id = PlayerUtils.getUUIDorName(player); File file = new File(cacheDir, id); if (file.exists()) { FileUtils.purgeDirectory(file); @@ -131,7 +131,7 @@ public class PlayerDataStorage { * @return true if data exist, false otherwise. */ public boolean hasData(Player player) { - String id = Utils.getUUIDorName(player); + String id = PlayerUtils.getUUIDorName(player); File file = new File(cacheDir, id + File.separator + "data.json"); return file.exists(); } diff --git a/src/main/java/fr/xephi/authme/command/CommandService.java b/src/main/java/fr/xephi/authme/command/CommandService.java index 95965fac9..a01edfaeb 100644 --- a/src/main/java/fr/xephi/authme/command/CommandService.java +++ b/src/main/java/fr/xephi/authme/command/CommandService.java @@ -4,7 +4,7 @@ import com.github.authme.configme.properties.Property; import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.output.Messages; import fr.xephi.authme.settings.Settings; -import fr.xephi.authme.util.ValidationService; +import fr.xephi.authme.service.ValidationService; import org.bukkit.command.CommandSender; import javax.inject.Inject; diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/AccountsCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/AccountsCommand.java index f8d39d054..5951bd808 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/AccountsCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/AccountsCommand.java @@ -5,7 +5,7 @@ import fr.xephi.authme.command.CommandService; import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.output.MessageKey; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.command.CommandSender; import javax.inject.Inject; diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/ChangePasswordAdminCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/ChangePasswordAdminCommand.java index 9dcd04797..3c0b2323a 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/ChangePasswordAdminCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/ChangePasswordAdminCommand.java @@ -9,9 +9,9 @@ import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.crypts.HashedPassword; -import fr.xephi.authme.util.BukkitService; -import fr.xephi.authme.util.ValidationService; -import fr.xephi.authme.util.ValidationService.ValidationResult; +import fr.xephi.authme.service.BukkitService; +import fr.xephi.authme.service.ValidationService; +import fr.xephi.authme.service.ValidationService.ValidationResult; import org.bukkit.command.CommandSender; import javax.inject.Inject; diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/ConverterCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/ConverterCommand.java index a615f3ec9..73a21a047 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/ConverterCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/ConverterCommand.java @@ -15,7 +15,7 @@ import fr.xephi.authme.converter.SqliteToSql; import fr.xephi.authme.converter.vAuthConverter; import fr.xephi.authme.converter.xAuthConverter; import fr.xephi.authme.output.MessageKey; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.command.CommandSender; import javax.inject.Inject; diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/ForceLoginCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/ForceLoginCommand.java index 9928f56f6..3adcad45e 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/ForceLoginCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/ForceLoginCommand.java @@ -3,7 +3,7 @@ package fr.xephi.authme.command.executable.authme; import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.permission.PermissionsManager; import fr.xephi.authme.process.Management; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/GetIpCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/GetIpCommand.java index 773f01b40..332c0c8dd 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/GetIpCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/GetIpCommand.java @@ -1,7 +1,7 @@ package fr.xephi.authme.command.executable.authme; import fr.xephi.authme.command.ExecutableCommand; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/PurgeBannedPlayersCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/PurgeBannedPlayersCommand.java index b4e9e545e..ff41ddbac 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/PurgeBannedPlayersCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/PurgeBannedPlayersCommand.java @@ -2,7 +2,7 @@ package fr.xephi.authme.command.executable.authme; import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.task.purge.PurgeService; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommand.java index f4ca7cb04..166d2d808 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommand.java @@ -9,9 +9,9 @@ import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.crypts.HashedPassword; -import fr.xephi.authme.util.BukkitService; -import fr.xephi.authme.util.ValidationService; -import fr.xephi.authme.util.ValidationService.ValidationResult; +import fr.xephi.authme.service.BukkitService; +import fr.xephi.authme.service.ValidationService; +import fr.xephi.authme.service.ValidationService.ValidationResult; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/SetEmailCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/SetEmailCommand.java index ebce774cf..d3d6ea78d 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/SetEmailCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/SetEmailCommand.java @@ -6,7 +6,7 @@ import fr.xephi.authme.command.CommandService; import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.output.MessageKey; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.command.CommandSender; import javax.inject.Inject; diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/UnregisterAdminCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/UnregisterAdminCommand.java index eaf14b6b7..51e7c4d43 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/UnregisterAdminCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/UnregisterAdminCommand.java @@ -5,7 +5,7 @@ import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.process.Management; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/VersionCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/VersionCommand.java index 86437dd77..4169940bb 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/VersionCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/VersionCommand.java @@ -3,7 +3,7 @@ package fr.xephi.authme.command.executable.authme; import fr.xephi.authme.AuthMe; import fr.xephi.authme.command.CommandService; import fr.xephi.authme.command.ExecutableCommand; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommand.java b/src/main/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommand.java index 0fdbf6072..2d7c12046 100644 --- a/src/main/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommand.java @@ -5,8 +5,8 @@ import fr.xephi.authme.command.CommandService; import fr.xephi.authme.command.PlayerCommand; import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.process.Management; -import fr.xephi.authme.util.ValidationService; -import fr.xephi.authme.util.ValidationService.ValidationResult; +import fr.xephi.authme.service.ValidationService; +import fr.xephi.authme.service.ValidationService.ValidationResult; import org.bukkit.entity.Player; import javax.inject.Inject; diff --git a/src/main/java/fr/xephi/authme/command/executable/email/RecoverEmailCommand.java b/src/main/java/fr/xephi/authme/command/executable/email/RecoverEmailCommand.java index 26b0e2f9c..ccff7b1be 100644 --- a/src/main/java/fr/xephi/authme/command/executable/email/RecoverEmailCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/email/RecoverEmailCommand.java @@ -11,7 +11,7 @@ import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.RandomString; import fr.xephi.authme.security.crypts.HashedPassword; -import fr.xephi.authme.service.RecoveryCodeManager; +import fr.xephi.authme.service.RecoveryCodeService; import org.bukkit.entity.Player; import javax.inject.Inject; @@ -40,7 +40,7 @@ public class RecoverEmailCommand extends PlayerCommand { private SendMailSSL sendMailSsl; @Inject - private RecoveryCodeManager recoveryCodeManager; + private RecoveryCodeService recoveryCodeService; @Override public void runCommand(Player player, List arguments) { @@ -69,7 +69,7 @@ public class RecoverEmailCommand extends PlayerCommand { return; } - if (recoveryCodeManager.isRecoveryCodeNeeded()) { + if (recoveryCodeService.isRecoveryCodeNeeded()) { // Process /email recovery addr@example.com if (arguments.size() == 1) { createAndSendRecoveryCode(player, email); @@ -83,20 +83,20 @@ public class RecoverEmailCommand extends PlayerCommand { } private void createAndSendRecoveryCode(Player player, String email) { - String recoveryCode = recoveryCodeManager.generateCode(player.getName()); + String recoveryCode = recoveryCodeService.generateCode(player.getName()); sendMailSsl.sendRecoveryCode(player.getName(), email, recoveryCode); commandService.send(player, MessageKey.RECOVERY_CODE_SENT); } private void processRecoveryCode(Player player, String code, String email) { final String name = player.getName(); - if (!recoveryCodeManager.isCodeValid(name, code)) { + if (!recoveryCodeService.isCodeValid(name, code)) { commandService.send(player, MessageKey.INCORRECT_RECOVERY_CODE); return; } generateAndSendNewPassword(player, email); - recoveryCodeManager.removeCode(name); + recoveryCodeService.removeCode(name); } private void generateAndSendNewPassword(Player player, String email) { diff --git a/src/main/java/fr/xephi/authme/util/GeoLiteAPI.java b/src/main/java/fr/xephi/authme/geoip/GeoLiteAPI.java similarity index 98% rename from src/main/java/fr/xephi/authme/util/GeoLiteAPI.java rename to src/main/java/fr/xephi/authme/geoip/GeoLiteAPI.java index 050c37300..11f5e4f01 100644 --- a/src/main/java/fr/xephi/authme/util/GeoLiteAPI.java +++ b/src/main/java/fr/xephi/authme/geoip/GeoLiteAPI.java @@ -1,9 +1,10 @@ -package fr.xephi.authme.util; +package fr.xephi.authme.geoip; import com.google.common.annotations.VisibleForTesting; import com.maxmind.geoip.LookupService; import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.initialization.DataFolder; +import fr.xephi.authme.util.FileUtils; import javax.inject.Inject; import java.io.File; diff --git a/src/main/java/fr/xephi/authme/initialization/Initializer.java b/src/main/java/fr/xephi/authme/initialization/Initializer.java index 9aaba7990..5a048678d 100644 --- a/src/main/java/fr/xephi/authme/initialization/Initializer.java +++ b/src/main/java/fr/xephi/authme/initialization/Initializer.java @@ -22,9 +22,9 @@ import fr.xephi.authme.settings.properties.AuthMeSettingsRetriever; import fr.xephi.authme.settings.properties.DatabaseSettings; import fr.xephi.authme.settings.properties.EmailSettings; import fr.xephi.authme.settings.properties.SecuritySettings; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.util.FileUtils; -import fr.xephi.authme.util.MigrationService; +import fr.xephi.authme.service.MigrationService; import fr.xephi.authme.util.StringUtils; import org.apache.logging.log4j.LogManager; import org.bukkit.Bukkit; @@ -37,7 +37,7 @@ import java.util.List; import java.util.logging.Logger; import static fr.xephi.authme.settings.properties.EmailSettings.RECALL_PLAYERS; -import static fr.xephi.authme.util.BukkitService.TICKS_PER_MINUTE; +import static fr.xephi.authme.service.BukkitService.TICKS_PER_MINUTE; /** * Initializes various services. diff --git a/src/main/java/fr/xephi/authme/initialization/OnShutdownPlayerSaver.java b/src/main/java/fr/xephi/authme/initialization/OnShutdownPlayerSaver.java index 852f5380d..28a1134f6 100644 --- a/src/main/java/fr/xephi/authme/initialization/OnShutdownPlayerSaver.java +++ b/src/main/java/fr/xephi/authme/initialization/OnShutdownPlayerSaver.java @@ -9,8 +9,8 @@ import fr.xephi.authme.hooks.PluginHooks; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.SpawnLoader; import fr.xephi.authme.settings.properties.RestrictionSettings; -import fr.xephi.authme.util.BukkitService; -import fr.xephi.authme.util.ValidationService; +import fr.xephi.authme.service.BukkitService; +import fr.xephi.authme.service.ValidationService; import org.bukkit.Location; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/xephi/authme/listener/ListenerService.java b/src/main/java/fr/xephi/authme/listener/ListenerService.java index 6c09bd2e5..4db65530a 100644 --- a/src/main/java/fr/xephi/authme/listener/ListenerService.java +++ b/src/main/java/fr/xephi/authme/listener/ListenerService.java @@ -6,7 +6,7 @@ import fr.xephi.authme.hooks.PluginHooks; import fr.xephi.authme.initialization.SettingsDependent; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.RegistrationSettings; -import fr.xephi.authme.util.ValidationService; +import fr.xephi.authme.service.ValidationService; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityEvent; diff --git a/src/main/java/fr/xephi/authme/listener/OnJoinVerifier.java b/src/main/java/fr/xephi/authme/listener/OnJoinVerifier.java index 1767e0e0b..b58f9bc99 100644 --- a/src/main/java/fr/xephi/authme/listener/OnJoinVerifier.java +++ b/src/main/java/fr/xephi/authme/listener/OnJoinVerifier.java @@ -13,10 +13,10 @@ import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.ProtectionSettings; import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.util.StringUtils; import fr.xephi.authme.util.Utils; -import fr.xephi.authme.util.ValidationService; +import fr.xephi.authme.service.ValidationService; import org.bukkit.Server; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerLoginEvent; diff --git a/src/main/java/fr/xephi/authme/listener/PlayerListener.java b/src/main/java/fr/xephi/authme/listener/PlayerListener.java index 1a5f8a287..20f33f09e 100644 --- a/src/main/java/fr/xephi/authme/listener/PlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/PlayerListener.java @@ -11,9 +11,9 @@ import fr.xephi.authme.settings.SpawnLoader; import fr.xephi.authme.settings.properties.HooksSettings; import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; -import fr.xephi.authme.util.BukkitService; -import fr.xephi.authme.util.TeleportationService; -import fr.xephi.authme.util.ValidationService; +import fr.xephi.authme.service.BukkitService; +import fr.xephi.authme.service.TeleportationService; +import fr.xephi.authme.service.ValidationService; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/src/main/java/fr/xephi/authme/listener/protocollib/ProtocolLibService.java b/src/main/java/fr/xephi/authme/listener/protocollib/ProtocolLibService.java index ae373bb08..3e10cde0d 100644 --- a/src/main/java/fr/xephi/authme/listener/protocollib/ProtocolLibService.java +++ b/src/main/java/fr/xephi/authme/listener/protocollib/ProtocolLibService.java @@ -7,7 +7,7 @@ import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.initialization.SettingsDependent; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.RestrictionSettings; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.entity.Player; import javax.inject.Inject; diff --git a/src/main/java/fr/xephi/authme/mail/SendMailSSL.java b/src/main/java/fr/xephi/authme/mail/SendMailSSL.java index 3bd5be44d..e629402f1 100644 --- a/src/main/java/fr/xephi/authme/mail/SendMailSSL.java +++ b/src/main/java/fr/xephi/authme/mail/SendMailSSL.java @@ -5,7 +5,7 @@ import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.EmailSettings; import fr.xephi.authme.settings.properties.SecuritySettings; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.util.FileUtils; import fr.xephi.authme.util.StringUtils; import org.apache.commons.mail.EmailConstants; diff --git a/src/main/java/fr/xephi/authme/process/Management.java b/src/main/java/fr/xephi/authme/process/Management.java index 9efb5e6d2..be32e99e8 100644 --- a/src/main/java/fr/xephi/authme/process/Management.java +++ b/src/main/java/fr/xephi/authme/process/Management.java @@ -9,7 +9,7 @@ import fr.xephi.authme.process.logout.AsynchronousLogout; import fr.xephi.authme.process.quit.AsynchronousQuit; import fr.xephi.authme.process.register.AsyncRegister; import fr.xephi.authme.process.unregister.AsynchronousUnregister; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/xephi/authme/process/ProcessService.java b/src/main/java/fr/xephi/authme/process/ProcessService.java index 33f3eed78..239c73fd1 100644 --- a/src/main/java/fr/xephi/authme/process/ProcessService.java +++ b/src/main/java/fr/xephi/authme/process/ProcessService.java @@ -8,7 +8,7 @@ import fr.xephi.authme.permission.AuthGroupType; import fr.xephi.authme.permission.PermissionNode; import fr.xephi.authme.permission.PermissionsManager; import fr.xephi.authme.settings.Settings; -import fr.xephi.authme.util.ValidationService; +import fr.xephi.authme.service.ValidationService; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/xephi/authme/process/SyncProcessManager.java b/src/main/java/fr/xephi/authme/process/SyncProcessManager.java index 777a957dd..b8c344bfe 100644 --- a/src/main/java/fr/xephi/authme/process/SyncProcessManager.java +++ b/src/main/java/fr/xephi/authme/process/SyncProcessManager.java @@ -5,7 +5,7 @@ import fr.xephi.authme.process.logout.ProcessSynchronousPlayerLogout; import fr.xephi.authme.process.quit.ProcessSyncronousPlayerQuit; import fr.xephi.authme.process.register.ProcessSyncEmailRegister; import fr.xephi.authme.process.register.ProcessSyncPasswordRegister; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.entity.Player; import javax.inject.Inject; diff --git a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java index dcd7599d3..b8dd5af00 100644 --- a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java +++ b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java @@ -20,8 +20,8 @@ import fr.xephi.authme.settings.properties.PluginSettings; import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.task.PlayerDataTaskManager; -import fr.xephi.authme.util.BukkitService; -import fr.xephi.authme.util.Utils; +import fr.xephi.authme.service.BukkitService; +import fr.xephi.authme.util.PlayerUtils; import org.apache.commons.lang.reflect.MethodUtils; import org.bukkit.GameMode; import org.bukkit.entity.LivingEntity; @@ -32,7 +32,7 @@ import org.bukkit.potion.PotionEffectType; import javax.inject.Inject; import static fr.xephi.authme.settings.properties.RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN; -import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND; +import static fr.xephi.authme.service.BukkitService.TICKS_PER_SECOND; /** * Asynchronous process for when a player joins. @@ -78,7 +78,7 @@ public class AsynchronousJoin implements AsynchronousProcess { public void processJoin(final Player player) { final String name = player.getName().toLowerCase(); - final String ip = Utils.getPlayerIp(player); + final String ip = PlayerUtils.getPlayerIp(player); if (isPlayerUnrestricted(name)) { return; @@ -249,7 +249,7 @@ public class AsynchronousJoin implements AsynchronousProcess { private int countOnlinePlayersByIp(String ip) { int count = 0; for (Player player : bukkitService.getOnlinePlayers()) { - if (ip.equalsIgnoreCase(Utils.getPlayerIp(player))) { + if (ip.equalsIgnoreCase(PlayerUtils.getPlayerIp(player))) { ++count; } } diff --git a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java index b63c6ccd5..3a8b7fc38 100644 --- a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java @@ -25,9 +25,9 @@ import fr.xephi.authme.settings.properties.HooksSettings; import fr.xephi.authme.settings.properties.PluginSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.task.PlayerDataTaskManager; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; +import fr.xephi.authme.util.PlayerUtils; import fr.xephi.authme.util.StringUtils; -import fr.xephi.authme.util.Utils; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -130,7 +130,7 @@ public class AsynchronousLogin implements AsynchronousProcess { return null; } - final String ip = Utils.getPlayerIp(player); + final String ip = PlayerUtils.getPlayerIp(player); if (hasReachedMaxLoggedInPlayersForIp(player, ip)) { service.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR); return null; @@ -163,7 +163,7 @@ public class AsynchronousLogin implements AsynchronousProcess { return false; } - final String ip = Utils.getPlayerIp(player); + final String ip = PlayerUtils.getPlayerIp(player); // Increase the counts here before knowing the result of the login. captchaManager.increaseCount(name); @@ -210,7 +210,7 @@ public class AsynchronousLogin implements AsynchronousProcess { private void performLogin(Player player, PlayerAuth auth) { if (player.isOnline()) { // Update auth to reflect this new login - final String ip = Utils.getPlayerIp(player); + final String ip = PlayerUtils.getPlayerIp(player); auth.setRealName(player.getName()); auth.setLastLogin(System.currentTimeMillis()); auth.setIp(ip); @@ -311,7 +311,7 @@ public class AsynchronousLogin implements AsynchronousProcess { final String name = player.getName(); int count = 0; for (Player onlinePlayer : bukkitService.getOnlinePlayers()) { - if (ip.equalsIgnoreCase(Utils.getPlayerIp(onlinePlayer)) + if (ip.equalsIgnoreCase(PlayerUtils.getPlayerIp(onlinePlayer)) && !onlinePlayer.getName().equals(name) && dataSource.isLogged(onlinePlayer.getName().toLowerCase())) { ++count; diff --git a/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java b/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java index acc235dbb..4735ab579 100644 --- a/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java @@ -12,8 +12,8 @@ import fr.xephi.authme.process.ProcessService; import fr.xephi.authme.process.SynchronousProcess; import fr.xephi.authme.service.BungeeService; import fr.xephi.authme.settings.properties.RegistrationSettings; -import fr.xephi.authme.util.BukkitService; -import fr.xephi.authme.util.TeleportationService; +import fr.xephi.authme.service.BukkitService; +import fr.xephi.authme.service.TeleportationService; import org.apache.commons.lang.reflect.MethodUtils; import org.bukkit.Bukkit; import org.bukkit.entity.LivingEntity; diff --git a/src/main/java/fr/xephi/authme/process/logout/ProcessSynchronousPlayerLogout.java b/src/main/java/fr/xephi/authme/process/logout/ProcessSynchronousPlayerLogout.java index 6b61b9258..cb3723cbe 100644 --- a/src/main/java/fr/xephi/authme/process/logout/ProcessSynchronousPlayerLogout.java +++ b/src/main/java/fr/xephi/authme/process/logout/ProcessSynchronousPlayerLogout.java @@ -11,15 +11,15 @@ import fr.xephi.authme.process.SynchronousProcess; import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.task.PlayerDataTaskManager; -import fr.xephi.authme.util.BukkitService; -import fr.xephi.authme.util.TeleportationService; +import fr.xephi.authme.service.BukkitService; +import fr.xephi.authme.service.TeleportationService; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import javax.inject.Inject; -import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND; +import static fr.xephi.authme.service.BukkitService.TICKS_PER_SECOND; public class ProcessSynchronousPlayerLogout implements SynchronousProcess { diff --git a/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java b/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java index cc7eb60fc..ce3af43aa 100644 --- a/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java +++ b/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java @@ -11,8 +11,8 @@ import fr.xephi.authme.process.ProcessService; import fr.xephi.authme.process.SyncProcessManager; import fr.xephi.authme.settings.SpawnLoader; import fr.xephi.authme.settings.properties.RestrictionSettings; -import fr.xephi.authme.util.Utils; -import fr.xephi.authme.util.ValidationService; +import fr.xephi.authme.util.PlayerUtils; +import fr.xephi.authme.service.ValidationService; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -63,7 +63,7 @@ public class AsynchronousQuit implements AsynchronousProcess { database.updateQuitLoc(auth); } - final String ip = Utils.getPlayerIp(player); + final String ip = PlayerUtils.getPlayerIp(player); PlayerAuth auth = PlayerAuth.builder() .name(name) .realName(player.getName()) diff --git a/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java b/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java index 21eae43dc..41b1d9992 100644 --- a/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java @@ -19,11 +19,11 @@ import fr.xephi.authme.settings.properties.PluginSettings; import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.settings.properties.SecuritySettings; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; +import fr.xephi.authme.util.PlayerUtils; import fr.xephi.authme.util.StringUtils; -import fr.xephi.authme.util.Utils; -import fr.xephi.authme.util.ValidationService; -import fr.xephi.authme.util.ValidationService.ValidationResult; +import fr.xephi.authme.service.ValidationService; +import fr.xephi.authme.service.ValidationService.ValidationResult; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -94,7 +94,7 @@ public class AsyncRegister implements AsynchronousProcess { } final int maxRegPerIp = service.getProperty(RestrictionSettings.MAX_REGISTRATION_PER_IP); - final String ip = Utils.getPlayerIp(player); + final String ip = PlayerUtils.getPlayerIp(player); if (maxRegPerIp > 0 && !"127.0.0.1".equalsIgnoreCase(ip) && !"localhost".equalsIgnoreCase(ip) @@ -132,7 +132,7 @@ public class AsyncRegister implements AsynchronousProcess { } final HashedPassword hashedPassword = passwordSecurity.computeHash(password, name); - final String ip = Utils.getPlayerIp(player); + final String ip = PlayerUtils.getPlayerIp(player); PlayerAuth auth = PlayerAuth.builder() .name(name) .realName(player.getName()) @@ -154,7 +154,7 @@ public class AsyncRegister implements AsynchronousProcess { private void passwordRegister(final Player player, String password, boolean autoLogin) { final String name = player.getName().toLowerCase(); - final String ip = Utils.getPlayerIp(player); + final String ip = PlayerUtils.getPlayerIp(player); final HashedPassword hashedPassword = passwordSecurity.computeHash(password, name); PlayerAuth auth = PlayerAuth.builder() .name(name) diff --git a/src/main/java/fr/xephi/authme/process/register/ProcessSyncEmailRegister.java b/src/main/java/fr/xephi/authme/process/register/ProcessSyncEmailRegister.java index cd10a69b5..67e1478a9 100644 --- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncEmailRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncEmailRegister.java @@ -7,7 +7,7 @@ import fr.xephi.authme.process.ProcessService; import fr.xephi.authme.process.SynchronousProcess; import fr.xephi.authme.settings.properties.HooksSettings; import fr.xephi.authme.task.PlayerDataTaskManager; -import fr.xephi.authme.util.Utils; +import fr.xephi.authme.util.PlayerUtils; import org.bukkit.entity.Player; import javax.inject.Inject; @@ -35,7 +35,7 @@ public class ProcessSyncEmailRegister implements SynchronousProcess { playerDataTaskManager.registerMessageTask(name, true); player.saveData(); - ConsoleLogger.fine(player.getName() + " registered " + Utils.getPlayerIp(player)); + ConsoleLogger.fine(player.getName() + " registered " + PlayerUtils.getPlayerIp(player)); } } diff --git a/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java b/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java index 2770b96ee..cbc37cbd4 100644 --- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java @@ -11,7 +11,7 @@ import fr.xephi.authme.settings.properties.EmailSettings; import fr.xephi.authme.settings.properties.HooksSettings; import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.task.PlayerDataTaskManager; -import fr.xephi.authme.util.Utils; +import fr.xephi.authme.util.PlayerUtils; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -74,7 +74,7 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess { } player.saveData(); - ConsoleLogger.fine(player.getName() + " registered " + Utils.getPlayerIp(player)); + ConsoleLogger.fine(player.getName() + " registered " + PlayerUtils.getPlayerIp(player)); // Kick Player after Registration is enabled, kick the player if (service.getProperty(RegistrationSettings.FORCE_KICK_AFTER_REGISTER)) { diff --git a/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java b/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java index 5d9a0fca1..de859e9a7 100644 --- a/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java +++ b/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java @@ -14,8 +14,8 @@ import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.task.PlayerDataTaskManager; -import fr.xephi.authme.util.BukkitService; -import fr.xephi.authme.util.TeleportationService; +import fr.xephi.authme.service.BukkitService; +import fr.xephi.authme.service.TeleportationService; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; @@ -23,7 +23,7 @@ import org.bukkit.potion.PotionEffectType; import javax.inject.Inject; -import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND; +import static fr.xephi.authme.service.BukkitService.TICKS_PER_SECOND; public class AsynchronousUnregister implements AsynchronousProcess { diff --git a/src/main/java/fr/xephi/authme/service/AntiBotService.java b/src/main/java/fr/xephi/authme/service/AntiBotService.java index 6fd3d8fa8..a1ecf71fc 100644 --- a/src/main/java/fr/xephi/authme/service/AntiBotService.java +++ b/src/main/java/fr/xephi/authme/service/AntiBotService.java @@ -7,15 +7,14 @@ import fr.xephi.authme.permission.AdminPermission; import fr.xephi.authme.permission.PermissionsManager; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.ProtectionSettings; -import fr.xephi.authme.util.BukkitService; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitTask; import javax.inject.Inject; import java.util.concurrent.CopyOnWriteArrayList; -import static fr.xephi.authme.util.BukkitService.TICKS_PER_MINUTE; -import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND; +import static fr.xephi.authme.service.BukkitService.TICKS_PER_MINUTE; +import static fr.xephi.authme.service.BukkitService.TICKS_PER_SECOND; /** * The AntiBot Service Management class. diff --git a/src/main/java/fr/xephi/authme/PerformBackup.java b/src/main/java/fr/xephi/authme/service/BackupService.java similarity index 97% rename from src/main/java/fr/xephi/authme/PerformBackup.java rename to src/main/java/fr/xephi/authme/service/BackupService.java index ab2d72db9..b5dfa06d3 100644 --- a/src/main/java/fr/xephi/authme/PerformBackup.java +++ b/src/main/java/fr/xephi/authme/service/BackupService.java @@ -1,5 +1,7 @@ -package fr.xephi.authme; +package fr.xephi.authme.service; +import fr.xephi.authme.AuthMe; +import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.datasource.DataSourceType; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.BackupSettings; @@ -19,7 +21,7 @@ import java.util.Date; * * @author stefano */ -public class PerformBackup { +public class BackupService { private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH-mm"); @@ -37,7 +39,7 @@ public class PerformBackup { * @param instance AuthMe * @param settings The plugin settings */ - public PerformBackup(AuthMe instance, Settings settings) { + public BackupService(AuthMe instance, Settings settings) { this.dataFolder = instance.getDataFolder(); this.settings = settings; this.dbName = settings.getProperty(DatabaseSettings.MYSQL_DATABASE); diff --git a/src/main/java/fr/xephi/authme/util/BukkitService.java b/src/main/java/fr/xephi/authme/service/BukkitService.java similarity index 99% rename from src/main/java/fr/xephi/authme/util/BukkitService.java rename to src/main/java/fr/xephi/authme/service/BukkitService.java index 72bdacf7a..cd5595fff 100644 --- a/src/main/java/fr/xephi/authme/util/BukkitService.java +++ b/src/main/java/fr/xephi/authme/service/BukkitService.java @@ -1,4 +1,4 @@ -package fr.xephi.authme.util; +package fr.xephi.authme.service; import fr.xephi.authme.AuthMe; import fr.xephi.authme.ConsoleLogger; diff --git a/src/main/java/fr/xephi/authme/util/MigrationService.java b/src/main/java/fr/xephi/authme/service/MigrationService.java similarity index 99% rename from src/main/java/fr/xephi/authme/util/MigrationService.java rename to src/main/java/fr/xephi/authme/service/MigrationService.java index 7b0a32d0a..f21bb8539 100644 --- a/src/main/java/fr/xephi/authme/util/MigrationService.java +++ b/src/main/java/fr/xephi/authme/service/MigrationService.java @@ -1,4 +1,4 @@ -package fr.xephi.authme.util; +package fr.xephi.authme.service; import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.cache.auth.PlayerAuth; diff --git a/src/main/java/fr/xephi/authme/service/RecoveryCodeManager.java b/src/main/java/fr/xephi/authme/service/RecoveryCodeService.java similarity index 96% rename from src/main/java/fr/xephi/authme/service/RecoveryCodeManager.java rename to src/main/java/fr/xephi/authme/service/RecoveryCodeService.java index e37d22733..5f5dd746b 100644 --- a/src/main/java/fr/xephi/authme/service/RecoveryCodeManager.java +++ b/src/main/java/fr/xephi/authme/service/RecoveryCodeService.java @@ -16,7 +16,7 @@ import static fr.xephi.authme.util.Utils.MILLIS_PER_HOUR; /** * Manager for recovery codes. */ -public class RecoveryCodeManager implements SettingsDependent { +public class RecoveryCodeService implements SettingsDependent { private Map recoveryCodes = new ConcurrentHashMap<>(); @@ -24,7 +24,7 @@ public class RecoveryCodeManager implements SettingsDependent { private long recoveryCodeExpirationMillis; @Inject - RecoveryCodeManager(Settings settings) { + RecoveryCodeService(Settings settings) { reload(settings); } diff --git a/src/main/java/fr/xephi/authme/util/TeleportationService.java b/src/main/java/fr/xephi/authme/service/TeleportationService.java similarity index 99% rename from src/main/java/fr/xephi/authme/util/TeleportationService.java rename to src/main/java/fr/xephi/authme/service/TeleportationService.java index b35535158..92f1c93a3 100644 --- a/src/main/java/fr/xephi/authme/util/TeleportationService.java +++ b/src/main/java/fr/xephi/authme/service/TeleportationService.java @@ -1,4 +1,4 @@ -package fr.xephi.authme.util; +package fr.xephi.authme.service; import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerCache; diff --git a/src/main/java/fr/xephi/authme/util/ValidationService.java b/src/main/java/fr/xephi/authme/service/ValidationService.java similarity index 98% rename from src/main/java/fr/xephi/authme/util/ValidationService.java rename to src/main/java/fr/xephi/authme/service/ValidationService.java index 7225c1e09..63227823d 100644 --- a/src/main/java/fr/xephi/authme/util/ValidationService.java +++ b/src/main/java/fr/xephi/authme/service/ValidationService.java @@ -1,7 +1,8 @@ -package fr.xephi.authme.util; +package fr.xephi.authme.service; import com.github.authme.configme.properties.Property; import fr.xephi.authme.datasource.DataSource; +import fr.xephi.authme.geoip.GeoLiteAPI; import fr.xephi.authme.initialization.Reloadable; import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.permission.PermissionsManager; @@ -11,6 +12,8 @@ import fr.xephi.authme.settings.properties.EmailSettings; import fr.xephi.authme.settings.properties.ProtectionSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.settings.properties.SecuritySettings; +import fr.xephi.authme.util.CollectionUtils; +import fr.xephi.authme.util.Utils; import org.bukkit.command.CommandSender; import javax.annotation.PostConstruct; diff --git a/src/main/java/fr/xephi/authme/task/MessageTask.java b/src/main/java/fr/xephi/authme/task/MessageTask.java index 7282bc659..1ae0aaed2 100644 --- a/src/main/java/fr/xephi/authme/task/MessageTask.java +++ b/src/main/java/fr/xephi/authme/task/MessageTask.java @@ -2,11 +2,11 @@ package fr.xephi.authme.task; import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.limbo.LimboCache; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitTask; -import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND; +import static fr.xephi.authme.service.BukkitService.TICKS_PER_SECOND; /** * Message shown to a player in a regular interval as long as he is not logged in. diff --git a/src/main/java/fr/xephi/authme/task/PlayerDataTaskManager.java b/src/main/java/fr/xephi/authme/task/PlayerDataTaskManager.java index b4e1846d2..b57141457 100644 --- a/src/main/java/fr/xephi/authme/task/PlayerDataTaskManager.java +++ b/src/main/java/fr/xephi/authme/task/PlayerDataTaskManager.java @@ -9,13 +9,13 @@ import fr.xephi.authme.output.Messages; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitTask; import javax.inject.Inject; -import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND; +import static fr.xephi.authme.service.BukkitService.TICKS_PER_SECOND; /** * Registers tasks associated with a PlayerData. diff --git a/src/main/java/fr/xephi/authme/task/purge/PurgeExecutor.java b/src/main/java/fr/xephi/authme/task/purge/PurgeExecutor.java index 2fb65fdd2..dcadc49b8 100644 --- a/src/main/java/fr/xephi/authme/task/purge/PurgeExecutor.java +++ b/src/main/java/fr/xephi/authme/task/purge/PurgeExecutor.java @@ -6,8 +6,8 @@ import fr.xephi.authme.hooks.PluginHooks; import fr.xephi.authme.permission.PermissionsManager; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.PurgeSettings; -import fr.xephi.authme.util.BukkitService; -import fr.xephi.authme.util.Utils; +import fr.xephi.authme.service.BukkitService; +import fr.xephi.authme.util.PlayerUtils; import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.Server; @@ -152,7 +152,7 @@ class PurgeExecutor { , makePath(settings.getProperty(PurgeSettings.DEFAULT_WORLD), "players")); for (OfflinePlayer offlinePlayer : cleared) { - File playerFile = new File(dataFolder, Utils.getUUIDorName(offlinePlayer) + ".dat"); + File playerFile = new File(dataFolder, PlayerUtils.getUUIDorName(offlinePlayer) + ".dat"); if (playerFile.delete()) { i++; } @@ -184,7 +184,7 @@ class PurgeExecutor { } for (OfflinePlayer offlinePlayer : cleared) { - File playerFile = new File(userDataFolder, Utils.getUUIDorName(offlinePlayer) + ".yml"); + File playerFile = new File(userDataFolder, PlayerUtils.getUUIDorName(offlinePlayer) + ".yml"); if (playerFile.exists() && playerFile.delete()) { i++; } diff --git a/src/main/java/fr/xephi/authme/task/purge/PurgeService.java b/src/main/java/fr/xephi/authme/task/purge/PurgeService.java index ee4370f88..040d2a893 100644 --- a/src/main/java/fr/xephi/authme/task/purge/PurgeService.java +++ b/src/main/java/fr/xephi/authme/task/purge/PurgeService.java @@ -5,7 +5,7 @@ import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.permission.PermissionsManager; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.PurgeSettings; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.util.CollectionUtils; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; diff --git a/src/main/java/fr/xephi/authme/util/CollectionUtils.java b/src/main/java/fr/xephi/authme/util/CollectionUtils.java index 9644c6cdc..2388fc608 100644 --- a/src/main/java/fr/xephi/authme/util/CollectionUtils.java +++ b/src/main/java/fr/xephi/authme/util/CollectionUtils.java @@ -9,6 +9,7 @@ import java.util.List; */ public final class CollectionUtils { + // Utility class private CollectionUtils() { } diff --git a/src/main/java/fr/xephi/authme/util/FileUtils.java b/src/main/java/fr/xephi/authme/util/FileUtils.java index d420ef0d5..faf557f47 100644 --- a/src/main/java/fr/xephi/authme/util/FileUtils.java +++ b/src/main/java/fr/xephi/authme/util/FileUtils.java @@ -15,6 +15,7 @@ import static java.lang.String.format; */ public final class FileUtils { + // Utility class private FileUtils() { } diff --git a/src/main/java/fr/xephi/authme/util/PlayerUtils.java b/src/main/java/fr/xephi/authme/util/PlayerUtils.java new file mode 100644 index 000000000..7c7302eb8 --- /dev/null +++ b/src/main/java/fr/xephi/authme/util/PlayerUtils.java @@ -0,0 +1,42 @@ +package fr.xephi.authme.util; + +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; + +/** + * Player utilities. + */ +public class PlayerUtils { + + // Utility class + private PlayerUtils() { + } + + /** + * Get player's UUID if can, name otherwise. + * + * @param player Player to retrieve + * + * @return player's UUID or Name in String. + */ + public static String getUUIDorName(OfflinePlayer player) { + // We may made this configurable in future + // so we can have uuid support. + try { + return player.getUniqueId().toString(); + } catch (NoSuchMethodError ignore) { + return player.getName(); + } + } + + /** + * Returns the IP of the given player. + * + * @param p The player to return the IP address for + * + * @return The player's IP address + */ + public static String getPlayerIp(Player p) { + return p.getAddress().getAddress().getHostAddress(); + } +} diff --git a/src/main/java/fr/xephi/authme/util/RuntimeUtils.java b/src/main/java/fr/xephi/authme/util/RuntimeUtils.java index af7fa3a34..6af0c4576 100644 --- a/src/main/java/fr/xephi/authme/util/RuntimeUtils.java +++ b/src/main/java/fr/xephi/authme/util/RuntimeUtils.java @@ -1,6 +1,19 @@ package fr.xephi.authme.util; +/** + * Runtime utilities. + */ public class RuntimeUtils { + + // Utility class + private RuntimeUtils() { + } + + /** + * Return the available core count of the JVM. + * + * @return the core count + */ public static int getCoreCount() { return Runtime.getRuntime().availableProcessors(); } diff --git a/src/main/java/fr/xephi/authme/util/StringUtils.java b/src/main/java/fr/xephi/authme/util/StringUtils.java index a02418ca9..d26a281fb 100644 --- a/src/main/java/fr/xephi/authme/util/StringUtils.java +++ b/src/main/java/fr/xephi/authme/util/StringUtils.java @@ -11,8 +11,8 @@ import java.io.File; */ public final class StringUtils { + // Utility class private StringUtils() { - // Utility class } /** diff --git a/src/main/java/fr/xephi/authme/util/Utils.java b/src/main/java/fr/xephi/authme/util/Utils.java index 3a7040d17..f15d77c8e 100644 --- a/src/main/java/fr/xephi/authme/util/Utils.java +++ b/src/main/java/fr/xephi/authme/util/Utils.java @@ -16,26 +16,10 @@ public final class Utils { /** Number of milliseconds in an hour. */ public static final long MILLIS_PER_HOUR = 60 * MILLIS_PER_MINUTE; + // Utility class private Utils() { } - /** - * Get player's UUID if can, name otherwise. - * - * @param player Player to retrieve - * - * @return player's UUID or Name in String. - */ - public static String getUUIDorName(OfflinePlayer player) { - // We may made this configurable in future - // so we can have uuid support. - try { - return player.getUniqueId().toString(); - } catch (NoSuchMethodError ignore) { - return player.getName(); - } - } - /** * Compile Pattern sneaky without throwing Exception. * @@ -52,17 +36,6 @@ public final class Utils { } } - /** - * Returns the IP of the given player. - * - * @param p The player to return the IP address for - * - * @return The player's IP address - */ - public static String getPlayerIp(Player p) { - return p.getAddress().getAddress().getHostAddress(); - } - /** * Returns whether the class exists in the current class loader. * diff --git a/src/test/java/fr/xephi/authme/AuthMeInitializationTest.java b/src/test/java/fr/xephi/authme/AuthMeInitializationTest.java index d20424a06..fc504f439 100644 --- a/src/test/java/fr/xephi/authme/AuthMeInitializationTest.java +++ b/src/test/java/fr/xephi/authme/AuthMeInitializationTest.java @@ -15,7 +15,7 @@ import fr.xephi.authme.process.login.ProcessSyncPlayerLogin; import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.task.purge.PurgeService; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.Bukkit; import org.bukkit.Server; import org.bukkit.plugin.PluginDescriptionFile; diff --git a/src/test/java/fr/xephi/authme/TestHelper.java b/src/test/java/fr/xephi/authme/TestHelper.java index c8d4803ec..d16bd31f7 100644 --- a/src/test/java/fr/xephi/authme/TestHelper.java +++ b/src/test/java/fr/xephi/authme/TestHelper.java @@ -1,6 +1,6 @@ package fr.xephi.authme; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.entity.Player; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; diff --git a/src/test/java/fr/xephi/authme/api/NewAPITest.java b/src/test/java/fr/xephi/authme/api/NewAPITest.java index 5ec009c02..7d915018b 100644 --- a/src/test/java/fr/xephi/authme/api/NewAPITest.java +++ b/src/test/java/fr/xephi/authme/api/NewAPITest.java @@ -8,7 +8,7 @@ import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.hooks.PluginHooks; import fr.xephi.authme.process.Management; import fr.xephi.authme.security.PasswordSecurity; -import fr.xephi.authme.util.ValidationService; +import fr.xephi.authme.service.ValidationService; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Server; diff --git a/src/test/java/fr/xephi/authme/cache/TempbanManagerTest.java b/src/test/java/fr/xephi/authme/cache/TempbanManagerTest.java index f487a97f6..bd4cfc04c 100644 --- a/src/test/java/fr/xephi/authme/cache/TempbanManagerTest.java +++ b/src/test/java/fr/xephi/authme/cache/TempbanManagerTest.java @@ -7,7 +7,7 @@ import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.output.Messages; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.SecuritySettings; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.entity.Player; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/fr/xephi/authme/cache/backup/PlayerDataStorageTest.java b/src/test/java/fr/xephi/authme/cache/backup/PlayerDataStorageTest.java index 3480b7d52..288f47710 100644 --- a/src/test/java/fr/xephi/authme/cache/backup/PlayerDataStorageTest.java +++ b/src/test/java/fr/xephi/authme/cache/backup/PlayerDataStorageTest.java @@ -8,7 +8,7 @@ import fr.xephi.authme.cache.limbo.PlayerData; import fr.xephi.authme.initialization.DataFolder; import fr.xephi.authme.permission.PermissionsManager; import fr.xephi.authme.settings.SpawnLoader; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.util.StringUtils; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/test/java/fr/xephi/authme/command/CommandServiceTest.java b/src/test/java/fr/xephi/authme/command/CommandServiceTest.java index 07c8a2898..cbdfc8f02 100644 --- a/src/test/java/fr/xephi/authme/command/CommandServiceTest.java +++ b/src/test/java/fr/xephi/authme/command/CommandServiceTest.java @@ -5,7 +5,7 @@ import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.output.Messages; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.SecuritySettings; -import fr.xephi.authme.util.ValidationService; +import fr.xephi.authme.service.ValidationService; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.junit.Test; diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/AccountsCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/AccountsCommandTest.java index 096157516..09405e079 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/AccountsCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/AccountsCommandTest.java @@ -4,7 +4,7 @@ import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.command.CommandService; import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.output.MessageKey; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.command.CommandSender; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/ChangePasswordAdminCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/ChangePasswordAdminCommandTest.java index a44cd6bc9..14df46d9e 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/ChangePasswordAdminCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/ChangePasswordAdminCommandTest.java @@ -8,9 +8,9 @@ import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.crypts.HashedPassword; -import fr.xephi.authme.util.BukkitService; -import fr.xephi.authme.util.ValidationService; -import fr.xephi.authme.util.ValidationService.ValidationResult; +import fr.xephi.authme.service.BukkitService; +import fr.xephi.authme.service.ValidationService; +import fr.xephi.authme.service.ValidationService.ValidationResult; import org.bukkit.command.CommandSender; import org.junit.BeforeClass; import org.junit.Test; diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/ConverterCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/ConverterCommandTest.java index a978833a4..e5035c450 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/ConverterCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/ConverterCommandTest.java @@ -5,7 +5,7 @@ import fr.xephi.authme.TestHelper; import fr.xephi.authme.command.CommandService; import fr.xephi.authme.converter.Converter; import fr.xephi.authme.output.MessageKey; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.util.StringUtils; import org.bukkit.command.CommandSender; import org.junit.BeforeClass; diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/ForceLoginCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/ForceLoginCommandTest.java index bc7fdec0f..fc2602bb4 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/ForceLoginCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/ForceLoginCommandTest.java @@ -3,7 +3,7 @@ package fr.xephi.authme.command.executable.authme; import fr.xephi.authme.permission.PermissionsManager; import fr.xephi.authme.permission.PlayerPermission; import fr.xephi.authme.process.Management; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.junit.Test; diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/GetIpCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/GetIpCommandTest.java index 65ed998a7..75d8953a0 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/GetIpCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/GetIpCommandTest.java @@ -1,7 +1,7 @@ package fr.xephi.authme.command.executable.authme; import fr.xephi.authme.TestHelper; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.junit.Test; diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/PurgeBannedPlayersCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/PurgeBannedPlayersCommandTest.java index 01d9c89d9..1927854ec 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/PurgeBannedPlayersCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/PurgeBannedPlayersCommandTest.java @@ -1,7 +1,7 @@ package fr.xephi.authme.command.executable.authme; import fr.xephi.authme.task.purge.PurgeService; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import org.junit.Test; diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommandTest.java index c71572296..49ea28ac8 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommandTest.java @@ -8,9 +8,9 @@ import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.crypts.HashedPassword; -import fr.xephi.authme.util.BukkitService; -import fr.xephi.authme.util.ValidationService; -import fr.xephi.authme.util.ValidationService.ValidationResult; +import fr.xephi.authme.service.BukkitService; +import fr.xephi.authme.service.ValidationService; +import fr.xephi.authme.service.ValidationService.ValidationResult; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.junit.BeforeClass; diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/SetEmailCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/SetEmailCommandTest.java index 7a07d8c8a..705302829 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/SetEmailCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/SetEmailCommandTest.java @@ -5,7 +5,7 @@ import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.command.CommandService; import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.output.MessageKey; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.command.CommandSender; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/UnregisterAdminCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/UnregisterAdminCommandTest.java index aea73ed71..e9cfbbabd 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/UnregisterAdminCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/UnregisterAdminCommandTest.java @@ -4,7 +4,7 @@ import fr.xephi.authme.command.CommandService; import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.process.Management; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.junit.Test; diff --git a/src/test/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommandTest.java index 3a67bd77e..a3d5a8ae0 100644 --- a/src/test/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommandTest.java @@ -6,8 +6,8 @@ import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.process.Management; import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.settings.properties.SecuritySettings; -import fr.xephi.authme.util.ValidationService; -import fr.xephi.authme.util.ValidationService.ValidationResult; +import fr.xephi.authme.service.ValidationService; +import fr.xephi.authme.service.ValidationService.ValidationResult; import org.bukkit.command.BlockCommandSender; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/test/java/fr/xephi/authme/command/executable/email/RecoverEmailCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/email/RecoverEmailCommandTest.java index 14d2cc62b..cb615d913 100644 --- a/src/test/java/fr/xephi/authme/command/executable/email/RecoverEmailCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/email/RecoverEmailCommandTest.java @@ -9,7 +9,7 @@ import fr.xephi.authme.mail.SendMailSSL; import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.crypts.HashedPassword; -import fr.xephi.authme.service.RecoveryCodeManager; +import fr.xephi.authme.service.RecoveryCodeService; import fr.xephi.authme.settings.properties.EmailSettings; import fr.xephi.authme.settings.properties.SecuritySettings; import org.bukkit.entity.Player; @@ -63,7 +63,7 @@ public class RecoverEmailCommandTest { private SendMailSSL sendMailSsl; @Mock - private RecoveryCodeManager recoveryCodeManager; + private RecoveryCodeService recoveryCodeService; @BeforeClass public static void initLogger() { @@ -177,8 +177,8 @@ public class RecoverEmailCommandTest { int hoursValid = 12; given(commandService.getProperty(SecuritySettings.RECOVERY_CODE_HOURS_VALID)).willReturn(hoursValid); String code = "a94f37"; - given(recoveryCodeManager.isRecoveryCodeNeeded()).willReturn(true); - given(recoveryCodeManager.generateCode(name)).willReturn(code); + given(recoveryCodeService.isRecoveryCodeNeeded()).willReturn(true); + given(recoveryCodeService.generateCode(name)).willReturn(code); // when command.executeCommand(sender, Collections.singletonList(email.toUpperCase())); @@ -186,7 +186,7 @@ public class RecoverEmailCommandTest { // then verify(sendMailSsl).hasAllInformation(); verify(dataSource).getAuth(name); - verify(recoveryCodeManager).generateCode(name); + verify(recoveryCodeService).generateCode(name); verify(commandService).send(sender, MessageKey.RECOVERY_CODE_SENT); verify(sendMailSsl).sendRecoveryCode(name, email, code); } @@ -203,8 +203,8 @@ public class RecoverEmailCommandTest { PlayerAuth auth = newAuthWithEmail(email); given(dataSource.getAuth(name)).willReturn(auth); given(commandService.getProperty(EmailSettings.RECOVERY_PASSWORD_LENGTH)).willReturn(20); - given(recoveryCodeManager.isRecoveryCodeNeeded()).willReturn(true); - given(recoveryCodeManager.isCodeValid(name, "bogus")).willReturn(false); + given(recoveryCodeService.isRecoveryCodeNeeded()).willReturn(true); + given(recoveryCodeService.isCodeValid(name, "bogus")).willReturn(false); // when command.executeCommand(sender, Arrays.asList(email, "bogus")); @@ -231,8 +231,8 @@ public class RecoverEmailCommandTest { given(commandService.getProperty(EmailSettings.RECOVERY_PASSWORD_LENGTH)).willReturn(20); given(passwordSecurity.computeHash(anyString(), eq(name))) .willAnswer(invocation -> new HashedPassword((String) invocation.getArguments()[0])); - given(recoveryCodeManager.isRecoveryCodeNeeded()).willReturn(true); - given(recoveryCodeManager.isCodeValid(name, code)).willReturn(true); + given(recoveryCodeService.isRecoveryCodeNeeded()).willReturn(true); + given(recoveryCodeService.isCodeValid(name, code)).willReturn(true); // when command.executeCommand(sender, Arrays.asList(email, code)); @@ -245,7 +245,7 @@ public class RecoverEmailCommandTest { String generatedPassword = passwordCaptor.getValue(); assertThat(generatedPassword, stringWithLength(20)); verify(dataSource).updatePassword(eq(name), any(HashedPassword.class)); - verify(recoveryCodeManager).removeCode(name); + verify(recoveryCodeService).removeCode(name); verify(sendMailSsl).sendPasswordMail(name, email, generatedPassword); verify(commandService).send(sender, MessageKey.RECOVERY_EMAIL_SENT_MESSAGE); } @@ -264,7 +264,7 @@ public class RecoverEmailCommandTest { given(commandService.getProperty(EmailSettings.RECOVERY_PASSWORD_LENGTH)).willReturn(20); given(passwordSecurity.computeHash(anyString(), eq(name))) .willAnswer(invocation -> new HashedPassword((String) invocation.getArguments()[0])); - given(recoveryCodeManager.isRecoveryCodeNeeded()).willReturn(false); + given(recoveryCodeService.isRecoveryCodeNeeded()).willReturn(false); // when command.executeCommand(sender, Collections.singletonList(email)); diff --git a/src/test/java/fr/xephi/authme/util/GeoLiteAPITest.java b/src/test/java/fr/xephi/authme/geoip/GeoIpManagerTest.java similarity index 96% rename from src/test/java/fr/xephi/authme/util/GeoLiteAPITest.java rename to src/test/java/fr/xephi/authme/geoip/GeoIpManagerTest.java index c932ddbb8..547cf3e70 100644 --- a/src/test/java/fr/xephi/authme/util/GeoLiteAPITest.java +++ b/src/test/java/fr/xephi/authme/geoip/GeoIpManagerTest.java @@ -1,7 +1,8 @@ -package fr.xephi.authme.util; +package fr.xephi.authme.geoip; import com.maxmind.geoip.Country; import com.maxmind.geoip.LookupService; +import fr.xephi.authme.geoip.GeoLiteAPI; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -25,7 +26,7 @@ import static org.mockito.Mockito.verify; * Test for {@link GeoLiteAPI}. */ @RunWith(MockitoJUnitRunner.class) -public class GeoLiteAPITest { +public class GeoIpManagerTest { private GeoLiteAPI geoLiteApi; private File dataFolder; diff --git a/src/test/java/fr/xephi/authme/listener/ListenerServiceTest.java b/src/test/java/fr/xephi/authme/listener/ListenerServiceTest.java index bc78db2f3..7ff0202f1 100644 --- a/src/test/java/fr/xephi/authme/listener/ListenerServiceTest.java +++ b/src/test/java/fr/xephi/authme/listener/ListenerServiceTest.java @@ -8,7 +8,7 @@ import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.hooks.PluginHooks; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.RegistrationSettings; -import fr.xephi.authme.util.ValidationService; +import fr.xephi.authme.service.ValidationService; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; diff --git a/src/test/java/fr/xephi/authme/listener/OnJoinVerifierTest.java b/src/test/java/fr/xephi/authme/listener/OnJoinVerifierTest.java index 66ddb673b..db6da711e 100644 --- a/src/test/java/fr/xephi/authme/listener/OnJoinVerifierTest.java +++ b/src/test/java/fr/xephi/authme/listener/OnJoinVerifierTest.java @@ -12,8 +12,8 @@ import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.ProtectionSettings; import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; -import fr.xephi.authme.util.BukkitService; -import fr.xephi.authme.util.ValidationService; +import fr.xephi.authme.service.BukkitService; +import fr.xephi.authme.service.ValidationService; import org.bukkit.Server; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerLoginEvent; diff --git a/src/test/java/fr/xephi/authme/listener/PlayerListenerTest.java b/src/test/java/fr/xephi/authme/listener/PlayerListenerTest.java index f9efc830a..d269726c8 100644 --- a/src/test/java/fr/xephi/authme/listener/PlayerListenerTest.java +++ b/src/test/java/fr/xephi/authme/listener/PlayerListenerTest.java @@ -10,9 +10,9 @@ import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.SpawnLoader; import fr.xephi.authme.settings.properties.HooksSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; -import fr.xephi.authme.util.BukkitService; -import fr.xephi.authme.util.TeleportationService; -import fr.xephi.authme.util.ValidationService; +import fr.xephi.authme.service.BukkitService; +import fr.xephi.authme.service.TeleportationService; +import fr.xephi.authme.service.ValidationService; import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.World; diff --git a/src/test/java/fr/xephi/authme/process/ProcessServiceTest.java b/src/test/java/fr/xephi/authme/process/ProcessServiceTest.java index a1196c4d2..3e6ed8520 100644 --- a/src/test/java/fr/xephi/authme/process/ProcessServiceTest.java +++ b/src/test/java/fr/xephi/authme/process/ProcessServiceTest.java @@ -9,7 +9,7 @@ import fr.xephi.authme.permission.PermissionsManager; import fr.xephi.authme.permission.PlayerPermission; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.SecuritySettings; -import fr.xephi.authme.util.ValidationService; +import fr.xephi.authme.service.ValidationService; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.junit.Test; diff --git a/src/test/java/fr/xephi/authme/process/login/AsynchronousLoginTest.java b/src/test/java/fr/xephi/authme/process/login/AsynchronousLoginTest.java index 2171bef20..b3dd38cf1 100644 --- a/src/test/java/fr/xephi/authme/process/login/AsynchronousLoginTest.java +++ b/src/test/java/fr/xephi/authme/process/login/AsynchronousLoginTest.java @@ -14,7 +14,7 @@ import fr.xephi.authme.settings.properties.HooksSettings; import fr.xephi.authme.settings.properties.PluginSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.task.PlayerDataTaskManager; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.entity.Player; import org.junit.BeforeClass; import org.junit.Test; diff --git a/src/test/java/fr/xephi/authme/process/unregister/AsynchronousUnregisterTest.java b/src/test/java/fr/xephi/authme/process/unregister/AsynchronousUnregisterTest.java index c77d4d3cf..24724768f 100644 --- a/src/test/java/fr/xephi/authme/process/unregister/AsynchronousUnregisterTest.java +++ b/src/test/java/fr/xephi/authme/process/unregister/AsynchronousUnregisterTest.java @@ -14,8 +14,8 @@ import fr.xephi.authme.security.crypts.HashedPassword; import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.task.PlayerDataTaskManager; -import fr.xephi.authme.util.BukkitService; -import fr.xephi.authme.util.TeleportationService; +import fr.xephi.authme.service.BukkitService; +import fr.xephi.authme.service.TeleportationService; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.junit.BeforeClass; diff --git a/src/test/java/fr/xephi/authme/service/AntiBotServiceTest.java b/src/test/java/fr/xephi/authme/service/AntiBotServiceTest.java index b401a895f..ffe06b82a 100644 --- a/src/test/java/fr/xephi/authme/service/AntiBotServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/AntiBotServiceTest.java @@ -10,7 +10,6 @@ import fr.xephi.authme.permission.AdminPermission; import fr.xephi.authme.permission.PermissionsManager; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.ProtectionSettings; -import fr.xephi.authme.util.BukkitService; import org.bukkit.entity.Player; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/fr/xephi/authme/util/BukkitServiceTest.java b/src/test/java/fr/xephi/authme/service/BukkitServiceTest.java similarity index 98% rename from src/test/java/fr/xephi/authme/util/BukkitServiceTest.java rename to src/test/java/fr/xephi/authme/service/BukkitServiceTest.java index 37922e929..d43f3c530 100644 --- a/src/test/java/fr/xephi/authme/util/BukkitServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/BukkitServiceTest.java @@ -1,4 +1,4 @@ -package fr.xephi.authme.util; +package fr.xephi.authme.service; import fr.xephi.authme.AuthMe; import fr.xephi.authme.ReflectionTestUtils; diff --git a/src/test/java/fr/xephi/authme/util/MigrationServiceTest.java b/src/test/java/fr/xephi/authme/service/MigrationServiceTest.java similarity index 98% rename from src/test/java/fr/xephi/authme/util/MigrationServiceTest.java rename to src/test/java/fr/xephi/authme/service/MigrationServiceTest.java index 5a3f19ee0..aad9343d4 100644 --- a/src/test/java/fr/xephi/authme/util/MigrationServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/MigrationServiceTest.java @@ -1,4 +1,4 @@ -package fr.xephi.authme.util; +package fr.xephi.authme.service; import fr.xephi.authme.TestHelper; import fr.xephi.authme.cache.auth.PlayerAuth; @@ -6,6 +6,7 @@ import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.security.HashAlgorithm; import fr.xephi.authme.security.crypts.HashedPassword; import fr.xephi.authme.security.crypts.SHA256; +import fr.xephi.authme.service.MigrationService; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.SecuritySettings; import org.junit.BeforeClass; diff --git a/src/test/java/fr/xephi/authme/service/RecoveryCodeManagerTest.java b/src/test/java/fr/xephi/authme/service/RecoveryCodeServiceTest.java similarity index 73% rename from src/test/java/fr/xephi/authme/service/RecoveryCodeManagerTest.java rename to src/test/java/fr/xephi/authme/service/RecoveryCodeServiceTest.java index c606a743a..b06a01f82 100644 --- a/src/test/java/fr/xephi/authme/service/RecoveryCodeManagerTest.java +++ b/src/test/java/fr/xephi/authme/service/RecoveryCodeServiceTest.java @@ -4,7 +4,7 @@ import ch.jalu.injector.testing.BeforeInjecting; import ch.jalu.injector.testing.DelayedInjectionRunner; import ch.jalu.injector.testing.InjectDelayed; import fr.xephi.authme.ReflectionTestUtils; -import fr.xephi.authme.service.RecoveryCodeManager.ExpiringEntry; +import fr.xephi.authme.service.RecoveryCodeService.ExpiringEntry; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.SecuritySettings; import org.junit.Test; @@ -20,13 +20,13 @@ import static org.junit.Assert.assertThat; import static org.mockito.BDDMockito.given; /** - * Test for {@link RecoveryCodeManager}. + * Test for {@link RecoveryCodeService}. */ @RunWith(DelayedInjectionRunner.class) -public class RecoveryCodeManagerTest { +public class RecoveryCodeServiceTest { @InjectDelayed - private RecoveryCodeManager recoveryCodeManager; + private RecoveryCodeService recoveryCodeService; @Mock private Settings settings; @@ -39,16 +39,16 @@ public class RecoveryCodeManagerTest { @Test public void shouldBeDisabledForNonPositiveLength() { - assertThat(recoveryCodeManager.isRecoveryCodeNeeded(), equalTo(true)); + assertThat(recoveryCodeService.isRecoveryCodeNeeded(), equalTo(true)); // given given(settings.getProperty(SecuritySettings.RECOVERY_CODE_LENGTH)).willReturn(0); // when - recoveryCodeManager.reload(settings); + recoveryCodeService.reload(settings); // then - assertThat(recoveryCodeManager.isRecoveryCodeNeeded(), equalTo(false)); + assertThat(recoveryCodeService.isRecoveryCodeNeeded(), equalTo(false)); } @Test @@ -57,7 +57,7 @@ public class RecoveryCodeManagerTest { String name = "Bobbers"; // when - recoveryCodeManager.generateCode(name); + recoveryCodeService.generateCode(name); // then ExpiringEntry entry = getCodeMap().get(name); @@ -72,7 +72,7 @@ public class RecoveryCodeManagerTest { setCodeInMap(player, code, System.currentTimeMillis() - 500); // when - boolean result = recoveryCodeManager.isCodeValid(player, code); + boolean result = recoveryCodeService.isCodeValid(player, code); // then assertThat(result, equalTo(false)); @@ -82,10 +82,10 @@ public class RecoveryCodeManagerTest { public void shouldRecognizeCorrectCode() { // given String player = "dragon"; - String code = recoveryCodeManager.generateCode(player); + String code = recoveryCodeService.generateCode(player); // when - boolean result = recoveryCodeManager.isCodeValid(player, code); + boolean result = recoveryCodeService.isCodeValid(player, code); // then assertThat(result, equalTo(true)); @@ -95,19 +95,19 @@ public class RecoveryCodeManagerTest { public void shouldRemoveCode() { // given String player = "Tester"; - String code = recoveryCodeManager.generateCode(player); + String code = recoveryCodeService.generateCode(player); // when - recoveryCodeManager.removeCode(player); + recoveryCodeService.removeCode(player); // then - assertThat(recoveryCodeManager.isCodeValid(player, code), equalTo(false)); + assertThat(recoveryCodeService.isCodeValid(player, code), equalTo(false)); assertThat(getCodeMap().get(player), nullValue()); } private Map getCodeMap() { - return ReflectionTestUtils.getFieldValue(RecoveryCodeManager.class, recoveryCodeManager, "recoveryCodes"); + return ReflectionTestUtils.getFieldValue(RecoveryCodeService.class, recoveryCodeService, "recoveryCodes"); } private void setCodeInMap(String player, String code, long expiration) { diff --git a/src/test/java/fr/xephi/authme/util/TeleportationServiceTest.java b/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java similarity index 99% rename from src/test/java/fr/xephi/authme/util/TeleportationServiceTest.java rename to src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java index d3b0973f7..0a218a84d 100644 --- a/src/test/java/fr/xephi/authme/util/TeleportationServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java @@ -1,10 +1,12 @@ -package fr.xephi.authme.util; +package fr.xephi.authme.service; import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.limbo.PlayerData; import fr.xephi.authme.events.FirstSpawnTeleportEvent; import fr.xephi.authme.events.SpawnTeleportEvent; +import fr.xephi.authme.service.BukkitService; +import fr.xephi.authme.service.TeleportationService; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.SpawnLoader; import fr.xephi.authme.settings.properties.RestrictionSettings; diff --git a/src/test/java/fr/xephi/authme/util/ValidationServiceTest.java b/src/test/java/fr/xephi/authme/service/ValidationServiceTest.java similarity index 98% rename from src/test/java/fr/xephi/authme/util/ValidationServiceTest.java rename to src/test/java/fr/xephi/authme/service/ValidationServiceTest.java index b61f833db..2a85b131a 100644 --- a/src/test/java/fr/xephi/authme/util/ValidationServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/ValidationServiceTest.java @@ -1,19 +1,21 @@ -package fr.xephi.authme.util; +package fr.xephi.authme.service; import ch.jalu.injector.testing.BeforeInjecting; import ch.jalu.injector.testing.DelayedInjectionRunner; import ch.jalu.injector.testing.InjectDelayed; import com.google.common.base.Strings; import fr.xephi.authme.datasource.DataSource; +import fr.xephi.authme.geoip.GeoLiteAPI; import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.permission.PermissionsManager; import fr.xephi.authme.permission.PlayerStatePermission; +import fr.xephi.authme.service.ValidationService; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.EmailSettings; import fr.xephi.authme.settings.properties.ProtectionSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.settings.properties.SecuritySettings; -import fr.xephi.authme.util.ValidationService.ValidationResult; +import fr.xephi.authme.service.ValidationService.ValidationResult; import org.bukkit.command.CommandSender; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/fr/xephi/authme/task/PlayerDataTaskManagerTest.java b/src/test/java/fr/xephi/authme/task/PlayerDataTaskManagerTest.java index ab4d6ef92..93b552ca1 100644 --- a/src/test/java/fr/xephi/authme/task/PlayerDataTaskManagerTest.java +++ b/src/test/java/fr/xephi/authme/task/PlayerDataTaskManagerTest.java @@ -9,7 +9,7 @@ import fr.xephi.authme.output.Messages; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitTask; import org.junit.BeforeClass; diff --git a/src/test/java/fr/xephi/authme/task/purge/PurgeServiceTest.java b/src/test/java/fr/xephi/authme/task/purge/PurgeServiceTest.java index 3f626f4d1..d6fe5b574 100644 --- a/src/test/java/fr/xephi/authme/task/purge/PurgeServiceTest.java +++ b/src/test/java/fr/xephi/authme/task/purge/PurgeServiceTest.java @@ -6,7 +6,7 @@ import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.permission.PermissionsManager; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.PurgeSettings; -import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.service.BukkitService; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/test/java/fr/xephi/authme/util/PlayerUtilsTest.java b/src/test/java/fr/xephi/authme/util/PlayerUtilsTest.java new file mode 100644 index 000000000..444d0c497 --- /dev/null +++ b/src/test/java/fr/xephi/authme/util/PlayerUtilsTest.java @@ -0,0 +1,69 @@ +package fr.xephi.authme.util; + +import fr.xephi.authme.TestHelper; +import org.bukkit.entity.Player; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.UUID; +import java.util.regex.Pattern; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; + +/** + * Test for {@link Utils}. + */ +public class PlayerUtilsTest { + + @BeforeClass + public static void setAuthmeInstance() { + TestHelper.setupLogger(); + } + + @Test + public void shouldGetPlayerIp() { + // given + Player player = mock(Player.class); + String ip = "124.86.248.62"; + TestHelper.mockPlayerIp(player, ip); + + // when + String result = PlayerUtils.getPlayerIp(player); + + // then + assertThat(result, equalTo(ip)); + } + + @Test + public void shouldGetUuid() { + // given + UUID uuid = UUID.randomUUID(); + Player player = mock(Player.class); + given(player.getUniqueId()).willReturn(uuid); + + // when + String result = PlayerUtils.getUUIDorName(player); + + // then + assertThat(result, equalTo(uuid.toString())); + } + + @Test + public void shouldFallbackToName() { + // given + Player player = mock(Player.class); + doThrow(NoSuchMethodError.class).when(player).getUniqueId(); + String name = "Bobby12"; + given(player.getName()).willReturn(name); + + // when + String result = PlayerUtils.getUUIDorName(player); + + // then + assertThat(result, equalTo(name)); + } +} diff --git a/src/test/java/fr/xephi/authme/util/UtilsTest.java b/src/test/java/fr/xephi/authme/util/UtilsTest.java index 930a5db8a..458023d6d 100644 --- a/src/test/java/fr/xephi/authme/util/UtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/UtilsTest.java @@ -1,18 +1,13 @@ package fr.xephi.authme.util; import fr.xephi.authme.TestHelper; -import org.bukkit.entity.Player; import org.junit.BeforeClass; import org.junit.Test; -import java.util.UUID; import java.util.regex.Pattern; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; /** * Test for {@link Utils}. @@ -48,49 +43,6 @@ public class UtilsTest { assertThat(result.toString(), equalTo(".*?")); } - @Test - public void shouldGetPlayerIp() { - // given - Player player = mock(Player.class); - String ip = "124.86.248.62"; - TestHelper.mockPlayerIp(player, ip); - - // when - String result = Utils.getPlayerIp(player); - - // then - assertThat(result, equalTo(ip)); - } - - @Test - public void shouldGetUuid() { - // given - UUID uuid = UUID.randomUUID(); - Player player = mock(Player.class); - given(player.getUniqueId()).willReturn(uuid); - - // when - String result = Utils.getUUIDorName(player); - - // then - assertThat(result, equalTo(uuid.toString())); - } - - @Test - public void shouldFallbackToName() { - // given - Player player = mock(Player.class); - doThrow(NoSuchMethodError.class).when(player).getUniqueId(); - String name = "Bobby12"; - given(player.getName()).willReturn(name); - - // when - String result = Utils.getUUIDorName(player); - - // then - assertThat(result, equalTo(name)); - } - @Test public void shouldHavePrivateConstructorOnly() { // given / when / then