Skip to content

Commit 14b0978

Browse files
suppressed warnings if the command is the default help command
1 parent a6d2152 commit 14b0978

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/java/com/datasiqn/commandcore/managers/CommandManager.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ public void registerCommand(@NotNull CommandBuilder command) {
3131
if (name.contains(" ")) throw new IllegalArgumentException("Command name cannot contain spaces");
3232
if (name.isEmpty()) throw new IllegalArgumentException("Command name cannot be empty");
3333
InitOptions options = CommandCore.getInstance().getOptions();
34-
options.warnIf(Warning.MISSING_DESCRIPTION, !builtCommand.hasDescription(), name);
35-
options.warnIf(Warning.MISSING_PERMISSION, !builtCommand.hasPermission(), name);
34+
// the default help command doesn't have a permission, so suppress all warnings if the command is the default help command
35+
if (!options.createHelpCommand() || !builtCommand.getName().equals("help")) {
36+
options.warnIf(Warning.MISSING_DESCRIPTION, !builtCommand.hasDescription(), name);
37+
options.warnIf(Warning.MISSING_PERMISSION, !builtCommand.hasPermission(), name);
38+
}
3639
if (commandMap.putIfAbsent(name, builtCommand) != null) throw new IllegalArgumentException("Command name already in use");
3740
for (String alias : builtCommand.getAliases()) {
3841
if (alias.contains(" ")) throw new IllegalArgumentException("Command aliases cannot contain spaces");

0 commit comments

Comments
 (0)