Class CustomArgument<T,B>

java.lang.Object
dev.jorel.commandapi.AbstractArgumentTree<dev.jorel.commandapi.arguments.Argument<T>, dev.jorel.commandapi.arguments.Argument<?>, org.bukkit.command.CommandSender>
dev.jorel.commandapi.arguments.AbstractArgument<T, dev.jorel.commandapi.arguments.Argument<T>, dev.jorel.commandapi.arguments.Argument<?>, org.bukkit.command.CommandSender>
dev.jorel.commandapi.arguments.Argument<T>
dev.jorel.commandapi.arguments.CustomArgument<T,B>
Type Parameters:
T - the return type of this custom argument when it is used
B - the return type of the underlying base argument base. For example, this would be Integer for an IntegerArgument
All Implemented Interfaces:
dev.jorel.commandapi.BukkitExecutable<dev.jorel.commandapi.arguments.Argument<T>>, dev.jorel.commandapi.ChainableBuilder<dev.jorel.commandapi.arguments.Argument<T>>, dev.jorel.commandapi.PlatformExecutable<dev.jorel.commandapi.arguments.Argument<T>, org.bukkit.command.CommandSender>

public class CustomArgument<T,B> extends dev.jorel.commandapi.arguments.Argument<T>
An argument that represents any custom object
Since:
2.0
API Note:
Returns a T object
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    An exception used to create command-related errors for the CustomArgument
    static final record 
    A record which contains information which can be passed to the custom argument's parser.
    static interface 
    A FunctionalInterface that takes in a CustomArgument.CustomArgumentInfo, returns T and can throw a CustomArgument.CustomArgumentException
    static class 
    MessageBuilder is used to create error messages for invalid argument inputs
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected dev.jorel.commandapi.CommandAPIExecutor<org.bukkit.command.CommandSender, dev.jorel.commandapi.commandsenders.AbstractCommandSender<? extends org.bukkit.command.CommandSender>>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    CustomArgument(dev.jorel.commandapi.arguments.Argument<B> base, CustomArgument.CustomArgumentInfoParser<T,B> parser)
    Creates a CustomArgument with a valid parser, with an underlying base argument as its parsing implementation.
  • Method Summary

    Modifier and Type
    Method
    Description
    dev.jorel.commandapi.arguments.Argument<T>
     
    dev.jorel.commandapi.arguments.CommandAPIArgumentType
     
    dev.jorel.commandapi.CommandAPIExecutor<org.bukkit.command.CommandSender, dev.jorel.commandapi.commandsenders.AbstractCommandSender<? extends org.bukkit.command.CommandSender>>
     
     
    <CommandSourceStack>
    T
    parseArgument(com.mojang.brigadier.context.CommandContext<CommandSourceStack> cmdCtx, String key, dev.jorel.commandapi.executors.CommandArguments previousArgs)
     
    void
    setExecutor(dev.jorel.commandapi.CommandAPIExecutor<org.bukkit.command.CommandSender, dev.jorel.commandapi.commandsenders.AbstractCommandSender<? extends org.bukkit.command.CommandSender>> arg0)
     

    Methods inherited from class dev.jorel.commandapi.arguments.Argument

    instance

    Methods inherited from class dev.jorel.commandapi.arguments.AbstractArgument

    combineWith, copyPermissionsAndRequirements, getArgumentPermission, getCombinedArguments, getEntityNames, getHelpString, getIncludedSuggestions, getNodeName, getOverriddenSuggestions, getRawType, getRawTypeSupplier, getRequirements, hasCombinedArguments, includeSuggestions, isListed, isOptional, replaceSuggestions, setListed, setOptional, toString, withPermission, withPermission, withRequirement

    Methods inherited from class dev.jorel.commandapi.AbstractArgumentTree

    then, thenNested, thenNested

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface dev.jorel.commandapi.BukkitExecutable

    executes, executes, executes, executes, executesCommandBlock, executesCommandBlock, executesCommandBlock, executesCommandBlock, executesConsole, executesConsole, executesConsole, executesConsole, executesEntity, executesEntity, executesEntity, executesEntity, executesFeedbackForwarding, executesFeedbackForwarding, executesFeedbackForwarding, executesFeedbackForwarding, executesNative, executesNative, executesNative, executesNative, executesPlayer, executesPlayer, executesPlayer, executesPlayer, executesProxy, executesProxy, executesProxy, executesProxy, executesRemoteConsole, executesRemoteConsole, executesRemoteConsole, executesRemoteConsole

    Methods inherited from interface dev.jorel.commandapi.PlatformExecutable

    getExecutor
  • Field Details

    • executor

      protected dev.jorel.commandapi.CommandAPIExecutor<org.bukkit.command.CommandSender, dev.jorel.commandapi.commandsenders.AbstractCommandSender<? extends org.bukkit.command.CommandSender>> executor
  • Constructor Details

    • CustomArgument

      public CustomArgument(dev.jorel.commandapi.arguments.Argument<B> base, CustomArgument.CustomArgumentInfoParser<T,B> parser)
      Creates a CustomArgument with a valid parser, with an underlying base argument as its parsing implementation.
      Parameters:
      base - the base argument to use for this custom argument. This base argument will represent the parsing implementation for client side and server side parsing. This base argument cannot be a LiteralArgument or MultiLiteralArgument
      parser - A CustomArgument.CustomArgumentInfo parser object which includes information such as the command sender, previously declared arguments and current input. This parser should return an object of your choice.

      <T> the return type of this custom argument when it is used
      <B> the return type of the underlying base argument base. For example, this would be Integer for an IntegerArgument

  • Method Details

    • getPrimitiveType

      public Class<T> getPrimitiveType()
      Specified by:
      getPrimitiveType in class dev.jorel.commandapi.arguments.AbstractArgument<T, dev.jorel.commandapi.arguments.Argument<T>, dev.jorel.commandapi.arguments.Argument<?>, org.bukkit.command.CommandSender>
    • getArgumentType

      public dev.jorel.commandapi.arguments.CommandAPIArgumentType getArgumentType()
      Specified by:
      getArgumentType in class dev.jorel.commandapi.arguments.AbstractArgument<T, dev.jorel.commandapi.arguments.Argument<T>, dev.jorel.commandapi.arguments.Argument<?>, org.bukkit.command.CommandSender>
    • parseArgument

      public <CommandSourceStack> T parseArgument(com.mojang.brigadier.context.CommandContext<CommandSourceStack> cmdCtx, String key, dev.jorel.commandapi.executors.CommandArguments previousArgs) throws com.mojang.brigadier.exceptions.CommandSyntaxException
      Specified by:
      parseArgument in class dev.jorel.commandapi.arguments.AbstractArgument<T, dev.jorel.commandapi.arguments.Argument<T>, dev.jorel.commandapi.arguments.Argument<?>, org.bukkit.command.CommandSender>
      Throws:
      com.mojang.brigadier.exceptions.CommandSyntaxException
    • getExecutor

      public dev.jorel.commandapi.CommandAPIExecutor<org.bukkit.command.CommandSender, dev.jorel.commandapi.commandsenders.AbstractCommandSender<? extends org.bukkit.command.CommandSender>> getExecutor()
    • setExecutor

      public void setExecutor(dev.jorel.commandapi.CommandAPIExecutor<org.bukkit.command.CommandSender, dev.jorel.commandapi.commandsenders.AbstractCommandSender<? extends org.bukkit.command.CommandSender>> arg0)
    • clearExecutors

      public dev.jorel.commandapi.arguments.Argument<T> clearExecutors()