Add some tests, minor Checkstyle fixes
This commit is contained in:
@@ -5,7 +5,6 @@ import org.bukkit.ChatColor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Utility functions for {@link CommandDescription} objects.
|
||||
@@ -76,19 +75,14 @@ public final class CommandUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a textual representation of the command, including its arguments.
|
||||
* For example: {@code /authme purge <days> [includeZero]}.
|
||||
* Constructs a command path with color formatting, based on the supplied labels. This includes
|
||||
* the command's arguments, as defined in the provided command description. The list of labels
|
||||
* must contain all labels to be used.
|
||||
*
|
||||
* @param command the command to create a usage string for
|
||||
* @return the command's path and arguments
|
||||
* @param command the command to read arguments from
|
||||
* @param correctLabels the labels to use (must be complete)
|
||||
* @return formatted command syntax incl. arguments
|
||||
*/
|
||||
public static String buildSyntax(CommandDescription command) {
|
||||
String arguments = command.getArguments().stream()
|
||||
.map(arg -> formatArgument(arg))
|
||||
.collect(Collectors.joining(" "));
|
||||
return (constructCommandPath(command) + " " + arguments).trim();
|
||||
}
|
||||
|
||||
public static String buildSyntax(CommandDescription command, List<String> correctLabels) {
|
||||
String commandSyntax = ChatColor.WHITE + "/" + correctLabels.get(0) + ChatColor.YELLOW;
|
||||
for (int i = 1; i < correctLabels.size(); ++i) {
|
||||
@@ -106,7 +100,7 @@ public final class CommandUtils {
|
||||
* @param argument the argument to format
|
||||
* @return the formatted argument
|
||||
*/
|
||||
private static String formatArgument(CommandArgumentDescription argument) {
|
||||
public static String formatArgument(CommandArgumentDescription argument) {
|
||||
if (argument.isOptional()) {
|
||||
return "[" + argument.getName() + "]";
|
||||
}
|
||||
|
||||
@@ -169,7 +169,6 @@ public class PurgeExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
File essentialsDataFolder = pluginHookService.getEssentialsDataFolder();
|
||||
if (essentialsDataFolder == null) {
|
||||
ConsoleLogger.info("Cannot purge Essentials: plugin is not loaded");
|
||||
@@ -181,14 +180,15 @@ public class PurgeExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
int deletedFiles = 0;
|
||||
for (OfflinePlayer offlinePlayer : cleared) {
|
||||
File playerFile = new File(userDataFolder, PlayerUtils.getUuidOrName(offlinePlayer) + ".yml");
|
||||
if (playerFile.exists() && playerFile.delete()) {
|
||||
i++;
|
||||
deletedFiles++;
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleLogger.info("AutoPurge: Removed " + i + " EssentialsFiles");
|
||||
ConsoleLogger.info("AutoPurge: Removed " + deletedFiles + " EssentialsFiles");
|
||||
}
|
||||
|
||||
// TODO #676: What is this method for? Is it correct?
|
||||
|
||||
@@ -61,7 +61,7 @@ public final class FileUtils {
|
||||
ConsoleLogger.warning("Could not create directory '" + dir + "'");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return dir.isDirectory();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,11 +5,11 @@ import java.util.regex.Pattern;
|
||||
/**
|
||||
* Utility class about the InternetProtocol
|
||||
*/
|
||||
public class InternetProtocolUtils {
|
||||
public final class InternetProtocolUtils {
|
||||
|
||||
private final static Pattern LOCAL_ADDRESS_PATTERN =
|
||||
Pattern.compile("(^127\\.)|(^(0)?10\\.)|(^172\\.(0)?1[6-9]\\.)|(^172\\.(0)?2[0-9]\\.)" +
|
||||
"|(^172\\.(0)?3[0-1]\\.)|(^169\\.254\\.)|(^192\\.168\\.)");
|
||||
private static final Pattern LOCAL_ADDRESS_PATTERN =
|
||||
Pattern.compile("(^127\\.)|(^(0)?10\\.)|(^172\\.(0)?1[6-9]\\.)|(^172\\.(0)?2[0-9]\\.)"
|
||||
+ "|(^172\\.(0)?3[0-1]\\.)|(^169\\.254\\.)|(^192\\.168\\.)");
|
||||
|
||||
// Utility class
|
||||
private InternetProtocolUtils() {
|
||||
|
||||
Reference in New Issue
Block a user