Various code householding

- Adjust javadoc
- Remove unused PlayerAuth constructor
- Replace legacy Settings with NewSetting calls
- Add process service to all (a)sync processes
- Change IP manager to only cache the calls to the VeryGames API
This commit is contained in:
ljacqu
2016-03-06 14:42:19 +01:00
parent 9a412fac05
commit 31bac6964f
25 changed files with 199 additions and 220 deletions
@@ -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.settings.Settings;
import fr.xephi.authme.settings.properties.PurgeSettings;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
@@ -15,7 +15,7 @@ public class PurgeBannedPlayersCommand implements ExecutableCommand {
@Override
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
// AuthMe plugin instance
final AuthMe plugin = AuthMe.getInstance();
final AuthMe plugin = commandService.getAuthMe();
// Get the list of banned players
List<String> bannedPlayers = new ArrayList<>();
@@ -25,13 +25,13 @@ public class PurgeBannedPlayersCommand implements ExecutableCommand {
// Purge the banned players
plugin.getDataSource().purgeBanned(bannedPlayers);
if (Settings.purgeEssentialsFile && plugin.ess != null)
if (commandService.getProperty(PurgeSettings.REMOVE_ESSENTIALS_FILES) && plugin.ess != null)
plugin.dataManager.purgeEssentials(bannedPlayers);
if (Settings.purgePlayerDat)
if (commandService.getProperty(PurgeSettings.REMOVE_PLAYER_DAT))
plugin.dataManager.purgeDat(bannedPlayers);
if (Settings.purgeLimitedCreative)
if (commandService.getProperty(PurgeSettings.REMOVE_LIMITED_CREATIVE_INVENTORIES))
plugin.dataManager.purgeLimitedCreative(bannedPlayers);
if (Settings.purgeAntiXray)
if (commandService.getProperty(PurgeSettings.REMOVE_ANTI_XRAY_FILE))
plugin.dataManager.purgeAntiXray(bannedPlayers);
// Show a status message
@@ -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.settings.Settings;
import fr.xephi.authme.settings.properties.PurgeSettings;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
@@ -15,7 +15,7 @@ public class PurgeCommand implements ExecutableCommand {
@Override
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
// AuthMe plugin instance
AuthMe plugin = AuthMe.getInstance();
AuthMe plugin = commandService.getAuthMe();
// Get the days parameter
String daysStr = arguments.get(0);
@@ -47,13 +47,13 @@ public class PurgeCommand implements ExecutableCommand {
sender.sendMessage(ChatColor.GOLD + "Deleted " + purged.size() + " user accounts");
// Purge other data
if (Settings.purgeEssentialsFile && plugin.ess != null)
if (commandService.getProperty(PurgeSettings.REMOVE_ESSENTIALS_FILES) && plugin.ess != null)
plugin.dataManager.purgeEssentials(purged);
if (Settings.purgePlayerDat)
if (commandService.getProperty(PurgeSettings.REMOVE_PLAYER_DAT))
plugin.dataManager.purgeDat(purged);
if (Settings.purgeLimitedCreative)
if (commandService.getProperty(PurgeSettings.REMOVE_LIMITED_CREATIVE_INVENTORIES))
plugin.dataManager.purgeLimitedCreative(purged);
if (Settings.purgeAntiXray)
if (commandService.getProperty(PurgeSettings.REMOVE_ANTI_XRAY_FILE))
plugin.dataManager.purgeAntiXray(purged);
// Show a status message
@@ -8,6 +8,7 @@ import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.task.MessageTask;
import fr.xephi.authme.task.TimeoutTask;
import fr.xephi.authme.util.Utils;
@@ -66,7 +67,7 @@ public class UnregisterAdminCommand implements ExecutableCommand {
plugin, new MessageTask(plugin, playerNameLowerCase, MessageKey.REGISTER_MESSAGE, interval)
)
);
if (Settings.applyBlindEffect) {
if (commandService.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeOut, 2));
}
commandService.send(target, MessageKey.UNREGISTERED_SUCCESS);
@@ -3,15 +3,15 @@ package fr.xephi.authme.command.executable.authme;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.ExecutableCommand;
import static fr.xephi.authme.settings.properties.PluginSettings.HELP_HEADER;
import fr.xephi.authme.util.Utils;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.List;
import static fr.xephi.authme.settings.properties.PluginSettings.HELP_HEADER;
public class VersionCommand implements ExecutableCommand {
@Override
@@ -71,8 +71,6 @@ public class VersionCommand implements ExecutableCommand {
* @return True if the player is online, false otherwise.
*/
private static boolean isPlayerOnline(String minecraftName) {
// Note ljacqu 20151121: Generally you should use Utils#getOnlinePlayers to retrieve the list of online players.
// If it's only used in a for-each loop such as here, it's fine. For other purposes, go through the Utils class.
for (Player player : Utils.getOnlinePlayers()) {
if (player.getName().equalsIgnoreCase(minecraftName)) {
return true;
@@ -7,6 +7,7 @@ import fr.xephi.authme.process.Management;
import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.security.RandomString;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.util.Utils;
import org.bukkit.entity.Player;
@@ -17,7 +18,7 @@ public class RegisterCommand extends PlayerCommand {
@Override
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
if (Settings.getPasswordHash == HashAlgorithm.TWO_FACTOR) {
if (commandService.getProperty(SecuritySettings.PASSWORD_HASH) == HashAlgorithm.TWO_FACTOR) {
//for two factor auth we don't need to check the usage
commandService.getManagement().performRegister(player, "", "");
return;