#336 Create command list generator in tools

- Add new conditional template tags [...] blabla [/...]
- Create logic for generating a list of commands
This commit is contained in:
ljacqu
2015-12-14 21:07:03 +01:00
parent 0fdc8d2810
commit 282f777311
9 changed files with 157 additions and 11 deletions
@@ -1,10 +1,12 @@
package fr.xephi.authme.command;
import java.util.List;
import com.google.common.collect.Lists;
import fr.xephi.authme.util.CollectionUtils;
import fr.xephi.authme.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
public final class CommandUtils {
public static int getMinNumberOfArguments(CommandDescription command) {
@@ -32,6 +34,16 @@ public final class CommandUtils {
return StringUtils.join(" ", labels);
}
public static String constructCommandPath(CommandDescription command) {
List<String> labels = new ArrayList<>();
CommandDescription currentCommand = command;
while (currentCommand != null) {
labels.add(currentCommand.getLabels().get(0));
currentCommand = currentCommand.getParent();
}
return "/" + labelsToString(Lists.reverse(labels));
}
public static double getDifference(List<String> labels1, List<String> labels2, boolean fullCompare) {
// Make sure the other reference is correct
if (labels1 == null || labels2 == null) {