#727 Remove CommandService from ExecutableCommand interface
(work in progress) - Inject CommandService like other classes instead of passing it as method parameter - Not solved: cyclic dependency CommandInitializer > ExecutableCommand > CommandService > CommandInitializer...
This commit is contained in:
@@ -23,17 +23,12 @@ public class CommandHandler {
|
||||
*/
|
||||
private static final double SUGGEST_COMMAND_THRESHOLD = 0.75;
|
||||
|
||||
private final CommandService commandService;
|
||||
private final PermissionsManager permissionsManager;
|
||||
|
||||
/*
|
||||
* Constructor.
|
||||
*/
|
||||
@Inject
|
||||
public CommandHandler(CommandService commandService, PermissionsManager permissionsManager) {
|
||||
this.commandService = commandService;
|
||||
this.permissionsManager = permissionsManager;
|
||||
}
|
||||
private CommandService commandService;
|
||||
|
||||
@Inject
|
||||
private PermissionsManager permissionsManager;
|
||||
|
||||
|
||||
/**
|
||||
* Map a command that was invoked to the proper {@link CommandDescription} or return a useful error
|
||||
@@ -86,7 +81,7 @@ public class CommandHandler {
|
||||
private void executeCommand(CommandSender sender, FoundCommandResult result) {
|
||||
ExecutableCommand executableCommand = result.getCommandDescription().getExecutableCommand();
|
||||
List<String> arguments = result.getArguments();
|
||||
executableCommand.executeCommand(sender, arguments, commandService);
|
||||
executableCommand.executeCommand(sender, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,12 +10,11 @@ import java.util.List;
|
||||
public interface ExecutableCommand {
|
||||
|
||||
/**
|
||||
* Execute the command with the given arguments.
|
||||
* Executes the command with the given arguments.
|
||||
*
|
||||
* @param sender The command sender.
|
||||
* @param arguments The arguments.
|
||||
* @param commandService The command service.
|
||||
* @param sender the command sender (initiator of the command)
|
||||
* @param arguments the arguments
|
||||
*/
|
||||
void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService);
|
||||
void executeCommand(CommandSender sender, List<String> arguments);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
package fr.xephi.authme.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Common base type for player-only commands, handling the verification that the command sender is indeed a player.
|
||||
*/
|
||||
public abstract class PlayerCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
if (sender instanceof Player) {
|
||||
runCommand((Player) sender, arguments, commandService);
|
||||
runCommand((Player) sender, arguments);
|
||||
} else {
|
||||
String alternative = getAlternativeCommand();
|
||||
if (alternative != null) {
|
||||
@@ -25,19 +25,18 @@ public abstract class PlayerCommand implements ExecutableCommand {
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the command with the given player and arguments.
|
||||
* Runs the command with the given player and arguments.
|
||||
*
|
||||
* @param player The player who initiated the command
|
||||
* @param arguments The arguments supplied with the command
|
||||
* @param commandService The command service
|
||||
* @param player the player who initiated the command
|
||||
* @param arguments the arguments supplied with the command
|
||||
*/
|
||||
protected abstract void runCommand(Player player, List<String> arguments, CommandService commandService);
|
||||
protected abstract void runCommand(Player player, List<String> arguments);
|
||||
|
||||
/**
|
||||
* Return an alternative command (textual representation) that is not restricted to players only.
|
||||
* Example: {@code "authme register <playerName> <password>"}
|
||||
* Returns an alternative command (textual representation) that is not restricted to players only.
|
||||
* Example: {@code "/authme register <playerName> <password>"}
|
||||
*
|
||||
* @return Alternative command not only for players, or null if not applicable
|
||||
* @return Alternative command not restricted to players, or null if not applicable
|
||||
*/
|
||||
protected String getAlternativeCommand() {
|
||||
return null;
|
||||
|
||||
@@ -9,6 +9,7 @@ import fr.xephi.authme.command.help.HelpProvider;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
|
||||
import static fr.xephi.authme.command.FoundResultStatus.MISSING_BASE_COMMAND;
|
||||
@@ -16,10 +17,14 @@ import static fr.xephi.authme.command.FoundResultStatus.UNKNOWN_LABEL;
|
||||
|
||||
public class HelpCommand implements ExecutableCommand {
|
||||
|
||||
@Inject
|
||||
private CommandService commandService;
|
||||
|
||||
|
||||
// Convention: arguments is not the actual invoked arguments but the command that was invoked,
|
||||
// e.g. "/authme help register" would typically be arguments = [register], but here we pass [authme, register]
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
FoundCommandResult result = commandService.mapPartsToCommand(sender, arguments);
|
||||
|
||||
FoundResultStatus resultStatus = result.getResultStatus();
|
||||
|
||||
@@ -23,9 +23,11 @@ public class AccountsCommand implements ExecutableCommand {
|
||||
@Inject
|
||||
private BukkitService bukkitService;
|
||||
|
||||
@Inject
|
||||
private CommandService commandService;
|
||||
|
||||
@Override
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments,
|
||||
final CommandService commandService) {
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||
final String playerName = arguments.isEmpty() ? sender.getName() : arguments.get(0);
|
||||
|
||||
// Assumption: a player name cannot contain '.'
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
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 org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -14,7 +13,7 @@ import java.util.List;
|
||||
public class AuthMeCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
sender.sendMessage(ChatColor.GREEN + "This server is running " + AuthMe.getPluginName() + " v"
|
||||
+ AuthMe.getPluginVersion() + " b" + AuthMe.getPluginBuildNumber()+ "! " + ChatColor.RED + "<3");
|
||||
sender.sendMessage(ChatColor.YELLOW + "Use the command " + ChatColor.GOLD + "/authme help" + ChatColor.YELLOW
|
||||
|
||||
+4
-2
@@ -37,9 +37,11 @@ public class ChangePasswordAdminCommand implements ExecutableCommand {
|
||||
@Inject
|
||||
private ValidationService validationService;
|
||||
|
||||
@Inject
|
||||
private CommandService commandService;
|
||||
|
||||
@Override
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments,
|
||||
final CommandService commandService) {
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||
// Get the player and password
|
||||
final String playerName = arguments.get(0);
|
||||
final String playerPass = arguments.get(1);
|
||||
|
||||
@@ -22,6 +22,9 @@ import java.util.List;
|
||||
*/
|
||||
public class ConverterCommand implements ExecutableCommand {
|
||||
|
||||
@Inject
|
||||
private CommandService commandService;
|
||||
|
||||
@Inject
|
||||
private BukkitService bukkitService;
|
||||
|
||||
@@ -29,7 +32,7 @@ public class ConverterCommand implements ExecutableCommand {
|
||||
private AuthMeServiceInitializer initializer;
|
||||
|
||||
@Override
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||
// Get the conversion job
|
||||
String job = arguments.get(0);
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.PlayerCommand;
|
||||
import fr.xephi.authme.settings.SpawnLoader;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -17,7 +16,7 @@ public class FirstSpawnCommand extends PlayerCommand {
|
||||
private SpawnLoader spawnLoader;
|
||||
|
||||
@Override
|
||||
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
|
||||
public void runCommand(Player player, List<String> arguments) {
|
||||
if (spawnLoader.getFirstSpawn() == null) {
|
||||
player.sendMessage("[AuthMe] First spawn has failed, please try to define the first spawn");
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.process.Management;
|
||||
@@ -28,7 +27,7 @@ public class ForceLoginCommand implements ExecutableCommand {
|
||||
private BukkitService bukkitService;
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
// Get the player query
|
||||
String playerName = arguments.isEmpty() ? sender.getName() : arguments.get(0);
|
||||
|
||||
|
||||
@@ -18,8 +18,11 @@ public class GetEmailCommand implements ExecutableCommand {
|
||||
@Inject
|
||||
private DataSource dataSource;
|
||||
|
||||
@Inject
|
||||
private CommandService commandService;
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
String playerName = arguments.isEmpty() ? sender.getName() : arguments.get(0);
|
||||
|
||||
PlayerAuth auth = dataSource.getAuth(playerName);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.util.BukkitService;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -15,7 +14,7 @@ public class GetIpCommand implements ExecutableCommand {
|
||||
private BukkitService bukkitService;
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
// Get the player query
|
||||
String playerName = arguments.get(0);
|
||||
|
||||
|
||||
@@ -19,8 +19,11 @@ public class LastLoginCommand implements ExecutableCommand {
|
||||
@Inject
|
||||
private DataSource dataSource;
|
||||
|
||||
@Inject
|
||||
private CommandService commandService;
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
// Get the player
|
||||
String playerName = (arguments.size() >= 1) ? arguments.get(0) : sender.getName();
|
||||
|
||||
|
||||
+5
-8
@@ -1,22 +1,19 @@
|
||||
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.datasource.DataSource;
|
||||
import fr.xephi.authme.task.PurgeTask;
|
||||
import fr.xephi.authme.util.BukkitService;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
* Command for purging data of banned players. Depending on the settings
|
||||
* it purges (deletes) data from third-party plugins as well.
|
||||
@@ -33,7 +30,7 @@ public class PurgeBannedPlayersCommand implements ExecutableCommand {
|
||||
private BukkitService bukkitService;
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
// Get the list of banned players
|
||||
Set<String> namedBanned = new HashSet<>();
|
||||
Set<OfflinePlayer> bannedPlayers = bukkitService.getBannedPlayers();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
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.datasource.DataSource;
|
||||
import fr.xephi.authme.task.PurgeTask;
|
||||
@@ -28,7 +27,7 @@ public class PurgeCommand implements ExecutableCommand {
|
||||
private AuthMe plugin;
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
// Get the days parameter
|
||||
String daysStr = arguments.get(0);
|
||||
|
||||
|
||||
+4
-1
@@ -18,8 +18,11 @@ public class PurgeLastPositionCommand implements ExecutableCommand {
|
||||
@Inject
|
||||
private DataSource dataSource;
|
||||
|
||||
@Inject
|
||||
private CommandService commandService;
|
||||
|
||||
@Override
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||
String playerName = arguments.isEmpty() ? sender.getName() : arguments.get(0);
|
||||
|
||||
if ("*".equals(playerName)) {
|
||||
|
||||
@@ -25,6 +25,9 @@ public class RegisterAdminCommand implements ExecutableCommand {
|
||||
@Inject
|
||||
private PasswordSecurity passwordSecurity;
|
||||
|
||||
@Inject
|
||||
private CommandService commandService;
|
||||
|
||||
@Inject
|
||||
private DataSource dataSource;
|
||||
|
||||
@@ -35,8 +38,7 @@ public class RegisterAdminCommand implements ExecutableCommand {
|
||||
private ValidationService validationService;
|
||||
|
||||
@Override
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments,
|
||||
final CommandService commandService) {
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||
// Get the player name and password
|
||||
final String playerName = arguments.get(0);
|
||||
final String playerPass = arguments.get(1);
|
||||
|
||||
@@ -31,8 +31,11 @@ public class ReloadCommand implements ExecutableCommand {
|
||||
@Inject
|
||||
private DataSource dataSource;
|
||||
|
||||
@Inject
|
||||
private CommandService commandService;
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
try {
|
||||
settings.reload();
|
||||
ConsoleLogger.setLoggingOptions(settings);
|
||||
|
||||
@@ -20,6 +20,9 @@ public class SetEmailCommand implements ExecutableCommand {
|
||||
@Inject
|
||||
private DataSource dataSource;
|
||||
|
||||
@Inject
|
||||
private CommandService commandService;
|
||||
|
||||
@Inject
|
||||
private PlayerCache playerCache;
|
||||
|
||||
@@ -27,8 +30,7 @@ public class SetEmailCommand implements ExecutableCommand {
|
||||
private BukkitService bukkitService;
|
||||
|
||||
@Override
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments,
|
||||
final CommandService commandService) {
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||
// Get the player name and email address
|
||||
final String playerName = arguments.get(0);
|
||||
final String playerEmail = arguments.get(1);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.PlayerCommand;
|
||||
import fr.xephi.authme.settings.SpawnLoader;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -14,7 +13,7 @@ public class SetFirstSpawnCommand extends PlayerCommand {
|
||||
private SpawnLoader spawnLoader;
|
||||
|
||||
@Override
|
||||
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
|
||||
public void runCommand(Player player, List<String> arguments) {
|
||||
if (spawnLoader.setFirstSpawn(player.getLocation())) {
|
||||
player.sendMessage("[AuthMe] Correctly defined new first spawn point");
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.PlayerCommand;
|
||||
import fr.xephi.authme.settings.SpawnLoader;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -14,7 +13,7 @@ public class SetSpawnCommand extends PlayerCommand {
|
||||
private SpawnLoader spawnLoader;
|
||||
|
||||
@Override
|
||||
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
|
||||
public void runCommand(Player player, List<String> arguments) {
|
||||
if (spawnLoader.setSpawn(player.getLocation())) {
|
||||
player.sendMessage("[AuthMe] Correctly defined new spawn point");
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.PlayerCommand;
|
||||
import fr.xephi.authme.settings.SpawnLoader;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -14,7 +13,7 @@ public class SpawnCommand extends PlayerCommand {
|
||||
private SpawnLoader spawnLoader;
|
||||
|
||||
@Override
|
||||
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
|
||||
public void runCommand(Player player, List<String> arguments) {
|
||||
if (spawnLoader.getSpawn() == null) {
|
||||
player.sendMessage("[AuthMe] Spawn has failed, please try to define the spawn");
|
||||
} else {
|
||||
|
||||
@@ -20,8 +20,11 @@ public class SwitchAntiBotCommand implements ExecutableCommand {
|
||||
@Inject
|
||||
private AntiBot antiBot;
|
||||
|
||||
@Inject
|
||||
private CommandService commandService;
|
||||
|
||||
@Override
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||
if (arguments.isEmpty()) {
|
||||
sender.sendMessage("[AuthMe] AntiBot status: " + antiBot.getAntiBotStatus().name());
|
||||
return;
|
||||
|
||||
+10
-4
@@ -33,6 +33,9 @@ public class UnregisterAdminCommand implements ExecutableCommand {
|
||||
@Inject
|
||||
private DataSource dataSource;
|
||||
|
||||
@Inject
|
||||
private CommandService commandService;
|
||||
|
||||
@Inject
|
||||
private PlayerCache playerCache;
|
||||
|
||||
@@ -42,8 +45,11 @@ public class UnregisterAdminCommand implements ExecutableCommand {
|
||||
@Inject
|
||||
private BukkitService bukkitService;
|
||||
|
||||
@Inject
|
||||
private LimboCache limboCache;
|
||||
|
||||
@Override
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||
// Get the player name
|
||||
String playerName = arguments.get(0);
|
||||
String playerNameLowerCase = playerName.toLowerCase();
|
||||
@@ -88,14 +94,14 @@ public class UnregisterAdminCommand implements ExecutableCommand {
|
||||
final String playerNameLowerCase = target.getName().toLowerCase();
|
||||
|
||||
Utils.teleportToSpawn(target);
|
||||
LimboCache.getInstance().addLimboPlayer(target);
|
||||
limboCache.addLimboPlayer(target);
|
||||
int timeOut = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;
|
||||
int interval = service.getProperty(RegistrationSettings.MESSAGE_INTERVAL);
|
||||
if (timeOut != 0) {
|
||||
BukkitTask id = bukkitService.runTaskLater(new TimeoutTask(authMe, playerNameLowerCase, target), timeOut);
|
||||
LimboCache.getInstance().getLimboPlayer(playerNameLowerCase).setTimeoutTask(id);
|
||||
limboCache.getLimboPlayer(playerNameLowerCase).setTimeoutTask(id);
|
||||
}
|
||||
LimboCache.getInstance().getLimboPlayer(playerNameLowerCase).setMessageTask(
|
||||
limboCache.getLimboPlayer(playerNameLowerCase).setMessageTask(
|
||||
bukkitService.runTask(new MessageTask(bukkitService, authMe.getMessages(),
|
||||
playerNameLowerCase, MessageKey.REGISTER_MESSAGE, interval)));
|
||||
|
||||
|
||||
@@ -19,8 +19,11 @@ public class VersionCommand implements ExecutableCommand {
|
||||
@Inject
|
||||
private BukkitService bukkitService;
|
||||
|
||||
@Inject
|
||||
private CommandService commandService;
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
// Show some version info
|
||||
sender.sendMessage(ChatColor.GOLD + "==========[ " + commandService.getProperty(HELP_HEADER)
|
||||
+ " ABOUT ]==========");
|
||||
|
||||
@@ -18,8 +18,11 @@ public class CaptchaCommand extends PlayerCommand {
|
||||
@Inject
|
||||
private CaptchaManager captchaManager;
|
||||
|
||||
@Inject
|
||||
private CommandService commandService;
|
||||
|
||||
@Override
|
||||
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
|
||||
public void runCommand(Player player, List<String> arguments) {
|
||||
final String playerName = player.getName().toLowerCase();
|
||||
|
||||
if (playerCache.isAuthenticated(playerName)) {
|
||||
|
||||
+4
-1
@@ -20,6 +20,9 @@ import java.util.List;
|
||||
*/
|
||||
public class ChangePasswordCommand extends PlayerCommand {
|
||||
|
||||
@Inject
|
||||
private CommandService commandService;
|
||||
|
||||
@Inject
|
||||
private PlayerCache playerCache;
|
||||
|
||||
@@ -34,7 +37,7 @@ public class ChangePasswordCommand extends PlayerCommand {
|
||||
private PasswordSecurity passwordSecurity;
|
||||
|
||||
@Override
|
||||
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
|
||||
public void runCommand(Player player, List<String> arguments) {
|
||||
String oldPassword = arguments.get(0);
|
||||
String newPassword = arguments.get(1);
|
||||
|
||||
|
||||
@@ -17,8 +17,11 @@ public class AddEmailCommand extends PlayerCommand {
|
||||
@Inject
|
||||
private Management management;
|
||||
|
||||
@Inject
|
||||
private CommandService commandService;
|
||||
|
||||
@Override
|
||||
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
|
||||
public void runCommand(Player player, List<String> arguments) {
|
||||
String email = arguments.get(0);
|
||||
String emailConfirmation = arguments.get(1);
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package fr.xephi.authme.command.executable.email;
|
||||
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.PlayerCommand;
|
||||
import fr.xephi.authme.process.Management;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -17,7 +16,7 @@ public class ChangeEmailCommand extends PlayerCommand {
|
||||
private Management management;
|
||||
|
||||
@Override
|
||||
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
|
||||
public void runCommand(Player player, List<String> arguments) {
|
||||
String playerMailOld = arguments.get(0);
|
||||
String playerMailNew = arguments.get(1);
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import fr.xephi.authme.command.FoundCommandResult;
|
||||
import fr.xephi.authme.command.help.HelpProvider;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -14,8 +15,11 @@ import java.util.List;
|
||||
*/
|
||||
public class EmailBaseCommand implements ExecutableCommand {
|
||||
|
||||
@Inject
|
||||
private CommandService commandService;
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
FoundCommandResult result = commandService.mapPartsToCommand(sender, Collections.singletonList("email"));
|
||||
commandService.outputHelp(sender, result, HelpProvider.SHOW_CHILDREN);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
package fr.xephi.authme.command.executable.email;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
@@ -19,12 +13,19 @@ import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||
import fr.xephi.authme.settings.properties.EmailSettings;
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
|
||||
public class RecoverEmailCommand extends PlayerCommand {
|
||||
|
||||
@Inject
|
||||
private PasswordSecurity passwordSecurity;
|
||||
|
||||
@Inject
|
||||
private CommandService commandService;
|
||||
|
||||
@Inject
|
||||
private DataSource dataSource;
|
||||
|
||||
@@ -32,10 +33,11 @@ public class RecoverEmailCommand extends PlayerCommand {
|
||||
private PlayerCache playerCache;
|
||||
|
||||
@Inject
|
||||
// TODO #655: Remove injected AuthMe instance once Authme#mail is encapsulated
|
||||
private AuthMe plugin;
|
||||
|
||||
@Override
|
||||
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
|
||||
public void runCommand(Player player, List<String> arguments) {
|
||||
final String playerMail = arguments.get(0);
|
||||
final String playerName = player.getName();
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package fr.xephi.authme.command.executable.login;
|
||||
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.PlayerCommand;
|
||||
import fr.xephi.authme.process.Management;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -17,7 +16,7 @@ public class LoginCommand extends PlayerCommand {
|
||||
private Management management;
|
||||
|
||||
@Override
|
||||
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
|
||||
public void runCommand(Player player, List<String> arguments) {
|
||||
final String password = arguments.get(0);
|
||||
management.performLogin(player, password, false);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package fr.xephi.authme.command.executable.logout;
|
||||
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.PlayerCommand;
|
||||
import fr.xephi.authme.process.Management;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -17,7 +16,7 @@ public class LogoutCommand extends PlayerCommand {
|
||||
private Management management;
|
||||
|
||||
@Override
|
||||
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
|
||||
public void runCommand(Player player, List<String> arguments) {
|
||||
management.performLogout(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,11 @@ public class RegisterCommand extends PlayerCommand {
|
||||
@Inject
|
||||
private Management management;
|
||||
|
||||
@Inject
|
||||
private CommandService commandService;
|
||||
|
||||
@Override
|
||||
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
|
||||
public void runCommand(Player player, List<String> arguments) {
|
||||
if (commandService.getProperty(SecuritySettings.PASSWORD_HASH) == HashAlgorithm.TWO_FACTOR) {
|
||||
//for two factor auth we don't need to check the usage
|
||||
management.performRegister(player, "", "", true);
|
||||
|
||||
@@ -15,8 +15,11 @@ public class UnregisterCommand extends PlayerCommand {
|
||||
@Inject
|
||||
private Management management;
|
||||
|
||||
@Inject
|
||||
private CommandService commandService;
|
||||
|
||||
@Override
|
||||
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
|
||||
public void runCommand(Player player, List<String> arguments) {
|
||||
String playerPass = arguments.get(0);
|
||||
final String playerNameLowerCase = player.getName().toLowerCase();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user