Merge enum branch into master
This commit is contained in:
@@ -226,11 +226,11 @@ public class CommandDescription {
|
||||
*/
|
||||
public void setLabels(List<String> labels) {
|
||||
// Check whether the command label list should be cleared
|
||||
if (labels == null)
|
||||
if (labels == null) {
|
||||
this.labels.clear();
|
||||
|
||||
else
|
||||
} else {
|
||||
this.labels = labels;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -344,7 +344,7 @@ public class CommandDescription {
|
||||
/**
|
||||
* Get the absolute command label, without a slash.
|
||||
*
|
||||
* @return String
|
||||
* @return the absolute label
|
||||
*/
|
||||
public String getAbsoluteLabel() {
|
||||
return getAbsoluteLabel(false);
|
||||
@@ -364,8 +364,8 @@ public class CommandDescription {
|
||||
/**
|
||||
* Get the absolute command label.
|
||||
*
|
||||
* @param includeSlash boolean
|
||||
* @param reference CommandParts
|
||||
* @param includeSlash
|
||||
* @param reference
|
||||
*
|
||||
* @return Absolute command label.
|
||||
*/
|
||||
@@ -644,11 +644,11 @@ public class CommandDescription {
|
||||
*/
|
||||
public void setArguments(List<CommandArgumentDescription> arguments) {
|
||||
// Convert null into an empty argument list
|
||||
if (arguments == null)
|
||||
if (arguments == null) {
|
||||
this.arguments.clear();
|
||||
|
||||
else
|
||||
} else {
|
||||
this.arguments = arguments;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -659,12 +659,7 @@ public class CommandDescription {
|
||||
* @return True if this argument already exists, false otherwise.
|
||||
*/
|
||||
public boolean hasArgument(CommandArgumentDescription argument) {
|
||||
// Make sure the argument is valid
|
||||
if (argument == null)
|
||||
return false;
|
||||
|
||||
// Check whether the argument exists, return the result
|
||||
return this.arguments.contains(argument);
|
||||
return argument != null && arguments.contains(argument);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -881,19 +876,22 @@ public class CommandDescription {
|
||||
*/
|
||||
public int getSuitableArgumentsDifference(CommandParts commandReference) {
|
||||
// Make sure the command reference is valid
|
||||
if (commandReference.getCount() <= 0)
|
||||
if (commandReference.getCount() <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get the remaining command reference element count
|
||||
int remainingElementCount = commandReference.getCount() - getParentCount() - 1;
|
||||
|
||||
// Check if there are too less arguments
|
||||
if (getMinimumArguments() > remainingElementCount)
|
||||
// Check if there are too few arguments
|
||||
if (getMinimumArguments() > remainingElementCount) {
|
||||
return Math.abs(getMinimumArguments() - remainingElementCount);
|
||||
}
|
||||
|
||||
// Check if there are too many arguments
|
||||
if (getMaximumArguments() < remainingElementCount && getMaximumArguments() >= 0)
|
||||
if (getMaximumArguments() < remainingElementCount && getMaximumArguments() >= 0) {
|
||||
return Math.abs(remainingElementCount - getMaximumArguments());
|
||||
}
|
||||
|
||||
// The arguments seem to be EQUALS, return the result
|
||||
return 0;
|
||||
@@ -934,12 +932,14 @@ public class CommandDescription {
|
||||
*/
|
||||
public boolean isValid() {
|
||||
// Make sure any command label is set
|
||||
if (getLabels().size() == 0)
|
||||
if (getLabels().size() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make sure the permissions are set up properly
|
||||
if (this.permissions == null)
|
||||
if (this.permissions == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Everything seems to be correct, return the result
|
||||
return true;
|
||||
|
||||
+9
-10
@@ -17,6 +17,11 @@ public class ChangePasswordCommand extends ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// Make sure the current command executor is a player
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final AuthMe plugin = AuthMe.getInstance();
|
||||
final Messages m = plugin.getMessages();
|
||||
|
||||
@@ -24,11 +29,6 @@ public class ChangePasswordCommand extends ExecutableCommand {
|
||||
String playerPass = commandArguments.get(0);
|
||||
String playerPassVerify = commandArguments.get(1);
|
||||
|
||||
// Make sure the current command executor is a player
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get the player instance and make sure it's authenticated
|
||||
Player player = (Player) sender;
|
||||
String name = player.getName().toLowerCase();
|
||||
@@ -38,6 +38,7 @@ public class ChangePasswordCommand extends ExecutableCommand {
|
||||
}
|
||||
|
||||
// Make sure the password is allowed
|
||||
// TODO ljacqu 20151121: The password confirmation appears to be never verified
|
||||
String playerPassLowerCase = playerPass.toLowerCase();
|
||||
if (playerPassLowerCase.contains("delete") || playerPassLowerCase.contains("where")
|
||||
|| playerPassLowerCase.contains("insert") || playerPassLowerCase.contains("modify")
|
||||
@@ -56,11 +57,9 @@ public class ChangePasswordCommand extends ExecutableCommand {
|
||||
m.send(player, MessageKey.INVALID_PASSWORD_LENGTH);
|
||||
return true;
|
||||
}
|
||||
if (!Settings.unsafePasswords.isEmpty()) {
|
||||
if (Settings.unsafePasswords.contains(playerPassLowerCase)) {
|
||||
m.send(player, MessageKey.PASSWORD_UNSAFE_ERROR);
|
||||
return true;
|
||||
}
|
||||
if (!Settings.unsafePasswords.isEmpty() && Settings.unsafePasswords.contains(playerPassLowerCase)) {
|
||||
m.send(player, MessageKey.PASSWORD_UNSAFE_ERROR);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Set the password
|
||||
|
||||
@@ -12,19 +12,19 @@ public class AddEmailCommand extends ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// Get the parameter values
|
||||
String playerMail = commandArguments.get(0);
|
||||
String playerMailVerify = commandArguments.get(1);
|
||||
|
||||
// Make sure the current command executor is a player
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get the parameter values
|
||||
String playerMail = commandArguments.get(0);
|
||||
String playerMailVerify = commandArguments.get(1);
|
||||
|
||||
// Get the player and perform email addition
|
||||
final AuthMe plugin = AuthMe.getInstance();
|
||||
final Player player = (Player) sender;
|
||||
plugin.management.performAddEmail(player, playerMail, playerMailVerify);
|
||||
plugin.getManagement().performAddEmail(player, playerMail, playerMailVerify);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,19 +12,19 @@ public class ChangeEmailCommand extends ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// Get the parameter values
|
||||
String playerMailOld = commandArguments.get(0);
|
||||
String playerMailNew = commandArguments.get(1);
|
||||
|
||||
// Make sure the current command executor is a player
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get the parameter values
|
||||
String playerMailOld = commandArguments.get(0);
|
||||
String playerMailNew = commandArguments.get(1);
|
||||
|
||||
// Get the player instance and execute action
|
||||
final AuthMe plugin = AuthMe.getInstance();
|
||||
final Player player = (Player) sender;
|
||||
plugin.management.performChangeEmail(player, playerMailOld, playerMailNew);
|
||||
plugin.getManagement().performChangeEmail(player, playerMailOld, playerMailNew);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,14 +22,14 @@ public class RecoverEmailCommand extends ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// Get the parameter values
|
||||
String playerMail = commandArguments.get(0);
|
||||
|
||||
// Make sure the current command executor is a player
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get the parameter values
|
||||
String playerMail = commandArguments.get(0);
|
||||
|
||||
// Get the player instance and name
|
||||
final Player player = (Player) sender;
|
||||
final String playerName = player.getName();
|
||||
|
||||
Reference in New Issue
Block a user