Class CommandModule<W extends BetterCommandSource>

java.lang.Object
kr.toxicity.command.impl.CommandModule<W>
Type Parameters:
W - wrapper class of command source
All Implemented Interfaces:
CommandArgument<W>

public final class CommandModule<W extends BetterCommandSource> extends Object implements CommandArgument<W>
Main command module can include many sub-command
  • Field Details

    • REQUIRED_ARGUMENT

      public static final CommandMessage REQUIRED_ARGUMENT
      Required argument message
    • OPTIONAL_ARGUMENT

      public static final CommandMessage OPTIONAL_ARGUMENT
      Optional argument message
    • CHILDREN

      public static final CommandMessage CHILDREN
      Sub-command argument message
    • ALIASES

      public static final CommandMessage ALIASES
      Aliases message
    • PERMISSIONS

      public static final CommandMessage PERMISSIONS
      Permission message
    • CLICK_MESSAGE

      public static final CommandMessage CLICK_MESSAGE
      Help command click message
    • UNKNOWN_DESCRIPTION

      public static final CommandMessage UNKNOWN_DESCRIPTION
      Unknown description message
  • Constructor Details

    • CommandModule

      public CommandModule()
  • Method Details

    • name

      @NotNull public @NotNull String name()
      Description copied from interface: CommandArgument
      Gets command name
      Specified by:
      name in interface CommandArgument<W extends BetterCommandSource>
      Returns:
      name
    • aliases

      @NotNull public @NotNull String[] aliases()
      Description copied from interface: CommandArgument
      Gets command aliases
      Specified by:
      aliases in interface CommandArgument<W extends BetterCommandSource>
      Returns:
      aliases
    • aliases

      @NotNull public @NotNull CommandModule<W> aliases(@Nullable @Nullable String[] aliases)
      Sets command aliases
      Parameters:
      aliases - target aliases
      Returns:
      self
    • description

      @NotNull public @NotNull MessageFunction<W> description()
      Description copied from interface: CommandArgument
      Gets command description
      Specified by:
      description in interface CommandArgument<W extends BetterCommandSource>
      Returns:
      description
    • description

      @NotNull public @NotNull CommandModule<W> description(@NotNull @NotNull String key, @NotNull @NotNull net.kyori.adventure.text.Component component)
      Sets command description
      Parameters:
      key - translatable key
      component - default component if lang file is not found
      Returns:
      self
    • description

      @NotNull public @NotNull CommandModule<W> description(@NotNull @NotNull CommandMessage description)
      Sets command description
      Parameters:
      description - description message
      Returns:
      self
    • description

      @NotNull public @NotNull CommandModule<W> description(@Nullable @Nullable MessageFunction<W> description)
      Sets command description
      Parameters:
      description - message function
      Returns:
      self
    • permission

      @Nullable public @Nullable String permission()
      Description copied from interface: CommandArgument
      Gets command permission
      Specified by:
      permission in interface CommandArgument<W extends BetterCommandSource>
      Returns:
      permission key or null if not set
    • permission

      @NotNull public @NotNull CommandModule<W> permission(@Nullable @Nullable String permission)
      Sets command permission
      Parameters:
      permission - target permission
      Returns:
      self
    • andPredicate

      @NotNull public @NotNull CommandModule<W> andPredicate(@NotNull @NotNull Predicate<? super W> predicate)
      Sets a condition to and gate
      Parameters:
      predicate - condition
      Returns:
      self
    • orPredicate

      @NotNull public @NotNull CommandModule<W> orPredicate(@NotNull @NotNull Predicate<? super W> predicate)
      Sets a condition to and gate
      Parameters:
      predicate - condition
      Returns:
      self
    • children

      @NotNull public @NotNull CommandModule<W> children(@NotNull @NotNull String name, @NotNull @NotNull Consumer<CommandModule<? super W>> consumer)
      Creates children module of parent
      Parameters:
      name - name of sub-command
      consumer - consumer of children module
      Returns:
      self
    • type

      @NotNull public @NotNull SenderType[] type()
      Gets all applicable type
      Returns:
      all type
    • type

      @NotNull public @NotNull CommandModule<W> type(@NotNull @NotNull SenderType[] type)
      Sets applicable type
      Parameters:
      type - type
      Returns:
      self
    • helpName

      @NotNull public @NotNull String helpName()
      Gets name in help command
      Returns:
      name in help command
    • helpName

      @NotNull public @NotNull CommandModule<W> helpName(@NotNull @NotNull String helpName)
      Sets name in help command
      Parameters:
      helpName - name
      Returns:
      self
    • usage

      @NotNull public @NotNull net.kyori.adventure.text.Component usage(@NotNull W w)
      Description copied from interface: CommandArgument
      Gets usage of this command
      Specified by:
      usage in interface CommandArgument<W extends BetterCommandSource>
      Parameters:
      w - source
      Returns:
      usage component
    • executes

      @NotNull public @NotNull CommandModule<W> executes(@NotNull @NotNull CommandListener executor)
      Sets executor of command
      Parameters:
      executor - command executor
      Returns:
      self
    • build

      @NotNull public <S> @NotNull @Unmodifiable List<com.mojang.brigadier.builder.LiteralArgumentBuilder<S>> build(@NotNull @NotNull Function<S,W> mapper)
      Description copied from interface: CommandArgument
      Build a brigadier command
      Specified by:
      build in interface CommandArgument<W extends BetterCommandSource>
      Type Parameters:
      S - source class of W (normally it is a CommandSourceStack)
      Parameters:
      mapper - class wrapper
      Returns:
      brigadier command