forked from SteamWar/SteamWar
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:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user