#432 Add field injection to AccountsCommand

This commit is contained in:
ljacqu
2016-04-27 22:59:44 +02:00
parent 02079f1f5c
commit 5963628fa6
7 changed files with 97 additions and 58 deletions
@@ -3,10 +3,13 @@ package fr.xephi.authme.command.executable.authme;
import fr.xephi.authme.cache.auth.PlayerAuth;
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.output.Messages;
import fr.xephi.authme.util.StringUtils;
import org.bukkit.command.CommandSender;
import javax.inject.Inject;
import java.util.List;
/**
@@ -14,6 +17,11 @@ import java.util.List;
*/
public class AccountsCommand implements ExecutableCommand {
@Inject
private DataSource dataSource;
@Inject
private Messages messages;
@Override
public void executeCommand(final CommandSender sender, List<String> arguments,
final CommandService commandService) {
@@ -24,15 +32,15 @@ public class AccountsCommand implements ExecutableCommand {
commandService.runTaskAsynchronously(new Runnable() {
@Override
public void run() {
PlayerAuth auth = commandService.getDataSource().getAuth(playerName.toLowerCase());
PlayerAuth auth = dataSource.getAuth(playerName.toLowerCase());
if (auth == null) {
commandService.send(sender, MessageKey.UNKNOWN_USER);
messages.send(sender, MessageKey.UNKNOWN_USER);
return;
}
List<String> accountList = commandService.getDataSource().getAllAuthsByIp(auth.getIp());
List<String> accountList = dataSource.getAllAuthsByIp(auth.getIp());
if (accountList.isEmpty()) {
commandService.send(sender, MessageKey.USER_NOT_REGISTERED);
messages.send(sender, MessageKey.USER_NOT_REGISTERED);
} else if (accountList.size() == 1) {
sender.sendMessage("[AuthMe] " + playerName + " is a single account player");
} else {
@@ -44,7 +52,7 @@ public class AccountsCommand implements ExecutableCommand {
commandService.runTaskAsynchronously(new Runnable() {
@Override
public void run() {
List<String> accountList = commandService.getDataSource().getAllAuthsByIp(playerName);
List<String> accountList = dataSource.getAllAuthsByIp(playerName);
if (accountList.isEmpty()) {
sender.sendMessage("[AuthMe] This IP does not exist in the database.");
} else if (accountList.size() == 1) {