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:
@@ -1,31 +1,29 @@
|
||||
package fr.xephi.authme.command.executable.email;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.util.Wrapper;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*/
|
||||
import java.util.List;
|
||||
|
||||
public class AddEmailCommand 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 parameter values
|
||||
String playerMail = commandArguments.get(0);
|
||||
String playerMailVerify = commandArguments.get(1);
|
||||
String playerMail = arguments.get(0);
|
||||
String playerMailVerify = arguments.get(1);
|
||||
|
||||
// Get the player and perform email addition
|
||||
final AuthMe plugin = Wrapper.getInstance().getAuthMe();
|
||||
final Player player = (Player) sender;
|
||||
plugin.getManagement().performAddEmail(player, playerMail, playerMailVerify);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
package fr.xephi.authme.command.executable.email;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.util.Wrapper;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ChangeEmailCommand 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 parameter values
|
||||
String playerMailOld = commandArguments.get(0);
|
||||
String playerMailNew = commandArguments.get(1);
|
||||
String playerMailOld = arguments.get(0);
|
||||
String playerMailNew = arguments.get(1);
|
||||
|
||||
// Get the player instance and execute action
|
||||
final AuthMe plugin = Wrapper.getInstance().getAuthMe();
|
||||
final Player player = (Player) sender;
|
||||
plugin.getManagement().performChangeEmail(player, playerMailOld, playerMailNew);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,32 +4,30 @@ import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
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.security.NoSuchAlgorithmException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class RecoverEmailCommand 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 parameter values
|
||||
String playerMail = commandArguments.get(0);
|
||||
String playerMail = arguments.get(0);
|
||||
|
||||
// Get the player instance and name
|
||||
final Player player = (Player) sender;
|
||||
@@ -42,12 +40,12 @@ public class RecoverEmailCommand extends ExecutableCommand {
|
||||
|
||||
if (plugin.mail == null) {
|
||||
m.send(player, MessageKey.ERROR);
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
if (plugin.database.isAuthAvailable(playerName)) {
|
||||
if (PlayerCache.getInstance().isAuthenticated(playerName)) {
|
||||
m.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR);
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
RandomString rand = new RandomString(Settings.getRecoveryPassLength);
|
||||
@@ -60,16 +58,17 @@ public class RecoverEmailCommand extends ExecutableCommand {
|
||||
auth = plugin.database.getAuth(playerName);
|
||||
} else {
|
||||
m.send(player, MessageKey.UNKNOWN_USER);
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
if (Settings.getmailAccount.equals("") || Settings.getmailAccount.isEmpty()) {
|
||||
m.send(player, MessageKey.ERROR);
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playerMail.equalsIgnoreCase(auth.getEmail()) || playerMail.equalsIgnoreCase("your@email.com") || auth.getEmail().equalsIgnoreCase("your@email.com")) {
|
||||
if (!playerMail.equalsIgnoreCase(auth.getEmail()) || playerMail.equalsIgnoreCase("your@email.com")
|
||||
|| auth.getEmail().equalsIgnoreCase("your@email.com")) {
|
||||
m.send(player, MessageKey.INVALID_EMAIL);
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
auth.setHash(hashNew);
|
||||
plugin.database.updatePassword(auth);
|
||||
@@ -83,7 +82,5 @@ public class RecoverEmailCommand extends ExecutableCommand {
|
||||
} else {
|
||||
m.send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user