#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
This commit is contained in:
ljacqu 2016-06-04 21:16:58 +02:00
parent 26ac466035
commit 91111ca476
3 changed files with 16 additions and 18 deletions

View File

@ -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));
}
}

View File

@ -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);
}
}
}

View File

@ -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 <playername> <password>";
}
private void handlePasswordRegistration(Player player, List<String> arguments, CommandService commandService) {
private void handlePasswordRegistration(Player player, List<String> 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<String> arguments, CommandService commandService) {
private void handleEmailRegistration(Player player, List<String> 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);