Class SafeOverrideableArgument<T,S>

java.lang.Object
dev.jorel.commandapi.ArgumentTree
dev.jorel.commandapi.arguments.Argument<T>
dev.jorel.commandapi.arguments.SafeOverrideableArgument<T,S>
Type Parameters:
T - The type of the underlying object that this argument casts to
S - A custom type which is represented by this argument. For example, a LocationArgument will have a custom type Location
Direct Known Subclasses:
AdvancementArgument, AngleArgument, AxisArgument, BiomeArgument, BooleanArgument, ChatColorArgument, DoubleArgument, EnchantmentArgument, EntityTypeArgument, EnvironmentArgument, FloatArgument, FloatRangeArgument, FunctionArgument, GreedyStringArgument, IntegerArgument, IntegerRangeArgument, ItemStackArgument, Location2DArgument, LocationArgument, LongArgument, LootTableArgument, MathOperationArgument, NamespacedKeyArgument, NBTCompoundArgument, ObjectiveArgument, OfflinePlayerArgument, ParticleArgument, PlayerArgument, PotionEffectArgument, RecipeArgument, RotationArgument, ScoreboardSlotArgument, SoundArgument, TeamArgument, TimeArgument, UUIDArgument

public abstract class SafeOverrideableArgument<T,S> extends Argument<T>
An interface declaring methods required to override argument suggestions
  • Field Details

    • executor

      protected CustomCommandExecutor<?> executor
      The CustomCommandExecutor for this executable implementation
  • Constructor Details

    • SafeOverrideableArgument

      protected SafeOverrideableArgument(String nodeName, com.mojang.brigadier.arguments.ArgumentType<?> rawType, Function<S,String> mapper)
      Instantiates this argument and assigns the mapper to the provided mapper
      Parameters:
      nodeName - the node name of this argument
      rawType - the NMS raw argument type of this argument
      mapper - the mapping function that maps this argument type to a string for suggestions
  • Method Details

    • replaceSafeSuggestions

      public final Argument<T> replaceSafeSuggestions(SafeSuggestions<S> suggestions)
      Replaces the suggestions with a safe SafeSuggestions object. Use the static methods in SafeSuggestions to create safe suggestions.
      Parameters:
      suggestions - The safe suggestions to use
      Returns:
      the current argument
    • replaceWithSafeSuggestions

      @Deprecated(forRemoval=true) public final Argument<T> replaceWithSafeSuggestions(Function<SuggestionInfo,S[]> suggestions)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Replaces the suggestions of this argument with an array of suggestions.
      Parameters:
      suggestions - a function that takes in SuggestionInfo and returns a SafeOverrideableArgument array of suggestions, where S is your custom type
      Returns:
      the current argument
    • replaceWithSafeSuggestionsT

      @Deprecated(forRemoval=true) public final Argument<T> replaceWithSafeSuggestionsT(Function<SuggestionInfo,Tooltip<S>[]> suggestions)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Replaces the suggestions of this argument with an array of suggestions.
      Parameters:
      suggestions - a function that takes in SuggestionInfo and returns a Tooltip array of suggestions, parameterized over SafeOverrideableArgument where S is your custom type
      Returns:
      the current argument
    • includeSafeSuggestions

      public final Argument<T> includeSafeSuggestions(SafeSuggestions<S> suggestions)
      Includes the suggestions provided with the existing suggestions for this argument. Use the static methods in SafeSuggestions to create safe suggestions.
      Parameters:
      suggestions - The safe suggestions to use
      Returns:
      the current argument
    • includeWithSafeSuggestions

      @Deprecated(forRemoval=true) public final Argument<T> includeWithSafeSuggestions(Function<SuggestionInfo,S[]> suggestions)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Include suggestions to add to the list of default suggestions represented by this argument.
      Parameters:
      suggestions - a function that takes in SuggestionInfo which includes information about the current state at the time the suggestions are run and returns a SafeOverrideableArgument array of suggestions to add, where S is your custom type
      Returns:
      the current argument
    • includeWithSafeSuggestionsT

      @Deprecated(forRemoval=true) public final Argument<T> includeWithSafeSuggestionsT(Function<SuggestionInfo,Tooltip<S>[]> suggestions)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Include suggestions to add to the list of default suggestions represented by this argument.
      Parameters:
      suggestions - a function that takes in SuggestionInfo which includes information about the current state at the time the suggestions are run and returns a Tooltip array of suggestions to add, parameterized over SafeOverrideableArgument where S is your custom type
      Returns:
      the current argument
    • executes

      public ArgumentTree executes(CommandExecutor executor, ExecutorType... types)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (CommandSender, Object[]) -> () that will be executed when the command is run
      types - A list of executor types to use this executes method for.
      Returns:
      this command builder
    • executes

      public ArgumentTree executes(ResultingCommandExecutor executor, ExecutorType... types)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (CommandSender, Object[]) -> int that will be executed when the command is run
      types - A list of executor types to use this executes method for.
      Returns:
      this command builder
    • executesPlayer

      public ArgumentTree executesPlayer(PlayerCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (Player, Object[]) -> () that will be executed when the command is run
      Returns:
      this command builder
    • executesPlayer

      public ArgumentTree executesPlayer(PlayerResultingCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (Player, Object[]) -> int that will be executed when the command is run
      Returns:
      this command builder
    • executesEntity

      public ArgumentTree executesEntity(EntityCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (Entity, Object[]) -> () that will be executed when the command is run
      Returns:
      this command builder
    • executesEntity

      public ArgumentTree executesEntity(EntityResultingCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (Entity, Object[]) -> int that will be executed when the command is run
      Returns:
      this command builder
    • executesProxy

      public ArgumentTree executesProxy(ProxyCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (Entity, Object[]) -> () that will be executed when the command is run
      Returns:
      this command builder
    • executesProxy

      public ArgumentTree executesProxy(ProxyResultingCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (Entity, Object[]) -> int that will be executed when the command is run
      Returns:
      this command builder
    • executesCommandBlock

      public ArgumentTree executesCommandBlock(CommandBlockCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (BlockCommandSender, Object[]) -> () that will be executed when the command is run
      Returns:
      this command builder
    • executesCommandBlock

      public ArgumentTree executesCommandBlock(CommandBlockResultingCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (BlockCommandSender, Object[]) -> int that will be executed when the command is run
      Returns:
      this command builder
    • executesConsole

      public ArgumentTree executesConsole(ConsoleCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (BlockCommandSender, Object[]) -> () that will be executed when the command is run
      Returns:
      this command builder
    • executesConsole

      public ArgumentTree executesConsole(ConsoleResultingCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (BlockCommandSender, Object[]) -> int that will be executed when the command is run
      Returns:
      this command builder
    • executesNative

      public ArgumentTree executesNative(NativeCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (NativeCommandExecutor, Object[]) -> () that will be executed when the command is run
      Returns:
      this command builder
    • executesNative

      public ArgumentTree executesNative(NativeResultingCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (NativeCommandExecutor, Object[]) -> int that will be executed when the command is run
      Returns:
      this command builder
    • getExecutor

      public CustomCommandExecutor<? extends org.bukkit.command.CommandSender> getExecutor()
      Returns the executors that this command has
      Returns:
      the executors that this command has
    • setExecutor

      public void setExecutor(CustomCommandExecutor<? extends org.bukkit.command.CommandSender> executor)
      Sets the executors for this command
      Parameters:
      executor - the executors for this command
    • clearExecutors

      public ArgumentTree clearExecutors()
      Clear all executors from the current command builder
      Returns:
      this command builder