Merge branch 'master' of https://github.com/AuthMe-Team/AuthMeReloaded into commands-refactor
Conflicts: src/main/java/fr/xephi/authme/command/CommandUtils.java src/main/java/fr/xephi/authme/command/executable/captcha/CaptchaCommand.java
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
package fr.xephi.authme.command;
|
||||
|
||||
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) {
|
||||
@@ -23,10 +28,20 @@ public final class CommandUtils {
|
||||
* the items ["authme", "register", "player"] it will return "authme register player".
|
||||
*
|
||||
* @param labels The labels to format
|
||||
*
|
||||
* @return The space-separated labels
|
||||
*/
|
||||
public static String labelsToString(Iterable<String> labels) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user