From 91111ca47658eef9663b8e29083825d97bd3bccd Mon Sep 17 00:00:00 2001 From: ljacqu Date: Sat, 4 Jun 2016 21:16:58 +0200 Subject: [PATCH] #727 Remove CommandService being passed as parameter to other methods - No longer need to pass as param to other methods since CommandService is now an injected field --- .../executable/authme/UnregisterAdminCommand.java | 11 +++++------ .../command/executable/captcha/CaptchaCommand.java | 10 +++++----- .../executable/register/RegisterCommand.java | 13 ++++++------- 3 files changed, 16 insertions(+), 18 deletions(-) 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 d81b9bafc..341666f06 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 @@ -72,7 +72,7 @@ public class UnregisterAdminCommand implements ExecutableCommand { Utils.setGroup(target, Utils.GroupType.UNREGISTERED); if (target != null && target.isOnline()) { if (commandService.getProperty(RegistrationSettings.FORCE)) { - applyUnregisteredEffectsAndTasks(target, commandService); + applyUnregisteredEffectsAndTasks(target); } commandService.send(target, MessageKey.UNREGISTERED_SUCCESS); } @@ -88,15 +88,14 @@ public class UnregisterAdminCommand implements ExecutableCommand { * timeout kick, blindness. * * @param target the player that was unregistered - * @param service the command service */ - private void applyUnregisteredEffectsAndTasks(Player target, CommandService service) { + private void applyUnregisteredEffectsAndTasks(Player target) { final String playerNameLowerCase = target.getName().toLowerCase(); Utils.teleportToSpawn(target); limboCache.addLimboPlayer(target); - int timeOut = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND; - int interval = service.getProperty(RegistrationSettings.MESSAGE_INTERVAL); + int timeOut = commandService.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND; + int interval = commandService.getProperty(RegistrationSettings.MESSAGE_INTERVAL); if (timeOut != 0) { BukkitTask id = bukkitService.runTaskLater(new TimeoutTask(authMe, playerNameLowerCase, target), timeOut); limboCache.getLimboPlayer(playerNameLowerCase).setTimeoutTask(id); @@ -105,7 +104,7 @@ public class UnregisterAdminCommand implements ExecutableCommand { bukkitService.runTask(new MessageTask(bukkitService, authMe.getMessages(), playerNameLowerCase, MessageKey.REGISTER_MESSAGE, interval))); - if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) { + if (commandService.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) { target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeOut, 2)); } } diff --git a/src/main/java/fr/xephi/authme/command/executable/captcha/CaptchaCommand.java b/src/main/java/fr/xephi/authme/command/executable/captcha/CaptchaCommand.java index 0cae9aa09..1577c7ad7 100644 --- a/src/main/java/fr/xephi/authme/command/executable/captcha/CaptchaCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/captcha/CaptchaCommand.java @@ -30,18 +30,18 @@ public class CaptchaCommand extends PlayerCommand { } else if (!captchaManager.isCaptchaRequired(playerName)) { commandService.send(player, MessageKey.USAGE_LOGIN); } else { - checkCaptcha(player, arguments.get(0), commandService); + checkCaptcha(player, arguments.get(0)); } } - private void checkCaptcha(Player player, String captchaCode, CommandService service) { + private void checkCaptcha(Player player, String captchaCode) { final boolean isCorrectCode = captchaManager.checkCode(player.getName(), captchaCode); if (isCorrectCode) { - service.send(player, MessageKey.CAPTCHA_SUCCESS); - service.send(player, MessageKey.LOGIN_MESSAGE); + commandService.send(player, MessageKey.CAPTCHA_SUCCESS); + commandService.send(player, MessageKey.LOGIN_MESSAGE); } else { String newCode = captchaManager.generateCode(player.getName()); - service.send(player, MessageKey.CAPTCHA_WRONG_ERROR, newCode); + commandService.send(player, MessageKey.CAPTCHA_WRONG_ERROR, newCode); } } } diff --git a/src/main/java/fr/xephi/authme/command/executable/register/RegisterCommand.java b/src/main/java/fr/xephi/authme/command/executable/register/RegisterCommand.java index f9a6d1655..ed9f9eef5 100644 --- a/src/main/java/fr/xephi/authme/command/executable/register/RegisterCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/register/RegisterCommand.java @@ -36,16 +36,16 @@ public class RegisterCommand extends PlayerCommand { } // Ensure that there is 1 argument, or 2 if confirmation is required - final boolean useConfirmation = isConfirmationRequired(commandService); + final boolean useConfirmation = isConfirmationRequired(); if (arguments.isEmpty() || useConfirmation && arguments.size() < 2) { commandService.send(player, MessageKey.USAGE_REGISTER); return; } if (commandService.getProperty(USE_EMAIL_REGISTRATION)) { - handleEmailRegistration(player, arguments, commandService); + handleEmailRegistration(player, arguments); } else { - handlePasswordRegistration(player, arguments, commandService); + handlePasswordRegistration(player, arguments); } } @@ -54,7 +54,7 @@ public class RegisterCommand extends PlayerCommand { return "/authme register "; } - private void handlePasswordRegistration(Player player, List arguments, CommandService commandService) { + private void handlePasswordRegistration(Player player, List arguments) { if (commandService.getProperty(ENABLE_PASSWORD_CONFIRMATION) && !arguments.get(0).equals(arguments.get(1))) { commandService.send(player, MessageKey.PASSWORD_MATCH_ERROR); } else { @@ -62,7 +62,7 @@ public class RegisterCommand extends PlayerCommand { } } - private void handleEmailRegistration(Player player, List arguments, CommandService commandService) { + private void handleEmailRegistration(Player player, List arguments) { if (commandService.getProperty(EmailSettings.MAIL_ACCOUNT).isEmpty()) { player.sendMessage("Cannot register: no email address is set for the server. " + "Please contact an administrator"); @@ -85,10 +85,9 @@ public class RegisterCommand extends PlayerCommand { /** * Return whether the password or email has to be confirmed. * - * @param commandService The command service * @return True if the confirmation is needed, false otherwise */ - private boolean isConfirmationRequired(CommandService commandService) { + private boolean isConfirmationRequired() { return commandService.getProperty(USE_EMAIL_REGISTRATION) ? commandService.getProperty(ENABLE_CONFIRM_EMAIL) : commandService.getProperty(ENABLE_PASSWORD_CONFIRMATION);