Change ExecutableCommand interface (wip – doesn't compile)
- Change interface to use (CommandSender, List<String> arguments) - Use CommandArgumentDescription#name instead of "label" (to prevent confusion between command labels and arguments) - Simplify command difference computation in CommandHandler (no longer consider argument difference)
This commit is contained in:
@@ -2,25 +2,24 @@ package fr.xephi.authme.command.executable.captcha;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.Wrapper;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*/
|
||||
import java.util.List;
|
||||
|
||||
public class CaptchaCommand extends ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
// Make sure the current command executor is a player
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the player instance and name
|
||||
@@ -28,7 +27,7 @@ public class CaptchaCommand extends ExecutableCommand {
|
||||
final String playerNameLowerCase = player.getName().toLowerCase();
|
||||
|
||||
// Get the parameter values
|
||||
String captcha = commandArguments.get(0);
|
||||
String captcha = arguments.get(0);
|
||||
|
||||
// AuthMe plugin instance
|
||||
final Wrapper wrapper = Wrapper.getInstance();
|
||||
@@ -40,18 +39,18 @@ public class CaptchaCommand extends ExecutableCommand {
|
||||
// Command logic
|
||||
if (PlayerCache.getInstance().isAuthenticated(playerNameLowerCase)) {
|
||||
m.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR);
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Settings.useCaptcha) {
|
||||
m.send(player, MessageKey.USAGE_LOGIN);
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!plugin.cap.containsKey(playerNameLowerCase)) {
|
||||
m.send(player, MessageKey.USAGE_LOGIN);
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Settings.useCaptcha && !captcha.equals(plugin.cap.get(playerNameLowerCase))) {
|
||||
@@ -61,7 +60,7 @@ public class CaptchaCommand extends ExecutableCommand {
|
||||
for (String s : m.retrieve(MessageKey.CAPTCHA_WRONG_ERROR)) {
|
||||
player.sendMessage(s.replace("THE_CAPTCHA", plugin.cap.get(playerNameLowerCase)));
|
||||
}
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.captcha.remove(playerNameLowerCase);
|
||||
@@ -70,6 +69,5 @@ public class CaptchaCommand extends ExecutableCommand {
|
||||
// Show a status message
|
||||
m.send(player, MessageKey.CAPTCHA_SUCCESS);
|
||||
m.send(player, MessageKey.LOGIN_MESSAGE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user