🐛 Fix issues with the help system
This commit is contained in:
parent
97e447739c
commit
c48eb28434
2 changed files with 20 additions and 4 deletions
|
|
@ -207,12 +207,16 @@ public final class CommandHelpHandler<C> {
|
||||||
} else {
|
} else {
|
||||||
if (index < queryFragments.length) {
|
if (index < queryFragments.length) {
|
||||||
/* We might still be able to match an argument */
|
/* We might still be able to match an argument */
|
||||||
|
CommandTree.Node<CommandArgument<C, ?>> potentialVariable = null;
|
||||||
for (final CommandTree.Node<CommandArgument<C, ?>> child : head.getChildren()) {
|
for (final CommandTree.Node<CommandArgument<C, ?>> child : head.getChildren()) {
|
||||||
@SuppressWarnings("unchecked") final StaticArgument<C> childArgument = (StaticArgument<C>) child
|
if (!(child.getValue() instanceof StaticArgument)) {
|
||||||
.getValue();
|
if (child.getValue() != null) {
|
||||||
if (childArgument == null) {
|
potentialVariable = child;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@SuppressWarnings("unchecked") final StaticArgument<C> childArgument = (StaticArgument<C>) child
|
||||||
|
.getValue();
|
||||||
for (final String childAlias : childArgument.getAliases()) {
|
for (final String childAlias : childArgument.getAliases()) {
|
||||||
if (childAlias.equalsIgnoreCase(queryFragments[index])) {
|
if (childAlias.equalsIgnoreCase(queryFragments[index])) {
|
||||||
head = child;
|
head = child;
|
||||||
|
|
@ -220,6 +224,10 @@ public final class CommandHelpHandler<C> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (potentialVariable != null) {
|
||||||
|
head = potentialVariable;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
final String currentDescription = this.commandManager.getCommandSyntaxFormatter().apply(traversedNodes, null);
|
final String currentDescription = this.commandManager.getCommandSyntaxFormatter().apply(traversedNodes, null);
|
||||||
/* Attempt to parse the longest possible description for the children */
|
/* Attempt to parse the longest possible description for the children */
|
||||||
|
|
|
||||||
|
|
@ -274,7 +274,15 @@ public final class ExamplePlugin extends JavaPlugin {
|
||||||
player.sendMessage(ChatColor.RED + "No entity matched your query.");
|
player.sendMessage(ChatColor.RED + "No entity matched your query.");
|
||||||
}
|
}
|
||||||
}).execute()
|
}).execute()
|
||||||
));
|
))
|
||||||
|
.command(builder.literal("teleport")
|
||||||
|
.meta(CommandMeta.DESCRIPTION, "Teleport to a world")
|
||||||
|
.argument(WorldArgument.of("world"), Description.of("World to teleport to"))
|
||||||
|
.handler(context -> manager.taskRecipe().begin(context).synchronous(ctx -> {
|
||||||
|
final Player player = (Player) ctx.getSender();
|
||||||
|
player.teleport(ctx.<World>get("world").getSpawnLocation());
|
||||||
|
player.sendMessage(ChatColor.GREEN + "You have been teleported!");
|
||||||
|
}).execute()));
|
||||||
manager.command(builder.literal("tasktest")
|
manager.command(builder.literal("tasktest")
|
||||||
.handler(context -> manager.taskRecipe()
|
.handler(context -> manager.taskRecipe()
|
||||||
.begin(context)
|
.begin(context)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue