Skip to content

Commit

Permalink
Skip setting booleans for empty arrarys (#1963)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanduhr32 committed Dec 27, 2021
1 parent e6f2bd0 commit 4a642db
Showing 1 changed file with 7 additions and 0 deletions.
Expand Up @@ -140,6 +140,8 @@ public CommandData setDefaultEnabled(boolean enabled)
public CommandData addOptions(@Nonnull OptionData... options)
{
Checks.noneNull(options, "Option");
if (options.length == 0)
return this;
Checks.check(options.length + this.options.length() <= 25, "Cannot have more than 25 options for a command!");
Checks.check(allowOption, "You cannot mix options with subcommands/groups.");
allowSubcommands = allowGroups = false;
Expand Down Expand Up @@ -257,8 +259,11 @@ public CommandData addOption(@Nonnull OptionType type, @Nonnull String name, @No
public CommandData addSubcommands(@Nonnull SubcommandData... subcommands)
{
Checks.noneNull(subcommands, "Subcommands");
if (subcommands.length == 0)
return this;
if (!allowSubcommands)
throw new IllegalArgumentException("You cannot mix options with subcommands/groups.");

allowOption = false;
Checks.check(subcommands.length + options.length() <= 25, "Cannot have more than 25 subcommands for a command!");
for (SubcommandData data : subcommands)
Expand Down Expand Up @@ -301,6 +306,8 @@ public CommandData addSubcommands(@Nonnull Collection<? extends SubcommandData>
public CommandData addSubcommandGroups(@Nonnull SubcommandGroupData... groups)
{
Checks.noneNull(groups, "SubcommandGroups");
if (groups.length == 0)
return this;
if (!allowGroups)
throw new IllegalArgumentException("You cannot mix options with subcommands/groups.");
allowOption = false;
Expand Down

0 comments on commit 4a642db

Please sign in to comment.