Fix command errors being hidden by generic help (#513)

Commands ending in a String... parameter are treated as help commands.
When such a command failed with an @ErrorMessage (e.g. /msg or /kick
with an offline player), the generic help matched next, printed the
usage and the collected error was never shown.

Stop before generic help (noTabComplete) if an earlier help command
already collected errors, and print those instead.
This commit is contained in:
2026-10-27 07:40:06 +01:00
parent d32f5738fd
commit 2ea09eadb2
@@ -91,9 +91,13 @@ public abstract class AbstractSWCommand<T> {
if (commandList.stream().noneMatch(s -> s.invoke(errors::add, sender, alias, args))) { if (commandList.stream().noneMatch(s -> s.invoke(errors::add, sender, alias, args))) {
errors.forEach(Runnable::run); errors.forEach(Runnable::run);
} else return; } else return;
if (errors.isEmpty() && helpCommandList.stream().noneMatch(s -> s.invoke(errors::add, sender, alias, args))) { if (!errors.isEmpty()) return;
errors.forEach(Runnable::run); for (SubCommand<T> help : helpCommandList) {
// Generic help must not hide the error of a more specific command
if (help.noTabComplete && !errors.isEmpty()) break;
if (help.invoke(errors::add, sender, alias, args)) return;
} }
errors.forEach(Runnable::run);
} catch (CommandFrameworkException e) { } catch (CommandFrameworkException e) {
commandSystemError(sender, e); commandSystemError(sender, e);
throw e; throw e;