More fixes for #387
This commit is contained in:
parent
82894ccdff
commit
a133aacaa2
1 changed files with 14 additions and 3 deletions
|
|
@ -684,9 +684,7 @@ public final class CloudBrigadierManager<C, S> {
|
||||||
final Method getNodesMethod = commandContext.getClass().getDeclaredMethod("getNodes");
|
final Method getNodesMethod = commandContext.getClass().getDeclaredMethod("getNodes");
|
||||||
final Object nodes = getNodesMethod.invoke(commandContext);
|
final Object nodes = getNodesMethod.invoke(commandContext);
|
||||||
if (nodes instanceof List) {
|
if (nodes instanceof List) {
|
||||||
return ((List<ParsedCommandNode<S>>) nodes).stream()
|
return ParsedCommandNodeHandler.toPairList((List) nodes);
|
||||||
.map(n -> Pair.of(n.getNode(), n.getRange()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
} else if (nodes instanceof Map) {
|
} else if (nodes instanceof Map) {
|
||||||
return ((Map<CommandNode<S>, StringRange>) nodes).entrySet().stream()
|
return ((Map<CommandNode<S>, StringRange>) nodes).entrySet().stream()
|
||||||
.map(entry -> Pair.of(entry.getKey(), entry.getValue()))
|
.map(entry -> Pair.of(entry.getKey(), entry.getValue()))
|
||||||
|
|
@ -698,4 +696,17 @@ public final class CloudBrigadierManager<C, S> {
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inner class to prevent attempting to load ParsedCommandNode when it doesn't exist
|
||||||
|
private static final class ParsedCommandNodeHandler {
|
||||||
|
private ParsedCommandNodeHandler() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <S> List<Pair<CommandNode<S>, StringRange>> toPairList(List<?> nodes) {
|
||||||
|
return ((List<ParsedCommandNode<S>>) nodes).stream()
|
||||||
|
.map(n -> Pair.of(n.getNode(), n.getRange()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue