🐛 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 {
|
||||
if (index < queryFragments.length) {
|
||||
/* We might still be able to match an argument */
|
||||
CommandTree.Node<CommandArgument<C, ?>> potentialVariable = null;
|
||||
for (final CommandTree.Node<CommandArgument<C, ?>> child : head.getChildren()) {
|
||||
@SuppressWarnings("unchecked") final StaticArgument<C> childArgument = (StaticArgument<C>) child
|
||||
.getValue();
|
||||
if (childArgument == null) {
|
||||
if (!(child.getValue() instanceof StaticArgument)) {
|
||||
if (child.getValue() != null) {
|
||||
potentialVariable = child;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@SuppressWarnings("unchecked") final StaticArgument<C> childArgument = (StaticArgument<C>) child
|
||||
.getValue();
|
||||
for (final String childAlias : childArgument.getAliases()) {
|
||||
if (childAlias.equalsIgnoreCase(queryFragments[index])) {
|
||||
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);
|
||||
/* 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.");
|
||||
}
|
||||
}).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")
|
||||
.handler(context -> manager.taskRecipe()
|
||||
.begin(context)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue