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:
parent
2f153fb85c
commit
eecad80748
@ -6,9 +6,9 @@ package fr.xephi.authme.command;
|
|||||||
public class CommandArgumentDescription {
|
public class CommandArgumentDescription {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Argument label (one-word description of the argument).
|
* Argument name (one-word description of the argument).
|
||||||
*/
|
*/
|
||||||
private final String label;
|
private final String name;
|
||||||
/**
|
/**
|
||||||
* Argument description.
|
* Argument description.
|
||||||
*/
|
*/
|
||||||
@ -21,23 +21,23 @@ public class CommandArgumentDescription {
|
|||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param label The argument label.
|
* @param name The argument name.
|
||||||
* @param description The argument description.
|
* @param description The argument description.
|
||||||
* @param isOptional True if the argument is optional, false otherwise.
|
* @param isOptional True if the argument is optional, false otherwise.
|
||||||
*/
|
*/
|
||||||
public CommandArgumentDescription(String label, String description, boolean isOptional) {
|
public CommandArgumentDescription(String name, String description, boolean isOptional) {
|
||||||
this.label = label;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.isOptional = isOptional;
|
this.isOptional = isOptional;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the argument label.
|
* Get the argument name.
|
||||||
*
|
*
|
||||||
* @return Argument label.
|
* @return Argument name.
|
||||||
*/
|
*/
|
||||||
public String getLabel() {
|
public String getName() {
|
||||||
return this.label;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -2,15 +2,10 @@ package fr.xephi.authme.command;
|
|||||||
|
|
||||||
import fr.xephi.authme.permission.DefaultPermission;
|
import fr.xephi.authme.permission.DefaultPermission;
|
||||||
import fr.xephi.authme.permission.PermissionNode;
|
import fr.xephi.authme.permission.PermissionNode;
|
||||||
import fr.xephi.authme.util.CollectionUtils;
|
|
||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.firstNonNull;
|
import static com.google.common.base.Objects.firstNonNull;
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import fr.xephi.authme.permission.PermissionsManager;
|
|||||||
import fr.xephi.authme.util.CollectionUtils;
|
import fr.xephi.authme.util.CollectionUtils;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -152,11 +151,11 @@ public class CommandHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prefer labels: /register help goes to "Help command", not "Register command" with argument 'help'
|
// Prefer labels: /register help goes to "Help command", not "Register command" with argument 'help'
|
||||||
List<String> remaining = parts.subList(1, parts.size());
|
List<String> remainingParts = parts.subList(1, parts.size());
|
||||||
CommandDescription childCommand = getSuitableChild(base, remaining);
|
CommandDescription childCommand = getSuitableChild(base, remainingParts);
|
||||||
if (childCommand != null) {
|
if (childCommand != null) {
|
||||||
return new FoundCommandResult(childCommand, parts.subList(2, parts.size()), parts.subList(0, 2));
|
return new FoundCommandResult(childCommand, parts.subList(2, parts.size()), parts.subList(0, 2));
|
||||||
} else if (isSuitableArgumentCount(base, remaining.size())) {
|
} else if (hasSuitableArgumentCount(base, remainingParts.size())) {
|
||||||
return new FoundCommandResult(base, parts.subList(1, parts.size()), parts.subList(0, 1));
|
return new FoundCommandResult(base, parts.subList(1, parts.size()), parts.subList(0, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,22 +164,17 @@ public class CommandHandler {
|
|||||||
|
|
||||||
private FoundCommandResult getCommandWithSmallestDifference(CommandDescription base, List<String> parts) {
|
private FoundCommandResult getCommandWithSmallestDifference(CommandDescription base, List<String> parts) {
|
||||||
final String label = parts.get(0);
|
final String label = parts.get(0);
|
||||||
final int argumentCount = parts.size() - 1;
|
|
||||||
|
|
||||||
double minDifference = Double.POSITIVE_INFINITY;
|
double minDifference = Double.POSITIVE_INFINITY;
|
||||||
CommandDescription closestCommand = null;
|
CommandDescription closestCommand = null;
|
||||||
for (CommandDescription child : base.getChildren()) {
|
for (CommandDescription child : base.getChildren()) {
|
||||||
double labelDifference = getLabelDifference(child, label);
|
double difference = getLabelDifference(child, label);
|
||||||
double argumentDifference = getArgumentCountDifference(child, argumentCount);
|
|
||||||
// Weigh argument difference less
|
|
||||||
double difference = labelDifference + argumentDifference / 2;
|
|
||||||
if (difference < minDifference) {
|
if (difference < minDifference) {
|
||||||
minDifference = difference;
|
minDifference = difference;
|
||||||
closestCommand = child;
|
closestCommand = child;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: Return the full list of labels and arguments
|
// TODO: Return the full list of labels and arguments
|
||||||
// TODO: Also compare the base command and suggest it if it's the most similar
|
|
||||||
return new FoundCommandResult(
|
return new FoundCommandResult(
|
||||||
closestCommand, null, null, minDifference, FoundCommandResult.ResultStatus.UNKNOWN_LABEL);
|
closestCommand, null, null, minDifference, FoundCommandResult.ResultStatus.UNKNOWN_LABEL);
|
||||||
}
|
}
|
||||||
@ -195,7 +189,16 @@ public class CommandHandler {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is the given command a suitable match for the given parts? parts is for example [changepassword, newpw, newpw]
|
/**
|
||||||
|
* Return a child from a base command if the label and the argument count match.
|
||||||
|
*
|
||||||
|
* @param baseCommand The base command whose children should be checked
|
||||||
|
* @param parts The command parts received from the invocation; the first item is the potential label and any
|
||||||
|
* other items are command arguments. The first initial part that led to the base command should not
|
||||||
|
* be present.
|
||||||
|
*
|
||||||
|
* @return A command if there was a complete match (including proper argument count), null otherwise
|
||||||
|
*/
|
||||||
private CommandDescription getSuitableChild(CommandDescription baseCommand, List<String> parts) {
|
private CommandDescription getSuitableChild(CommandDescription baseCommand, List<String> parts) {
|
||||||
if (CollectionUtils.isEmpty(parts)) {
|
if (CollectionUtils.isEmpty(parts)) {
|
||||||
return null;
|
return null;
|
||||||
@ -205,26 +208,20 @@ public class CommandHandler {
|
|||||||
final int argumentCount = parts.size() - 1;
|
final int argumentCount = parts.size() - 1;
|
||||||
|
|
||||||
for (CommandDescription child : baseCommand.getChildren()) {
|
for (CommandDescription child : baseCommand.getChildren()) {
|
||||||
if (child.hasLabel(label) && isSuitableArgumentCount(child, argumentCount)) {
|
if (child.hasLabel(label) && hasSuitableArgumentCount(child, argumentCount)) {
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isSuitableArgumentCount(CommandDescription command, int argumentCount) {
|
private static boolean hasSuitableArgumentCount(CommandDescription command, int argumentCount) {
|
||||||
int minArgs = CommandUtils.getMinNumberOfArguments(command);
|
int minArgs = CommandUtils.getMinNumberOfArguments(command);
|
||||||
int maxArgs = CommandUtils.getMaxNumberOfArguments(command);
|
int maxArgs = CommandUtils.getMaxNumberOfArguments(command);
|
||||||
|
|
||||||
return argumentCount >= minArgs && argumentCount <= maxArgs;
|
return argumentCount >= minArgs && argumentCount <= maxArgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getArgumentCountDifference(CommandDescription commandDescription, int givenArgumentsCount) {
|
|
||||||
return Math.min(
|
|
||||||
Math.abs(givenArgumentsCount - CommandUtils.getMinNumberOfArguments(commandDescription)),
|
|
||||||
Math.abs(givenArgumentsCount - CommandUtils.getMaxNumberOfArguments(commandDescription)));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static double getLabelDifference(CommandDescription command, String givenLabel) {
|
private static double getLabelDifference(CommandDescription command, String givenLabel) {
|
||||||
double minDifference = Double.POSITIVE_INFINITY;
|
double minDifference = Double.POSITIVE_INFINITY;
|
||||||
for (String commandLabel : command.getLabels()) {
|
for (String commandLabel : command.getLabels()) {
|
||||||
|
|||||||
@ -1,11 +1,7 @@
|
|||||||
package fr.xephi.authme.command;
|
package fr.xephi.authme.command;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
|
||||||
import fr.xephi.authme.permission.DefaultPermission;
|
import fr.xephi.authme.permission.DefaultPermission;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
|
||||||
import fr.xephi.authme.permission.PermissionNode;
|
import fr.xephi.authme.permission.PermissionNode;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -42,38 +38,6 @@ public class CommandPermissions {
|
|||||||
return this.permissionNodes;
|
return this.permissionNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check whether this command requires any permission to be executed. This is based on the getPermission() method.
|
|
||||||
*
|
|
||||||
* @param sender CommandSender
|
|
||||||
*
|
|
||||||
* @return True if this command requires any permission to be executed by a player.
|
|
||||||
*/
|
|
||||||
public boolean hasPermission(CommandSender sender) {
|
|
||||||
// Make sure any permission node is set
|
|
||||||
if (permissionNodes.isEmpty()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
PermissionsManager permissionsManager = AuthMe.getInstance().getPermissionsManager();
|
|
||||||
final boolean defaultPermission = getDefaultPermissionCommandSender(sender);
|
|
||||||
|
|
||||||
// Make sure the command sender is a player, if not use the default
|
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
return defaultPermission;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the player instance
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
// Get the permissions manager, and make sure it's instance is valid
|
|
||||||
|
|
||||||
if (permissionsManager == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Check whether the player has permission, return the result
|
|
||||||
return permissionsManager.hasPermission(player, this.permissionNodes, defaultPermission);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the default permission if the permission nodes couldn't be used.
|
* Get the default permission if the permission nodes couldn't be used.
|
||||||
@ -85,24 +49,4 @@ public class CommandPermissions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the default permission for a specified command sender.
|
|
||||||
*
|
|
||||||
* @param sender The command sender to get the default permission for.
|
|
||||||
*
|
|
||||||
* @return True if the command sender has permission by default, false otherwise.
|
|
||||||
*/
|
|
||||||
public boolean getDefaultPermissionCommandSender(CommandSender sender) {
|
|
||||||
switch (getDefaultPermission()) {
|
|
||||||
case ALLOWED:
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case OP_ONLY:
|
|
||||||
return sender.isOp();
|
|
||||||
|
|
||||||
case NOT_ALLOWED:
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,19 +2,18 @@ package fr.xephi.authme.command;
|
|||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for AuthMe commands that can be executed.
|
* Base class for AuthMe commands that can be executed.
|
||||||
*/
|
*/
|
||||||
public abstract class ExecutableCommand {
|
public abstract class ExecutableCommand {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the command.
|
* Execute the command with the given arguments.
|
||||||
*
|
*
|
||||||
* @param sender The command sender.
|
* @param sender The command sender.
|
||||||
* @param commandReference The command reference.
|
* @param arguments The arguments.
|
||||||
* @param commandArguments The command arguments.
|
|
||||||
*
|
|
||||||
* @return True if the command was executed successfully, false otherwise.
|
|
||||||
*/
|
*/
|
||||||
public abstract boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments);
|
public abstract void executeCommand(CommandSender sender, List<String> arguments);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,6 @@ package fr.xephi.authme.command.executable.authme;
|
|||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
@ -12,21 +11,17 @@ import org.bukkit.command.CommandSender;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class AccountsCommand extends ExecutableCommand {
|
public class AccountsCommand extends ExecutableCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||||
final AuthMe plugin = AuthMe.getInstance();
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
final Messages m = plugin.getMessages();
|
final Messages m = plugin.getMessages();
|
||||||
|
|
||||||
List<String> arguments = commandArguments.getList();
|
|
||||||
|
|
||||||
// Get the player query
|
// Get the player query
|
||||||
String playerQuery = sender.getName();
|
String playerQuery = sender.getName();
|
||||||
if (arguments.size() >= 1)
|
if (arguments.size() >= 1)
|
||||||
playerQuery = commandArguments.get(0);
|
playerQuery = arguments.get(0);
|
||||||
final String playerQueryFinal = playerQuery;
|
final String playerQueryFinal = playerQuery;
|
||||||
|
|
||||||
// Command logic
|
// Command logic
|
||||||
@ -70,7 +65,7 @@ public class AccountsCommand extends ExecutableCommand {
|
|||||||
sender.sendMessage(message.toString());
|
sender.sendMessage(message.toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return;
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -108,7 +103,6 @@ public class AccountsCommand extends ExecutableCommand {
|
|||||||
sender.sendMessage(message.toString());
|
sender.sendMessage(message.toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +1,20 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
package fr.xephi.authme.command.executable.authme;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
/**
|
import java.util.List;
|
||||||
*/
|
|
||||||
public class AuthMeCommand extends ExecutableCommand {
|
public class AuthMeCommand extends ExecutableCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||||
// Show some version info
|
// Show some version info
|
||||||
|
// FIXME replace use of commandReference
|
||||||
sender.sendMessage(ChatColor.GREEN + "This server is running " + AuthMe.getPluginName() + " v" + AuthMe.getPluginVersion() + " b" + AuthMe.getPluginBuildNumber()+ "! " + ChatColor.RED + "<3");
|
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 + "/" + commandReference.get(0) + " help" + ChatColor.YELLOW + " to view help.");
|
sender.sendMessage(ChatColor.YELLOW + "Use the command " + ChatColor.GOLD + "/" + commandReference.get(0) + " help" + ChatColor.YELLOW + " to view help.");
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Use the command " + ChatColor.GOLD + "/" + commandReference.get(0) + " about" + ChatColor.YELLOW + " to view about.");
|
sender.sendMessage(ChatColor.YELLOW + "Use the command " + ChatColor.GOLD + "/" + commandReference.get(0) + " about" + ChatColor.YELLOW + " to view about.");
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,16 +4,16 @@ import fr.xephi.authme.AuthMe;
|
|||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Admin command for changing a player's password.
|
* Admin command for changing a player's password.
|
||||||
@ -21,14 +21,13 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
public class ChangePasswordAdminCommand extends ExecutableCommand {
|
public class ChangePasswordAdminCommand extends ExecutableCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||||
final AuthMe plugin = AuthMe.getInstance();
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
// Messages instance
|
|
||||||
final Messages m = plugin.getMessages();
|
final Messages m = plugin.getMessages();
|
||||||
|
|
||||||
// Get the player and password
|
// Get the player and password
|
||||||
String playerName = commandArguments.get(0);
|
String playerName = arguments.get(0);
|
||||||
final String playerPass = commandArguments.get(1);
|
final String playerPass = arguments.get(1);
|
||||||
|
|
||||||
// Validate the password
|
// Validate the password
|
||||||
String playerPassLowerCase = playerPass.toLowerCase();
|
String playerPassLowerCase = playerPass.toLowerCase();
|
||||||
@ -38,20 +37,20 @@ public class ChangePasswordAdminCommand extends ExecutableCommand {
|
|||||||
|| playerPassLowerCase.contains(";") || playerPassLowerCase.contains("null")
|
|| playerPassLowerCase.contains(";") || playerPassLowerCase.contains("null")
|
||||||
|| !playerPassLowerCase.matches(Settings.getPassRegex)) {
|
|| !playerPassLowerCase.matches(Settings.getPassRegex)) {
|
||||||
m.send(sender, MessageKey.PASSWORD_MATCH_ERROR);
|
m.send(sender, MessageKey.PASSWORD_MATCH_ERROR);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
if (playerPassLowerCase.equalsIgnoreCase(playerName)) {
|
if (playerPassLowerCase.equalsIgnoreCase(playerName)) {
|
||||||
m.send(sender, MessageKey.PASSWORD_IS_USERNAME_ERROR);
|
m.send(sender, MessageKey.PASSWORD_IS_USERNAME_ERROR);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
if (playerPassLowerCase.length() < Settings.getPasswordMinLen
|
if (playerPassLowerCase.length() < Settings.getPasswordMinLen
|
||||||
|| playerPassLowerCase.length() > Settings.passwordMaxLength) {
|
|| playerPassLowerCase.length() > Settings.passwordMaxLength) {
|
||||||
m.send(sender, MessageKey.INVALID_PASSWORD_LENGTH);
|
m.send(sender, MessageKey.INVALID_PASSWORD_LENGTH);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
if (!Settings.unsafePasswords.isEmpty() && Settings.unsafePasswords.contains(playerPassLowerCase)) {
|
if (!Settings.unsafePasswords.isEmpty() && Settings.unsafePasswords.contains(playerPassLowerCase)) {
|
||||||
m.send(sender, MessageKey.PASSWORD_UNSAFE_ERROR);
|
m.send(sender, MessageKey.PASSWORD_UNSAFE_ERROR);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
// Set the password
|
// Set the password
|
||||||
final String playerNameLowerCase = playerName.toLowerCase();
|
final String playerNameLowerCase = playerName.toLowerCase();
|
||||||
@ -90,6 +89,5 @@ public class ChangePasswordAdminCommand extends ExecutableCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,17 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
package fr.xephi.authme.command.executable.authme;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.settings.Spawn;
|
import fr.xephi.authme.settings.Spawn;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
import java.util.List;
|
||||||
*/
|
|
||||||
public class FirstSpawnCommand extends ExecutableCommand {
|
public class FirstSpawnCommand extends ExecutableCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||||
// Make sure the command executor is a player
|
// Make sure the command executor is a player
|
||||||
try {
|
try {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
@ -26,6 +25,5 @@ public class FirstSpawnCommand extends ExecutableCommand {
|
|||||||
// TODO ljacqu 20151119: Catching NullPointerException is never a good idea. Find what can cause one instead
|
// TODO ljacqu 20151119: Catching NullPointerException is never a good idea. Find what can cause one instead
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
package fr.xephi.authme.command.executable.authme;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.permission.PlayerPermission;
|
import fr.xephi.authme.permission.PlayerPermission;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -15,34 +14,32 @@ import java.util.List;
|
|||||||
public class ForceLoginCommand extends ExecutableCommand {
|
public class ForceLoginCommand extends ExecutableCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||||
// AuthMe plugin instance
|
// AuthMe plugin instance
|
||||||
final AuthMe plugin = AuthMe.getInstance();
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
|
|
||||||
// Get the player query
|
// Get the player query
|
||||||
String playerName = sender.getName();
|
String playerName = sender.getName();
|
||||||
List<String> arguments = commandArguments.getList();
|
if (arguments.size() >= 1) {
|
||||||
if (arguments.size() >= 1)
|
playerName = arguments.get(0);
|
||||||
playerName = commandArguments.get(0);
|
}
|
||||||
|
|
||||||
// Command logic
|
// Command logic
|
||||||
try {
|
try {
|
||||||
@SuppressWarnings("deprecation")
|
// TODO ljacqu 20151212: Retrieve player via Utils method instead
|
||||||
Player player = Bukkit.getPlayer(playerName);
|
Player player = Bukkit.getPlayer(playerName);
|
||||||
if (player == null || !player.isOnline()) {
|
if (player == null || !player.isOnline()) {
|
||||||
sender.sendMessage("Player needs to be online!");
|
sender.sendMessage("Player needs to be online!");
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
if (!plugin.getPermissionsManager().hasPermission(player, PlayerPermission.CAN_LOGIN_BE_FORCED)) {
|
if (!plugin.getPermissionsManager().hasPermission(player, PlayerPermission.CAN_LOGIN_BE_FORCED)) {
|
||||||
sender.sendMessage("You cannot force login for the player " + playerName + "!");
|
sender.sendMessage("You cannot force login for the player " + playerName + "!");
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
plugin.getManagement().performLogin(player, "dontneed", true);
|
plugin.getManagement().performLogin(player, "dontneed", true);
|
||||||
sender.sendMessage("Force Login for " + playerName + " performed!");
|
sender.sendMessage("Force Login for " + playerName + " performed!");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sender.sendMessage("An error occurred while trying to get that player!");
|
sender.sendMessage("An error occurred while trying to get that player!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package fr.xephi.authme.command.executable.authme;
|
|||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
@ -10,26 +9,11 @@ import org.bukkit.command.CommandSender;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class GetEmailCommand extends ExecutableCommand {
|
public class GetEmailCommand extends ExecutableCommand {
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the command.
|
|
||||||
*
|
|
||||||
* @param sender The command sender.
|
|
||||||
* @param commandReference The command reference.
|
|
||||||
* @param commandArguments The command arguments.
|
|
||||||
*
|
|
||||||
* @return True if the command was executed successfully, false otherwise.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||||
// Get the player name
|
String playerName = arguments.isEmpty() ? sender.getName() : arguments.get(0);
|
||||||
List<String> arguments = commandArguments.getList();
|
|
||||||
String playerName = sender.getName();
|
|
||||||
if (arguments.size() >= 1)
|
|
||||||
playerName = commandArguments.get(0);
|
|
||||||
|
|
||||||
// Get the authenticated user
|
// Get the authenticated user
|
||||||
AuthMe plugin = AuthMe.getInstance();
|
AuthMe plugin = AuthMe.getInstance();
|
||||||
@ -37,11 +21,10 @@ public class GetEmailCommand extends ExecutableCommand {
|
|||||||
PlayerAuth auth = plugin.database.getAuth(playerName.toLowerCase());
|
PlayerAuth auth = plugin.database.getAuth(playerName.toLowerCase());
|
||||||
if (auth == null) {
|
if (auth == null) {
|
||||||
m.send(sender, MessageKey.UNKNOWN_USER);
|
m.send(sender, MessageKey.UNKNOWN_USER);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show the email address
|
// Show the email address
|
||||||
sender.sendMessage("[AuthMe] " + playerName + "'s email: " + auth.getEmail());
|
sender.sendMessage("[AuthMe] " + playerName + "'s email: " + auth.getEmail());
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
package fr.xephi.authme.command.executable.authme;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -9,25 +8,25 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class GetIpCommand extends ExecutableCommand {
|
public class GetIpCommand extends ExecutableCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||||
final AuthMe plugin = AuthMe.getInstance();
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
List<String> arguments = commandArguments.getList();
|
|
||||||
|
|
||||||
// Get the player query
|
// Get the player query
|
||||||
String playerName = (arguments.size() >= 1) ? arguments.get(0) : sender.getName();
|
String playerName = (arguments.size() >= 1) ? arguments.get(0) : sender.getName();
|
||||||
|
|
||||||
|
// TODO ljacqu 20151212: Use the Utils function instead
|
||||||
Player player = Bukkit.getPlayer(playerName);
|
Player player = Bukkit.getPlayer(playerName);
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
sender.sendMessage("This player is not actually online");
|
sender.sendMessage("The player is not online");
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
sender.sendMessage(player.getName() + "'s actual IP is : " + player.getAddress().getAddress().getHostAddress() + ":" + player.getAddress().getPort());
|
|
||||||
|
// TODO ljacqu 20151212: Revise the messages (actual IP vs. real IP...?)
|
||||||
|
sender.sendMessage(player.getName() + "'s actual IP is : " + player.getAddress().getAddress().getHostAddress()
|
||||||
|
+ ":" + player.getAddress().getPort());
|
||||||
sender.sendMessage(player.getName() + "'s real IP is : " + plugin.getIP(player));
|
sender.sendMessage(player.getName() + "'s real IP is : " + plugin.getIP(player));
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package fr.xephi.authme.command.executable.authme;
|
|||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
@ -16,9 +15,8 @@ import java.util.List;
|
|||||||
public class LastLoginCommand extends ExecutableCommand {
|
public class LastLoginCommand extends ExecutableCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||||
// Get the player
|
// Get the player
|
||||||
List<String> arguments = commandArguments.getList();
|
|
||||||
String playerName = (arguments.size() >= 1) ? arguments.get(0) : sender.getName();
|
String playerName = (arguments.size() >= 1) ? arguments.get(0) : sender.getName();
|
||||||
|
|
||||||
// Validate the player
|
// Validate the player
|
||||||
@ -30,11 +28,11 @@ public class LastLoginCommand extends ExecutableCommand {
|
|||||||
auth = plugin.database.getAuth(playerName.toLowerCase());
|
auth = plugin.database.getAuth(playerName.toLowerCase());
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
m.send(sender, MessageKey.UNKNOWN_USER);
|
m.send(sender, MessageKey.UNKNOWN_USER);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
if (auth == null) {
|
if (auth == null) {
|
||||||
m.send(sender, MessageKey.USER_NOT_REGISTERED);
|
m.send(sender, MessageKey.USER_NOT_REGISTERED);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the last login date
|
// Get the last login date
|
||||||
@ -45,7 +43,8 @@ public class LastLoginCommand extends ExecutableCommand {
|
|||||||
final long diff = System.currentTimeMillis() - lastLogin;
|
final long diff = System.currentTimeMillis() - lastLogin;
|
||||||
|
|
||||||
// Build the message
|
// Build the message
|
||||||
final String msg = (int) (diff / 86400000) + " days " + (int) (diff / 3600000 % 24) + " hours " + (int) (diff / 60000 % 60) + " mins " + (int) (diff / 1000 % 60) + " secs.";
|
final String msg = (int) (diff / 86400000) + " days " + (int) (diff / 3600000 % 24) + " hours "
|
||||||
|
+ (int) (diff / 60000 % 60) + " mins " + (int) (diff / 1000 % 60) + " secs.";
|
||||||
|
|
||||||
// Get the player's last IP
|
// Get the player's last IP
|
||||||
String lastIP = auth.getIp();
|
String lastIP = auth.getIp();
|
||||||
@ -54,6 +53,5 @@ public class LastLoginCommand extends ExecutableCommand {
|
|||||||
sender.sendMessage("[AuthMe] " + playerName + " last login : " + date.toString());
|
sender.sendMessage("[AuthMe] " + playerName + " last login : " + date.toString());
|
||||||
sender.sendMessage("[AuthMe] The player " + auth.getNickname() + " is unlogged since " + msg);
|
sender.sendMessage("[AuthMe] The player " + auth.getNickname() + " is unlogged since " + msg);
|
||||||
sender.sendMessage("[AuthMe] Last Player's IP: " + lastIP);
|
sender.sendMessage("[AuthMe] Last Player's IP: " + lastIP);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
package fr.xephi.authme.command.executable.authme;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@ -10,21 +9,10 @@ import org.bukkit.command.CommandSender;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class PurgeBannedPlayersCommand extends ExecutableCommand {
|
public class PurgeBannedPlayersCommand extends ExecutableCommand {
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the command.
|
|
||||||
*
|
|
||||||
* @param sender The command sender.
|
|
||||||
* @param commandReference The command reference.
|
|
||||||
* @param commandArguments The command arguments.
|
|
||||||
*
|
|
||||||
* @return True if the command was executed successfully, false otherwise.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||||
// AuthMe plugin instance
|
// AuthMe plugin instance
|
||||||
final AuthMe plugin = AuthMe.getInstance();
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
|
|
||||||
@ -47,6 +35,5 @@ public class PurgeBannedPlayersCommand extends ExecutableCommand {
|
|||||||
|
|
||||||
// Show a status message
|
// Show a status message
|
||||||
sender.sendMessage("[AuthMe] Database has been purged correctly");
|
sender.sendMessage("[AuthMe] Database has been purged correctly");
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
package fr.xephi.authme.command.executable.authme;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -10,40 +9,29 @@ import org.bukkit.command.CommandSender;
|
|||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class PurgeCommand extends ExecutableCommand {
|
public class PurgeCommand extends ExecutableCommand {
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the command.
|
|
||||||
*
|
|
||||||
* @param sender The command sender.
|
|
||||||
* @param commandReference The command reference.
|
|
||||||
* @param commandArguments The command arguments.
|
|
||||||
*
|
|
||||||
* @return True if the command was executed successfully, false otherwise.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||||
// AuthMe plugin instance
|
// AuthMe plugin instance
|
||||||
AuthMe plugin = AuthMe.getInstance();
|
AuthMe plugin = AuthMe.getInstance();
|
||||||
|
|
||||||
// Get the days parameter
|
// Get the days parameter
|
||||||
String daysStr = commandArguments.get(0);
|
String daysStr = arguments.get(0);
|
||||||
|
|
||||||
// Convert the days string to an integer value, and make sure it's valid
|
// Convert the days string to an integer value, and make sure it's valid
|
||||||
int days;
|
int days;
|
||||||
try {
|
try {
|
||||||
days = Integer.valueOf(daysStr);
|
days = Integer.parseInt(daysStr);
|
||||||
} catch (Exception ex) {
|
} catch (NumberFormatException ex) {
|
||||||
sender.sendMessage(ChatColor.RED + "The value you've entered is invalid!");
|
sender.sendMessage(ChatColor.RED + "The value you've entered is invalid!");
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the value
|
// Validate the value
|
||||||
if (days < 30) {
|
if (days < 30) {
|
||||||
sender.sendMessage(ChatColor.RED + "You can only purge data older than 30 days");
|
sender.sendMessage(ChatColor.RED + "You can only purge data older than 30 days");
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a calender instance to determine the date
|
// Create a calender instance to determine the date
|
||||||
@ -69,6 +57,5 @@ public class PurgeCommand extends ExecutableCommand {
|
|||||||
|
|
||||||
// Show a status message
|
// Show a status message
|
||||||
sender.sendMessage(ChatColor.GREEN + "[AuthMe] Database has been purged correctly");
|
sender.sendMessage(ChatColor.GREEN + "[AuthMe] Database has been purged correctly");
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,6 @@ package fr.xephi.authme.command.executable.authme;
|
|||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
@ -12,25 +11,13 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class PurgeLastPositionCommand extends ExecutableCommand {
|
public class PurgeLastPositionCommand extends ExecutableCommand {
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the command.
|
|
||||||
*
|
|
||||||
* @param sender The command sender.
|
|
||||||
* @param commandReference The command reference.
|
|
||||||
* @param commandArguments The command arguments.
|
|
||||||
*
|
|
||||||
* @return True if the command was executed successfully, false otherwise.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||||
final AuthMe plugin = AuthMe.getInstance();
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
final Messages m = plugin.getMessages();
|
final Messages m = plugin.getMessages();
|
||||||
|
|
||||||
List<String> arguments = commandArguments.getList();
|
|
||||||
String playerName = arguments.isEmpty() ? sender.getName() : arguments.get(0);
|
String playerName = arguments.isEmpty() ? sender.getName() : arguments.get(0);
|
||||||
|
|
||||||
// Get the player
|
// Get the player
|
||||||
@ -42,7 +29,7 @@ public class PurgeLastPositionCommand extends ExecutableCommand {
|
|||||||
PlayerAuth auth = plugin.database.getAuth(playerNameLowerCase);
|
PlayerAuth auth = plugin.database.getAuth(playerNameLowerCase);
|
||||||
if (auth == null) {
|
if (auth == null) {
|
||||||
m.send(sender, MessageKey.UNKNOWN_USER);
|
m.send(sender, MessageKey.UNKNOWN_USER);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the last position
|
// Set the last position
|
||||||
@ -61,6 +48,5 @@ public class PurgeLastPositionCommand extends ExecutableCommand {
|
|||||||
if (sender instanceof Player)
|
if (sender instanceof Player)
|
||||||
sender.sendMessage("An error occurred while trying to reset location or player do not exist, please see logs");
|
sender.sendMessage("An error occurred while trying to reset location or player do not exist, please see logs");
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,9 +5,9 @@ import fr.xephi.authme.ConsoleLogger;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
import fr.xephi.authme.command.CommandParts;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|||||||
@ -1,10 +1,7 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
package fr.xephi.authme.command.executable.authme;
|
||||||
|
|
||||||
//import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
@ -12,21 +9,12 @@ import fr.xephi.authme.settings.Settings;
|
|||||||
import fr.xephi.authme.util.Profiler;
|
import fr.xephi.authme.util.Profiler;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
/**
|
import java.util.List;
|
||||||
*/
|
|
||||||
public class ReloadCommand extends ExecutableCommand {
|
public class ReloadCommand extends ExecutableCommand {
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the command.
|
|
||||||
*
|
|
||||||
* @param sender The command sender.
|
|
||||||
* @param commandReference The command reference.
|
|
||||||
* @param commandArguments The command arguments.
|
|
||||||
*
|
|
||||||
* @return True if the command was executed successfully, false otherwise.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||||
// Profile the reload process
|
// Profile the reload process
|
||||||
Profiler p = new Profiler(true);
|
Profiler p = new Profiler(true);
|
||||||
|
|
||||||
@ -48,7 +36,6 @@ public class ReloadCommand extends ExecutableCommand {
|
|||||||
ConsoleLogger.showError("Fatal error occurred! AuthMe instance ABORTED!");
|
ConsoleLogger.showError("Fatal error occurred! AuthMe instance ABORTED!");
|
||||||
ConsoleLogger.writeStackTrace(e);
|
ConsoleLogger.writeStackTrace(e);
|
||||||
plugin.stopOrUnload();
|
plugin.stopOrUnload();
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show a status message
|
// Show a status message
|
||||||
@ -57,6 +44,5 @@ public class ReloadCommand extends ExecutableCommand {
|
|||||||
|
|
||||||
// AuthMeReloaded reloaded, show a status message
|
// AuthMeReloaded reloaded, show a status message
|
||||||
// sender.sendMessage(ChatColor.GREEN + "AuthMeReloaded has been reloaded successfully, took " + p.getTimeFormatted() + "!");
|
// sender.sendMessage(ChatColor.GREEN + "AuthMeReloaded has been reloaded successfully, took " + p.getTimeFormatted() + "!");
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,28 +3,18 @@ package fr.xephi.authme.command.executable.authme;
|
|||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
/**
|
import java.util.List;
|
||||||
*/
|
|
||||||
public class SetEmailCommand extends ExecutableCommand {
|
public class SetEmailCommand extends ExecutableCommand {
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the command.
|
|
||||||
*
|
|
||||||
* @param sender The command sender.
|
|
||||||
* @param commandReference The command reference.
|
|
||||||
* @param commandArguments The command arguments.
|
|
||||||
*
|
|
||||||
* @return True if the command was executed successfully, false otherwise.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||||
// AuthMe plugin instance
|
// AuthMe plugin instance
|
||||||
AuthMe plugin = AuthMe.getInstance();
|
AuthMe plugin = AuthMe.getInstance();
|
||||||
|
|
||||||
@ -32,27 +22,27 @@ public class SetEmailCommand extends ExecutableCommand {
|
|||||||
Messages m = plugin.getMessages();
|
Messages m = plugin.getMessages();
|
||||||
|
|
||||||
// Get the player name and email address
|
// Get the player name and email address
|
||||||
String playerName = commandArguments.get(0);
|
String playerName = arguments.get(0);
|
||||||
String playerEmail = commandArguments.get(1);
|
String playerEmail = arguments.get(1);
|
||||||
|
|
||||||
// Validate the email address
|
// Validate the email address
|
||||||
if (!Settings.isEmailCorrect(playerEmail)) {
|
if (!Settings.isEmailCorrect(playerEmail)) {
|
||||||
m.send(sender, MessageKey.INVALID_EMAIL);
|
m.send(sender, MessageKey.INVALID_EMAIL);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the user
|
// Validate the user
|
||||||
PlayerAuth auth = plugin.database.getAuth(playerName.toLowerCase());
|
PlayerAuth auth = plugin.database.getAuth(playerName.toLowerCase());
|
||||||
if (auth == null) {
|
if (auth == null) {
|
||||||
m.send(sender, MessageKey.UNKNOWN_USER);
|
m.send(sender, MessageKey.UNKNOWN_USER);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the email address
|
// Set the email address
|
||||||
auth.setEmail(playerEmail);
|
auth.setEmail(playerEmail);
|
||||||
if (!plugin.database.updateEmail(auth)) {
|
if (!plugin.database.updateEmail(auth)) {
|
||||||
m.send(sender, MessageKey.ERROR);
|
m.send(sender, MessageKey.ERROR);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the player cache
|
// Update the player cache
|
||||||
@ -61,6 +51,6 @@ public class SetEmailCommand extends ExecutableCommand {
|
|||||||
|
|
||||||
// Show a status message
|
// Show a status message
|
||||||
m.send(sender, MessageKey.EMAIL_CHANGED_SUCCESS);
|
m.send(sender, MessageKey.EMAIL_CHANGED_SUCCESS);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,27 +1,17 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
package fr.xephi.authme.command.executable.authme;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.settings.Spawn;
|
import fr.xephi.authme.settings.Spawn;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
import java.util.List;
|
||||||
*/
|
|
||||||
public class SetFirstSpawnCommand extends ExecutableCommand {
|
public class SetFirstSpawnCommand extends ExecutableCommand {
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the command.
|
|
||||||
*
|
|
||||||
* @param sender The command sender.
|
|
||||||
* @param commandReference The command reference.
|
|
||||||
* @param commandArguments The command arguments.
|
|
||||||
*
|
|
||||||
* @return True if the command was executed successfully, false otherwise.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||||
try {
|
try {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
if (Spawn.getInstance().setFirstSpawn(((Player) sender).getLocation()))
|
if (Spawn.getInstance().setFirstSpawn(((Player) sender).getLocation()))
|
||||||
@ -33,6 +23,5 @@ public class SetFirstSpawnCommand extends ExecutableCommand {
|
|||||||
} catch (NullPointerException ex) {
|
} catch (NullPointerException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,27 +1,17 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
package fr.xephi.authme.command.executable.authme;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.settings.Spawn;
|
import fr.xephi.authme.settings.Spawn;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
import java.util.List;
|
||||||
*/
|
|
||||||
public class SetSpawnCommand extends ExecutableCommand {
|
public class SetSpawnCommand extends ExecutableCommand {
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the command.
|
|
||||||
*
|
|
||||||
* @param sender The command sender.
|
|
||||||
* @param commandReference The command reference.
|
|
||||||
* @param commandArguments The command arguments.
|
|
||||||
*
|
|
||||||
* @return True if the command was executed successfully, false otherwise.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||||
// Make sure the command executor is a player
|
// Make sure the command executor is a player
|
||||||
try {
|
try {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
@ -36,6 +26,5 @@ public class SetSpawnCommand extends ExecutableCommand {
|
|||||||
} catch (NullPointerException ex) {
|
} catch (NullPointerException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,27 +1,17 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
package fr.xephi.authme.command.executable.authme;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.settings.Spawn;
|
import fr.xephi.authme.settings.Spawn;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
import java.util.List;
|
||||||
*/
|
|
||||||
public class SpawnCommand extends ExecutableCommand {
|
public class SpawnCommand extends ExecutableCommand {
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the command.
|
|
||||||
*
|
|
||||||
* @param sender The command sender.
|
|
||||||
* @param commandReference The command reference.
|
|
||||||
* @param commandArguments The command arguments.
|
|
||||||
*
|
|
||||||
* @return True if the command was executed successfully, false otherwise.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||||
// Make sure the command executor is a player
|
// Make sure the command executor is a player
|
||||||
try {
|
try {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
@ -29,11 +19,10 @@ public class SpawnCommand extends ExecutableCommand {
|
|||||||
((Player) sender).teleport(Spawn.getInstance().getSpawn());
|
((Player) sender).teleport(Spawn.getInstance().getSpawn());
|
||||||
else sender.sendMessage("[AuthMe] Spawn has failed, please try to define the spawn");
|
else sender.sendMessage("[AuthMe] Spawn has failed, please try to define the spawn");
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage("[AuthMe] Please use that command in game");
|
sender.sendMessage("[AuthMe] Please use the command in game");
|
||||||
}
|
}
|
||||||
} catch (NullPointerException ex) {
|
} catch (NullPointerException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
package fr.xephi.authme.command.executable.authme;
|
||||||
|
|
||||||
import fr.xephi.authme.AntiBot;
|
import fr.xephi.authme.AntiBot;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.CommandUtils;
|
import fr.xephi.authme.command.CommandUtils;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.command.help.HelpProvider;
|
import fr.xephi.authme.command.help.HelpProvider;
|
||||||
@ -11,56 +10,44 @@ import org.bukkit.command.CommandSender;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class SwitchAntiBotCommand extends ExecutableCommand {
|
public class SwitchAntiBotCommand extends ExecutableCommand {
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the command.
|
|
||||||
*
|
|
||||||
* @param sender The command sender.
|
|
||||||
* @param commandReference The command reference.
|
|
||||||
* @param commandArguments The command arguments.
|
|
||||||
*
|
|
||||||
* @return True if the command was executed successfully, false otherwise.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||||
// Get the new state
|
// Get the new state
|
||||||
String newState = null;
|
String newState = null;
|
||||||
List<String> arguments = commandArguments.getList();
|
|
||||||
|
|
||||||
if (arguments.size() == 1) {
|
if (arguments.size() == 1) {
|
||||||
newState = commandArguments.get(0);
|
newState = arguments.get(0);
|
||||||
} else if (arguments.size() == 0) {
|
} else if (arguments.size() == 0) {
|
||||||
sender.sendMessage("[AuthMe] AntiBot status: " + AntiBot.getAntiBotStatus().name());
|
sender.sendMessage("[AuthMe] AntiBot status: " + AntiBot.getAntiBotStatus().name());
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable the mod
|
// Enable the mod
|
||||||
if ("ON".equalsIgnoreCase(newState)) {
|
if ("ON".equalsIgnoreCase(newState)) {
|
||||||
AntiBot.overrideAntiBotStatus(true);
|
AntiBot.overrideAntiBotStatus(true);
|
||||||
sender.sendMessage("[AuthMe] AntiBot Manual Override: enabled!");
|
sender.sendMessage("[AuthMe] AntiBot Manual Override: enabled!");
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable the mod
|
// Disable the mod
|
||||||
if ("OFF".equalsIgnoreCase(newState)) {
|
if ("OFF".equalsIgnoreCase(newState)) {
|
||||||
AntiBot.overrideAntiBotStatus(false);
|
AntiBot.overrideAntiBotStatus(false);
|
||||||
sender.sendMessage("[AuthMe] AntiBotMod Manual Override: disabled!");
|
sender.sendMessage("[AuthMe] AntiBotMod Manual Override: disabled!");
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show the invalid arguments warning
|
// Show the invalid arguments warning
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "Invalid AntiBot mode!");
|
sender.sendMessage(ChatColor.DARK_RED + "Invalid AntiBot mode!");
|
||||||
|
|
||||||
// Show the command argument help
|
// Show the command argument help
|
||||||
|
// FIXME fix help reference
|
||||||
HelpProvider.showHelp(sender, commandReference, commandReference, true, false, true, false, false, false);
|
HelpProvider.showHelp(sender, commandReference, commandReference, true, false, true, false, false, false);
|
||||||
|
|
||||||
// Show the command to use for detailed help
|
// Show the command to use for detailed help
|
||||||
List<String> helpCommandReference = CollectionUtils.getRange(commandReference.getList(), 1);
|
List<String> helpCommandReference = CollectionUtils.getRange(commandReference.getList(), 1);
|
||||||
sender.sendMessage(ChatColor.GOLD + "Detailed help: " + ChatColor.WHITE + "/"
|
sender.sendMessage(ChatColor.GOLD + "Detailed help: " + ChatColor.WHITE + "/"
|
||||||
+ commandReference.get(0) + " help " + CommandUtils.labelsToString(helpCommandReference));
|
+ commandReference.get(0) + " help " + CommandUtils.labelsToString(helpCommandReference));
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import fr.xephi.authme.AuthMe;
|
|||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
@ -20,22 +19,16 @@ import org.bukkit.potion.PotionEffectType;
|
|||||||
import org.bukkit.scheduler.BukkitScheduler;
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Admin command to unregister a player.
|
* Admin command to unregister a player.
|
||||||
*/
|
*/
|
||||||
public class UnregisterAdminCommand extends ExecutableCommand {
|
public class UnregisterAdminCommand extends ExecutableCommand {
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the command.
|
|
||||||
*
|
|
||||||
* @param sender The command sender.
|
|
||||||
* @param commandReference The command reference.
|
|
||||||
* @param commandArguments The command arguments.
|
|
||||||
*
|
|
||||||
* @return True if the command was executed successfully, false otherwise.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||||
// AuthMe plugin instance
|
// AuthMe plugin instance
|
||||||
final AuthMe plugin = AuthMe.getInstance();
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
|
|
||||||
@ -43,19 +36,19 @@ public class UnregisterAdminCommand extends ExecutableCommand {
|
|||||||
final Messages m = plugin.getMessages();
|
final Messages m = plugin.getMessages();
|
||||||
|
|
||||||
// Get the player name
|
// Get the player name
|
||||||
String playerName = commandArguments.get(0);
|
String playerName = arguments.get(0);
|
||||||
String playerNameLowerCase = playerName.toLowerCase();
|
String playerNameLowerCase = playerName.toLowerCase();
|
||||||
|
|
||||||
// Make sure the user is valid
|
// Make sure the user is valid
|
||||||
if (!plugin.database.isAuthAvailable(playerNameLowerCase)) {
|
if (!plugin.database.isAuthAvailable(playerNameLowerCase)) {
|
||||||
m.send(sender, MessageKey.UNKNOWN_USER);
|
m.send(sender, MessageKey.UNKNOWN_USER);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the player
|
// Remove the player
|
||||||
if (!plugin.database.removeAuth(playerNameLowerCase)) {
|
if (!plugin.database.removeAuth(playerNameLowerCase)) {
|
||||||
m.send(sender, MessageKey.ERROR);
|
m.send(sender, MessageKey.ERROR);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unregister the player
|
// Unregister the player
|
||||||
@ -88,6 +81,5 @@ public class UnregisterAdminCommand extends ExecutableCommand {
|
|||||||
// Show a status message
|
// Show a status message
|
||||||
m.send(sender, MessageKey.UNREGISTERED_SUCCESS);
|
m.send(sender, MessageKey.UNREGISTERED_SUCCESS);
|
||||||
ConsoleLogger.info(playerName + " unregistered");
|
ConsoleLogger.info(playerName + " unregistered");
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,30 +1,19 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
package fr.xephi.authme.command.executable.authme;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
import java.util.List;
|
||||||
*/
|
|
||||||
public class VersionCommand extends ExecutableCommand {
|
public class VersionCommand extends ExecutableCommand {
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the command.
|
|
||||||
*
|
|
||||||
* @param sender The command sender.
|
|
||||||
* @param commandReference The command reference.
|
|
||||||
* @param commandArguments The command arguments.
|
|
||||||
*
|
|
||||||
* @return True if the command was executed successfully, false otherwise.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||||
// Show some version info
|
// Show some version info
|
||||||
sender.sendMessage(ChatColor.GOLD + "==========[ " + Settings.helpHeader.toUpperCase() + " ABOUT ]==========");
|
sender.sendMessage(ChatColor.GOLD + "==========[ " + Settings.helpHeader.toUpperCase() + " ABOUT ]==========");
|
||||||
sender.sendMessage(ChatColor.GOLD + "Version: " + ChatColor.WHITE + AuthMe.getPluginName() + " v" + AuthMe.getPluginVersion() + ChatColor.GRAY + " (build: " + AuthMe.getPluginBuildNumber() + ")");
|
sender.sendMessage(ChatColor.GOLD + "Version: " + ChatColor.WHITE + AuthMe.getPluginName() + " v" + AuthMe.getPluginVersion() + ChatColor.GRAY + " (build: " + AuthMe.getPluginBuildNumber() + ")");
|
||||||
@ -37,7 +26,6 @@ public class VersionCommand extends ExecutableCommand {
|
|||||||
sender.sendMessage(ChatColor.GOLD + "Website: " + ChatColor.WHITE + "http://dev.bukkit.org/bukkit-plugins/authme-reloaded/");
|
sender.sendMessage(ChatColor.GOLD + "Website: " + ChatColor.WHITE + "http://dev.bukkit.org/bukkit-plugins/authme-reloaded/");
|
||||||
sender.sendMessage(ChatColor.GOLD + "License: " + ChatColor.WHITE + "GNU GPL v3.0" + ChatColor.GRAY + ChatColor.ITALIC + " (See LICENSE file)");
|
sender.sendMessage(ChatColor.GOLD + "License: " + ChatColor.WHITE + "GNU GPL v3.0" + ChatColor.GRAY + ChatColor.ITALIC + " (See LICENSE file)");
|
||||||
sender.sendMessage(ChatColor.GOLD + "Copyright: " + ChatColor.WHITE + "Copyright (c) Xephi 2015. All rights reserved.");
|
sender.sendMessage(ChatColor.GOLD + "Copyright: " + ChatColor.WHITE + "Copyright (c) Xephi 2015. All rights reserved.");
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -2,25 +2,24 @@ package fr.xephi.authme.command.executable.captcha;
|
|||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.security.RandomString;
|
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
|
import fr.xephi.authme.security.RandomString;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.util.Wrapper;
|
import fr.xephi.authme.util.Wrapper;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
import java.util.List;
|
||||||
*/
|
|
||||||
public class CaptchaCommand extends ExecutableCommand {
|
public class CaptchaCommand extends ExecutableCommand {
|
||||||
|
|
||||||
@Override
|
@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
|
// Make sure the current command executor is a player
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the player instance and name
|
// Get the player instance and name
|
||||||
@ -28,7 +27,7 @@ public class CaptchaCommand extends ExecutableCommand {
|
|||||||
final String playerNameLowerCase = player.getName().toLowerCase();
|
final String playerNameLowerCase = player.getName().toLowerCase();
|
||||||
|
|
||||||
// Get the parameter values
|
// Get the parameter values
|
||||||
String captcha = commandArguments.get(0);
|
String captcha = arguments.get(0);
|
||||||
|
|
||||||
// AuthMe plugin instance
|
// AuthMe plugin instance
|
||||||
final Wrapper wrapper = Wrapper.getInstance();
|
final Wrapper wrapper = Wrapper.getInstance();
|
||||||
@ -40,18 +39,18 @@ public class CaptchaCommand extends ExecutableCommand {
|
|||||||
// Command logic
|
// Command logic
|
||||||
if (PlayerCache.getInstance().isAuthenticated(playerNameLowerCase)) {
|
if (PlayerCache.getInstance().isAuthenticated(playerNameLowerCase)) {
|
||||||
m.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR);
|
m.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Settings.useCaptcha) {
|
if (!Settings.useCaptcha) {
|
||||||
m.send(player, MessageKey.USAGE_LOGIN);
|
m.send(player, MessageKey.USAGE_LOGIN);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!plugin.cap.containsKey(playerNameLowerCase)) {
|
if (!plugin.cap.containsKey(playerNameLowerCase)) {
|
||||||
m.send(player, MessageKey.USAGE_LOGIN);
|
m.send(player, MessageKey.USAGE_LOGIN);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.useCaptcha && !captcha.equals(plugin.cap.get(playerNameLowerCase))) {
|
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)) {
|
for (String s : m.retrieve(MessageKey.CAPTCHA_WRONG_ERROR)) {
|
||||||
player.sendMessage(s.replace("THE_CAPTCHA", plugin.cap.get(playerNameLowerCase)));
|
player.sendMessage(s.replace("THE_CAPTCHA", plugin.cap.get(playerNameLowerCase)));
|
||||||
}
|
}
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.captcha.remove(playerNameLowerCase);
|
plugin.captcha.remove(playerNameLowerCase);
|
||||||
@ -70,6 +69,5 @@ public class CaptchaCommand extends ExecutableCommand {
|
|||||||
// Show a status message
|
// Show a status message
|
||||||
m.send(player, MessageKey.CAPTCHA_SUCCESS);
|
m.send(player, MessageKey.CAPTCHA_SUCCESS);
|
||||||
m.send(player, MessageKey.LOGIN_MESSAGE);
|
m.send(player, MessageKey.LOGIN_MESSAGE);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package fr.xephi.authme.command.executable.changepassword;
|
|||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
@ -12,24 +11,26 @@ import fr.xephi.authme.util.Wrapper;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The command for a player to change his password with.
|
* The command for a player to change his password with.
|
||||||
*/
|
*/
|
||||||
public class ChangePasswordCommand extends ExecutableCommand {
|
public class ChangePasswordCommand extends ExecutableCommand {
|
||||||
|
|
||||||
@Override
|
@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
|
// Make sure the current command executor is a player
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Wrapper wrapper = Wrapper.getInstance();
|
final Wrapper wrapper = Wrapper.getInstance();
|
||||||
final Messages m = wrapper.getMessages();
|
final Messages m = wrapper.getMessages();
|
||||||
|
|
||||||
// Get the passwords
|
// Get the passwords
|
||||||
String oldPassword = commandArguments.get(0);
|
String oldPassword = arguments.get(0);
|
||||||
String newPassword = commandArguments.get(1);
|
String newPassword = arguments.get(1);
|
||||||
|
|
||||||
// Get the player instance and make sure he's authenticated
|
// Get the player instance and make sure he's authenticated
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
@ -37,7 +38,7 @@ public class ChangePasswordCommand extends ExecutableCommand {
|
|||||||
final PlayerCache playerCache = wrapper.getPlayerCache();
|
final PlayerCache playerCache = wrapper.getPlayerCache();
|
||||||
if (!playerCache.isAuthenticated(name)) {
|
if (!playerCache.isAuthenticated(name)) {
|
||||||
m.send(player, MessageKey.NOT_LOGGED_IN);
|
m.send(player, MessageKey.NOT_LOGGED_IN);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the password is allowed
|
// Make sure the password is allowed
|
||||||
@ -48,26 +49,25 @@ public class ChangePasswordCommand extends ExecutableCommand {
|
|||||||
|| playerPassLowerCase.contains(";") || playerPassLowerCase.contains("null")
|
|| playerPassLowerCase.contains(";") || playerPassLowerCase.contains("null")
|
||||||
|| !playerPassLowerCase.matches(Settings.getPassRegex)) {
|
|| !playerPassLowerCase.matches(Settings.getPassRegex)) {
|
||||||
m.send(player, MessageKey.PASSWORD_MATCH_ERROR);
|
m.send(player, MessageKey.PASSWORD_MATCH_ERROR);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
if (playerPassLowerCase.equalsIgnoreCase(name)) {
|
if (playerPassLowerCase.equalsIgnoreCase(name)) {
|
||||||
m.send(player, MessageKey.PASSWORD_IS_USERNAME_ERROR);
|
m.send(player, MessageKey.PASSWORD_IS_USERNAME_ERROR);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
if (playerPassLowerCase.length() < Settings.getPasswordMinLen
|
if (playerPassLowerCase.length() < Settings.getPasswordMinLen
|
||||||
|| playerPassLowerCase.length() > Settings.passwordMaxLength) {
|
|| playerPassLowerCase.length() > Settings.passwordMaxLength) {
|
||||||
m.send(player, MessageKey.INVALID_PASSWORD_LENGTH);
|
m.send(player, MessageKey.INVALID_PASSWORD_LENGTH);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
if (!Settings.unsafePasswords.isEmpty() && Settings.unsafePasswords.contains(playerPassLowerCase)) {
|
if (!Settings.unsafePasswords.isEmpty() && Settings.unsafePasswords.contains(playerPassLowerCase)) {
|
||||||
m.send(player, MessageKey.PASSWORD_UNSAFE_ERROR);
|
m.send(player, MessageKey.PASSWORD_UNSAFE_ERROR);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the password
|
// Set the password
|
||||||
final AuthMe plugin = wrapper.getAuthMe();
|
final AuthMe plugin = wrapper.getAuthMe();
|
||||||
wrapper.getScheduler().runTaskAsynchronously(plugin,
|
wrapper.getScheduler().runTaskAsynchronously(plugin,
|
||||||
new ChangePasswordTask(plugin, player, oldPassword, newPassword));
|
new ChangePasswordTask(plugin, player, oldPassword, newPassword));
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,29 +1,27 @@
|
|||||||
package fr.xephi.authme.command.executable.converter;
|
package fr.xephi.authme.command.executable.converter;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.converter.*;
|
import fr.xephi.authme.converter.Converter;
|
||||||
|
import fr.xephi.authme.converter.CrazyLoginConverter;
|
||||||
|
import fr.xephi.authme.converter.FlatToSql;
|
||||||
|
import fr.xephi.authme.converter.FlatToSqlite;
|
||||||
|
import fr.xephi.authme.converter.RakamakConverter;
|
||||||
|
import fr.xephi.authme.converter.RoyalAuthConverter;
|
||||||
|
import fr.xephi.authme.converter.SqlToFlat;
|
||||||
|
import fr.xephi.authme.converter.vAuthConverter;
|
||||||
|
import fr.xephi.authme.converter.xAuthConverter;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
/**
|
import java.util.List;
|
||||||
*/
|
|
||||||
public class ConverterCommand extends ExecutableCommand {
|
public class ConverterCommand extends ExecutableCommand {
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the command.
|
|
||||||
*
|
|
||||||
* @param sender The command sender.
|
|
||||||
* @param commandReference The command reference.
|
|
||||||
* @param commandArguments The command arguments.
|
|
||||||
*
|
|
||||||
* @return True if the command was executed successfully, false otherwise.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||||
// AuthMe plugin instance
|
// AuthMe plugin instance
|
||||||
final AuthMe plugin = AuthMe.getInstance();
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
|
|
||||||
@ -31,40 +29,40 @@ public class ConverterCommand extends ExecutableCommand {
|
|||||||
final Messages m = plugin.getMessages();
|
final Messages m = plugin.getMessages();
|
||||||
|
|
||||||
// Get the conversion job
|
// Get the conversion job
|
||||||
String job = commandArguments.get(0);
|
String job = arguments.get(0);
|
||||||
|
|
||||||
// Determine the job type
|
// Determine the job type
|
||||||
ConvertType jobType = ConvertType.fromName(job);
|
ConvertType jobType = ConvertType.fromName(job);
|
||||||
if (jobType == null) {
|
if (jobType == null) {
|
||||||
m.send(sender, MessageKey.ERROR);
|
m.send(sender, MessageKey.ERROR);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the proper converter instance
|
// Get the proper converter instance
|
||||||
Converter converter = null;
|
Converter converter = null;
|
||||||
switch (jobType) {
|
switch (jobType) {
|
||||||
case ftsql:
|
case FTSQL:
|
||||||
converter = new FlatToSql();
|
converter = new FlatToSql();
|
||||||
break;
|
break;
|
||||||
case ftsqlite:
|
case FTSQLITE:
|
||||||
converter = new FlatToSqlite(sender);
|
converter = new FlatToSqlite(sender);
|
||||||
break;
|
break;
|
||||||
case xauth:
|
case XAUTH:
|
||||||
converter = new xAuthConverter(plugin, sender);
|
converter = new xAuthConverter(plugin, sender);
|
||||||
break;
|
break;
|
||||||
case crazylogin:
|
case CRAZYLOGIN:
|
||||||
converter = new CrazyLoginConverter(plugin, sender);
|
converter = new CrazyLoginConverter(plugin, sender);
|
||||||
break;
|
break;
|
||||||
case rakamak:
|
case RAKAMAK:
|
||||||
converter = new RakamakConverter(plugin, sender);
|
converter = new RakamakConverter(plugin, sender);
|
||||||
break;
|
break;
|
||||||
case royalauth:
|
case ROYALAUTH:
|
||||||
converter = new RoyalAuthConverter(plugin);
|
converter = new RoyalAuthConverter(plugin);
|
||||||
break;
|
break;
|
||||||
case vauth:
|
case VAUTH:
|
||||||
converter = new vAuthConverter(plugin, sender);
|
converter = new vAuthConverter(plugin, sender);
|
||||||
break;
|
break;
|
||||||
case sqltoflat:
|
case SQLTOFLAT:
|
||||||
converter = new SqlToFlat(plugin, sender);
|
converter = new SqlToFlat(plugin, sender);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -76,52 +74,33 @@ public class ConverterCommand extends ExecutableCommand {
|
|||||||
|
|
||||||
// Show a status message
|
// Show a status message
|
||||||
sender.sendMessage("[AuthMe] Successfully converted from " + jobType.getName());
|
sender.sendMessage("[AuthMe] Successfully converted from " + jobType.getName());
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public enum ConvertType {
|
public enum ConvertType {
|
||||||
ftsql("flattosql"),
|
FTSQL("flattosql"),
|
||||||
ftsqlite("flattosqlite"),
|
FTSQLITE("flattosqlite"),
|
||||||
xauth("xauth"),
|
XAUTH("xauth"),
|
||||||
crazylogin("crazylogin"),
|
CRAZYLOGIN("crazylogin"),
|
||||||
rakamak("rakamak"),
|
RAKAMAK("rakamak"),
|
||||||
royalauth("royalauth"),
|
ROYALAUTH("royalauth"),
|
||||||
vauth("vauth"),
|
VAUTH("vauth"),
|
||||||
sqltoflat("sqltoflat");
|
SQLTOFLAT("sqltoflat");
|
||||||
|
|
||||||
final String name;
|
final String name;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for ConvertType.
|
|
||||||
*
|
|
||||||
* @param name String
|
|
||||||
*/
|
|
||||||
ConvertType(String name) {
|
ConvertType(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method fromName.
|
|
||||||
*
|
|
||||||
* @param name String
|
|
||||||
*
|
|
||||||
* @return ConvertType
|
|
||||||
*/
|
|
||||||
public static ConvertType fromName(String name) {
|
public static ConvertType fromName(String name) {
|
||||||
for (ConvertType type : ConvertType.values()) {
|
for (ConvertType type : ConvertType.values()) {
|
||||||
if (type.getName().equalsIgnoreCase(name))
|
if (type.getName().equalsIgnoreCase(name)) {
|
||||||
return type;
|
return type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getName.
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
String getName() {
|
String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,31 +1,29 @@
|
|||||||
package fr.xephi.authme.command.executable.email;
|
package fr.xephi.authme.command.executable.email;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.util.Wrapper;
|
import fr.xephi.authme.util.Wrapper;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
import java.util.List;
|
||||||
*/
|
|
||||||
public class AddEmailCommand extends ExecutableCommand {
|
public class AddEmailCommand extends ExecutableCommand {
|
||||||
|
|
||||||
@Override
|
@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
|
// Make sure the current command executor is a player
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the parameter values
|
// Get the parameter values
|
||||||
String playerMail = commandArguments.get(0);
|
String playerMail = arguments.get(0);
|
||||||
String playerMailVerify = commandArguments.get(1);
|
String playerMailVerify = arguments.get(1);
|
||||||
|
|
||||||
// Get the player and perform email addition
|
// Get the player and perform email addition
|
||||||
final AuthMe plugin = Wrapper.getInstance().getAuthMe();
|
final AuthMe plugin = Wrapper.getInstance().getAuthMe();
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
plugin.getManagement().performAddEmail(player, playerMail, playerMailVerify);
|
plugin.getManagement().performAddEmail(player, playerMail, playerMailVerify);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,31 +1,31 @@
|
|||||||
package fr.xephi.authme.command.executable.email;
|
package fr.xephi.authme.command.executable.email;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.util.Wrapper;
|
import fr.xephi.authme.util.Wrapper;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class ChangeEmailCommand extends ExecutableCommand {
|
public class ChangeEmailCommand extends ExecutableCommand {
|
||||||
|
|
||||||
@Override
|
@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
|
// Make sure the current command executor is a player
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the parameter values
|
// Get the parameter values
|
||||||
String playerMailOld = commandArguments.get(0);
|
String playerMailOld = arguments.get(0);
|
||||||
String playerMailNew = commandArguments.get(1);
|
String playerMailNew = arguments.get(1);
|
||||||
|
|
||||||
// Get the player instance and execute action
|
// Get the player instance and execute action
|
||||||
final AuthMe plugin = Wrapper.getInstance().getAuthMe();
|
final AuthMe plugin = Wrapper.getInstance().getAuthMe();
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
plugin.getManagement().performChangeEmail(player, playerMailOld, playerMailNew);
|
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.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
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.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
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.settings.Settings;
|
||||||
import fr.xephi.authme.util.Wrapper;
|
import fr.xephi.authme.util.Wrapper;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class RecoverEmailCommand extends ExecutableCommand {
|
public class RecoverEmailCommand extends ExecutableCommand {
|
||||||
|
|
||||||
@Override
|
@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
|
// Make sure the current command executor is a player
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the parameter values
|
// Get the parameter values
|
||||||
String playerMail = commandArguments.get(0);
|
String playerMail = arguments.get(0);
|
||||||
|
|
||||||
// Get the player instance and name
|
// Get the player instance and name
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
@ -42,12 +40,12 @@ public class RecoverEmailCommand extends ExecutableCommand {
|
|||||||
|
|
||||||
if (plugin.mail == null) {
|
if (plugin.mail == null) {
|
||||||
m.send(player, MessageKey.ERROR);
|
m.send(player, MessageKey.ERROR);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
if (plugin.database.isAuthAvailable(playerName)) {
|
if (plugin.database.isAuthAvailable(playerName)) {
|
||||||
if (PlayerCache.getInstance().isAuthenticated(playerName)) {
|
if (PlayerCache.getInstance().isAuthenticated(playerName)) {
|
||||||
m.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR);
|
m.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
RandomString rand = new RandomString(Settings.getRecoveryPassLength);
|
RandomString rand = new RandomString(Settings.getRecoveryPassLength);
|
||||||
@ -60,16 +58,17 @@ public class RecoverEmailCommand extends ExecutableCommand {
|
|||||||
auth = plugin.database.getAuth(playerName);
|
auth = plugin.database.getAuth(playerName);
|
||||||
} else {
|
} else {
|
||||||
m.send(player, MessageKey.UNKNOWN_USER);
|
m.send(player, MessageKey.UNKNOWN_USER);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
if (Settings.getmailAccount.equals("") || Settings.getmailAccount.isEmpty()) {
|
if (Settings.getmailAccount.equals("") || Settings.getmailAccount.isEmpty()) {
|
||||||
m.send(player, MessageKey.ERROR);
|
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);
|
m.send(player, MessageKey.INVALID_EMAIL);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
auth.setHash(hashNew);
|
auth.setHash(hashNew);
|
||||||
plugin.database.updatePassword(auth);
|
plugin.database.updatePassword(auth);
|
||||||
@ -83,7 +82,5 @@ public class RecoverEmailCommand extends ExecutableCommand {
|
|||||||
} else {
|
} else {
|
||||||
m.send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
|
m.send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,30 +1,28 @@
|
|||||||
package fr.xephi.authme.command.executable.login;
|
package fr.xephi.authme.command.executable.login;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.util.Wrapper;
|
import fr.xephi.authme.util.Wrapper;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
import java.util.List;
|
||||||
*/
|
|
||||||
public class LoginCommand extends ExecutableCommand {
|
public class LoginCommand extends ExecutableCommand {
|
||||||
|
|
||||||
@Override
|
@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
|
// Make sure the current command executor is a player
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the necessary objects
|
// Get the necessary objects
|
||||||
final AuthMe plugin = Wrapper.getInstance().getAuthMe();
|
final AuthMe plugin = Wrapper.getInstance().getAuthMe();
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final String password = commandArguments.get(0);
|
final String password = arguments.get(0);
|
||||||
|
|
||||||
// Log the player in
|
// Log the player in
|
||||||
plugin.getManagement().performLogin(player, password, false);
|
plugin.getManagement().performLogin(player, password, false);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +1,22 @@
|
|||||||
package fr.xephi.authme.command.executable.logout;
|
package fr.xephi.authme.command.executable.logout;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.util.Wrapper;
|
import fr.xephi.authme.util.Wrapper;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class LogoutCommand extends ExecutableCommand {
|
public class LogoutCommand extends ExecutableCommand {
|
||||||
|
|
||||||
@Override
|
@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
|
// Make sure the current command executor is a player
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the player instance
|
// Get the player instance
|
||||||
@ -24,6 +25,5 @@ public class LogoutCommand extends ExecutableCommand {
|
|||||||
|
|
||||||
// Logout the player
|
// Logout the player
|
||||||
plugin.getManagement().performLogout(player);
|
plugin.getManagement().performLogout(player);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
package fr.xephi.authme.command.executable.register;
|
package fr.xephi.authme.command.executable.register;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.process.Management;
|
|
||||||
import fr.xephi.authme.security.RandomString;
|
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
|
import fr.xephi.authme.process.Management;
|
||||||
|
import fr.xephi.authme.security.RandomString;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.util.Wrapper;
|
import fr.xephi.authme.util.Wrapper;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -14,20 +13,16 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class RegisterCommand extends ExecutableCommand {
|
public class RegisterCommand extends ExecutableCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||||
// Make sure the sender is a player
|
// Make sure the sender is a player
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage("Player Only! Use 'authme register <playername> <password>' instead");
|
sender.sendMessage("Player Only! Use 'authme register <playername> <password>' instead");
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> arguments = commandArguments.getList();
|
|
||||||
|
|
||||||
final Wrapper wrapper = Wrapper.getInstance();
|
final Wrapper wrapper = Wrapper.getInstance();
|
||||||
final AuthMe plugin = wrapper.getAuthMe();
|
final AuthMe plugin = wrapper.getAuthMe();
|
||||||
final Messages m = wrapper.getMessages();
|
final Messages m = wrapper.getMessages();
|
||||||
@ -36,31 +31,30 @@ public class RegisterCommand extends ExecutableCommand {
|
|||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
if (arguments.isEmpty() || (Settings.getEnablePasswordVerifier && arguments.size() < 2)) {
|
if (arguments.isEmpty() || (Settings.getEnablePasswordVerifier && arguments.size() < 2)) {
|
||||||
m.send(player, MessageKey.USAGE_REGISTER);
|
m.send(player, MessageKey.USAGE_REGISTER);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Management management = plugin.getManagement();
|
final Management management = plugin.getManagement();
|
||||||
if (Settings.emailRegistration && !Settings.getmailAccount.isEmpty()) {
|
if (Settings.emailRegistration && !Settings.getmailAccount.isEmpty()) {
|
||||||
if (Settings.doubleEmailCheck && arguments.size() < 2 || !arguments.get(0).equals(arguments.get(1))) {
|
if (Settings.doubleEmailCheck && arguments.size() < 2 || !arguments.get(0).equals(arguments.get(1))) {
|
||||||
m.send(player, MessageKey.USAGE_REGISTER);
|
m.send(player, MessageKey.USAGE_REGISTER);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
final String email = arguments.get(0);
|
final String email = arguments.get(0);
|
||||||
if (!Settings.isEmailCorrect(email)) {
|
if (!Settings.isEmailCorrect(email)) {
|
||||||
m.send(player, MessageKey.INVALID_EMAIL);
|
m.send(player, MessageKey.INVALID_EMAIL);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
final String thePass = new RandomString(Settings.getRecoveryPassLength).nextString();
|
final String thePass = new RandomString(Settings.getRecoveryPassLength).nextString();
|
||||||
management.performRegister(player, thePass, email);
|
management.performRegister(player, thePass, email);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
if (arguments.size() > 1 && Settings.getEnablePasswordVerifier) {
|
if (arguments.size() > 1 && Settings.getEnablePasswordVerifier) {
|
||||||
if (!arguments.get(0).equals(commandArguments.get(1))) {
|
if (!arguments.get(0).equals(arguments.get(1))) {
|
||||||
m.send(player, MessageKey.PASSWORD_MATCH_ERROR);
|
m.send(player, MessageKey.PASSWORD_MATCH_ERROR);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
management.performRegister(player, commandArguments.get(0), "");
|
management.performRegister(player, arguments.get(0), "");
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,41 +2,28 @@ package fr.xephi.authme.command.executable.unregister;
|
|||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
import java.util.List;
|
||||||
*/
|
|
||||||
public class UnregisterCommand extends ExecutableCommand {
|
public class UnregisterCommand extends ExecutableCommand {
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the command.
|
|
||||||
*
|
|
||||||
* @param sender The command sender.
|
|
||||||
* @param commandReference The command reference.
|
|
||||||
* @param commandArguments The command arguments.
|
|
||||||
*
|
|
||||||
* @return True if the command was executed successfully, false otherwise.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||||
// AuthMe plugin instance
|
|
||||||
final AuthMe plugin = AuthMe.getInstance();
|
|
||||||
|
|
||||||
// Messages instance
|
|
||||||
final Messages m = plugin.getMessages();
|
|
||||||
|
|
||||||
// Make sure the current command executor is a player
|
// Make sure the current command executor is a player
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
|
final Messages m = plugin.getMessages();
|
||||||
|
|
||||||
// Get the password
|
// Get the password
|
||||||
String playerPass = commandArguments.get(0);
|
String playerPass = arguments.get(0);
|
||||||
|
|
||||||
// Get the player instance and name
|
// Get the player instance and name
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
@ -45,11 +32,10 @@ public class UnregisterCommand extends ExecutableCommand {
|
|||||||
// Make sure the player is authenticated
|
// Make sure the player is authenticated
|
||||||
if (!PlayerCache.getInstance().isAuthenticated(playerNameLowerCase)) {
|
if (!PlayerCache.getInstance().isAuthenticated(playerNameLowerCase)) {
|
||||||
m.send(player, MessageKey.NOT_LOGGED_IN);
|
m.send(player, MessageKey.NOT_LOGGED_IN);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unregister the player
|
// Unregister the player
|
||||||
plugin.getManagement().performUnregister(player, playerPass, false);
|
plugin.getManagement().performUnregister(player, playerPass, false);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,7 +69,7 @@ public class HelpPrinter {
|
|||||||
for (CommandArgumentDescription arg : command.getArguments()) {
|
for (CommandArgumentDescription arg : command.getArguments()) {
|
||||||
// Create a string builder to build the syntax in
|
// Create a string builder to build the syntax in
|
||||||
StringBuilder argString = new StringBuilder();
|
StringBuilder argString = new StringBuilder();
|
||||||
argString.append(" " + ChatColor.YELLOW + ChatColor.ITALIC + arg.getLabel() + " : " + ChatColor.WHITE + arg.getDescription());
|
argString.append(" " + ChatColor.YELLOW + ChatColor.ITALIC + arg.getName() + " : " + ChatColor.WHITE + arg.getDescription());
|
||||||
|
|
||||||
// Suffix a note if the command is optional
|
// Suffix a note if the command is optional
|
||||||
if (arg.isOptional())
|
if (arg.isOptional())
|
||||||
|
|||||||
@ -29,6 +29,13 @@ public class HelpProvider {
|
|||||||
showHelp(sender, reference, helpQuery, true, true, true, true, true, true);
|
showHelp(sender, reference, helpQuery, true, true, true, true, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void showHelp(CommandSender sender, CommandParts reference, CommandParts helpQuery,
|
||||||
|
boolean showCommand, boolean showDescription, boolean showArguments,
|
||||||
|
boolean showPermissions, boolean showAlternatives, boolean showCommands) {
|
||||||
|
showHelp(sender, reference.getList(), helpQuery.getList(), showCommand, showDescription, showArguments,
|
||||||
|
showPermissions, showAlternatives, showCommands);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show help for a specific command.
|
* Show help for a specific command.
|
||||||
*
|
*
|
||||||
@ -42,7 +49,9 @@ public class HelpProvider {
|
|||||||
* @param showAlternatives True to show the command alternatives.
|
* @param showAlternatives True to show the command alternatives.
|
||||||
* @param showCommands True to show the child commands.
|
* @param showCommands True to show the child commands.
|
||||||
*/
|
*/
|
||||||
public static void showHelp(CommandSender sender, CommandParts reference, CommandParts helpQuery, boolean showCommand, boolean showDescription, boolean showArguments, boolean showPermissions, boolean showAlternatives, boolean showCommands) {
|
public static void showHelp(CommandSender sender, List<String> reference, List<String> helpQuery,
|
||||||
|
boolean showCommand, boolean showDescription, boolean showArguments,
|
||||||
|
boolean showPermissions, boolean showAlternatives, boolean showCommands) {
|
||||||
// Find the command for this help query, one with and one without a prefixed base command
|
// Find the command for this help query, one with and one without a prefixed base command
|
||||||
FoundCommandResult result = AuthMe.getInstance().getCommandHandler().findCommand(new CommandParts(helpQuery.getList()));
|
FoundCommandResult result = AuthMe.getInstance().getCommandHandler().findCommand(new CommandParts(helpQuery.getList()));
|
||||||
|
|
||||||
@ -77,7 +86,7 @@ public class HelpProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the proper command reference to use for the help page
|
// Get the proper command reference to use for the help page
|
||||||
CommandParts commandReference = command.getCommandReference(result.getQueryReference());
|
CommandParts commandReference = command.getCommandReference(result.getLabels());
|
||||||
|
|
||||||
// Get the base command
|
// Get the base command
|
||||||
String baseCommand = commandReference.get(0);
|
String baseCommand = commandReference.get(0);
|
||||||
|
|||||||
@ -73,8 +73,8 @@ public final class HelpSyntaxHelper {
|
|||||||
|
|
||||||
private static String formatArgument(CommandArgumentDescription argument) {
|
private static String formatArgument(CommandArgumentDescription argument) {
|
||||||
if (argument.isOptional()) {
|
if (argument.isOptional()) {
|
||||||
return " [" + argument.getLabel() + "]";
|
return " [" + argument.getName() + "]";
|
||||||
}
|
}
|
||||||
return " <" + argument.getLabel() + ">";
|
return " <" + argument.getName() + ">";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package fr.xephi.authme.command;
|
package fr.xephi.authme.command;
|
||||||
|
|
||||||
import fr.xephi.authme.permission.DefaultPermission;
|
import fr.xephi.authme.permission.DefaultPermission;
|
||||||
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.permission.PlayerPermission;
|
import fr.xephi.authme.permission.PlayerPermission;
|
||||||
import fr.xephi.authme.util.WrapperMock;
|
import fr.xephi.authme.util.WrapperMock;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -21,7 +22,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
|||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.stringContainsInOrder;
|
import static org.hamcrest.Matchers.stringContainsInOrder;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.anyListOf;
|
||||||
import static org.mockito.Matchers.anyString;
|
import static org.mockito.Matchers.anyString;
|
||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.Matchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
@ -35,6 +36,7 @@ public class CommandHandlerTest {
|
|||||||
|
|
||||||
private static Set<CommandDescription> commands;
|
private static Set<CommandDescription> commands;
|
||||||
private static CommandHandler handler;
|
private static CommandHandler handler;
|
||||||
|
private static PermissionsManager permissionsManagerMock;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpCommandHandler() {
|
public static void setUpCommandHandler() {
|
||||||
@ -47,7 +49,8 @@ public class CommandHandlerTest {
|
|||||||
|
|
||||||
CommandDescription testBase = createCommand(null, null, singletonList("test"), newArgument("test", true));
|
CommandDescription testBase = createCommand(null, null, singletonList("test"), newArgument("test", true));
|
||||||
commands = new HashSet<>(asList(authMeBase, testBase));
|
commands = new HashSet<>(asList(authMeBase, testBase));
|
||||||
handler = new CommandHandler(commands);
|
permissionsManagerMock = mock(PermissionsManager.class);
|
||||||
|
handler = new CommandHandler(commands, permissionsManagerMock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -65,8 +68,7 @@ public class CommandHandlerTest {
|
|||||||
// then
|
// then
|
||||||
final CommandDescription loginCmd = getChildWithLabel("login", getCommandWithLabel("authme", commands));
|
final CommandDescription loginCmd = getChildWithLabel("login", getCommandWithLabel("authme", commands));
|
||||||
verify(sender, never()).sendMessage(anyString());
|
verify(sender, never()).sendMessage(anyString());
|
||||||
verify(loginCmd.getExecutableCommand()).executeCommand(
|
verify(loginCmd.getExecutableCommand()).executeCommand(eq(sender), anyListOf(String.class));
|
||||||
eq(sender), any(CommandParts.class), any(CommandParts.class));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -98,7 +100,7 @@ public class CommandHandlerTest {
|
|||||||
|
|
||||||
if (arguments != null && arguments.length > 0) {
|
if (arguments != null && arguments.length > 0) {
|
||||||
for (CommandArgumentDescription argument : arguments) {
|
for (CommandArgumentDescription argument : arguments) {
|
||||||
command.withArgument(argument.getLabel(), "Test description", argument.isOptional());
|
command.withArgument(argument.getName(), "Test description", argument.isOptional());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user