Class CustomMapArgument

java.lang.Object
dev.jorel.commandapi.AbstractArgumentTree<dev.jorel.commandapi.arguments.Argument<Map<String,Object>>,dev.jorel.commandapi.arguments.Argument<?>,org.bukkit.command.CommandSender>
dev.jorel.commandapi.arguments.AbstractArgument<Map<String,Object>,dev.jorel.commandapi.arguments.Argument<Map<String,Object>>,dev.jorel.commandapi.arguments.Argument<?>,org.bukkit.command.CommandSender>
dev.jorel.commandapi.arguments.Argument<Map<String,Object>>
dev.jorel.commandapi.arguments.CustomArgument<Map<String,Object>,String>
me.deecaad.core.commands.CustomMapArgument
All Implemented Interfaces:
dev.jorel.commandapi.BukkitExecutable<dev.jorel.commandapi.arguments.Argument<Map<String,Object>>>, dev.jorel.commandapi.ChainableBuilder<dev.jorel.commandapi.arguments.Argument<Map<String,Object>>>, dev.jorel.commandapi.PlatformExecutable<dev.jorel.commandapi.arguments.Argument<Map<String,Object>>,org.bukkit.command.CommandSender>

public class CustomMapArgument extends dev.jorel.commandapi.arguments.CustomArgument<Map<String,Object>,String>

A CustomArgument for parsing a single argument that contains multiple key-value pairs (a "map"). Each key must be known ahead of time, and each key is handled by a SimpleSerializer for type-checking and deserialization.


 Example usage (registering the argument):

   // 1) Build known types for each "key"
   Map<String, SimpleSerializer<?>>> weaponDataMap = new HashMap<>();
   weaponDataMap.put("ammo", new IntSerializer(1, 64));
   weaponDataMap.put("firemode", new IntSerializer(0, 2));
   weaponDataMap.put("skipMainhand", new BooleanSerializer());
   weaponDataMap.put("skin", new StringSerializer());

   // 2) Create the custom argument
   Argument<Map<String, Object>> dataArg = new CustomMapArgument("data", weaponDataMap)
       .setDefault(Collections.emptyMap()); // make it optional

   // 3) Use it in a CommandAPICommand
   new CommandAPICommand("give")
       .withArguments(dataArg)
       .executesPlayer((player, args) -> {
           Map<String, Object> data = (Map<String, Object>) args.get("data");
           // e.g. data.get("ammo") -> Integer
       })
       .register();
 

This class automatically handles:

  • Splitting the user input on commas (and optional braces '{' / '}')
  • Validating each key, using your SimpleSerializer
  • Providing tab-completions for keys and values, based on each serializer's SimpleSerializer.examples()
}
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class dev.jorel.commandapi.arguments.CustomArgument

    dev.jorel.commandapi.arguments.CustomArgument.CustomArgumentException, dev.jorel.commandapi.arguments.CustomArgument.CustomArgumentInfo<B>, dev.jorel.commandapi.arguments.CustomArgument.CustomArgumentInfoParser<T,B>, dev.jorel.commandapi.arguments.CustomArgument.MessageBuilder
  • 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
    CustomMapArgument(String nodeName, Map<String,SimpleSerializer<?>> knownTypes)
    Creates a new CustomMapArgument that parses a map of key-value pairs from a single argument.
  • Method Summary

    Modifier and Type
    Method
    Description
    dev.jorel.commandapi.arguments.Argument<Map<String,Object>>
     
    dev.jorel.commandapi.CommandAPIExecutor<org.bukkit.command.CommandSender,dev.jorel.commandapi.commandsenders.AbstractCommandSender<? extends org.bukkit.command.CommandSender>>
     
    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.CustomArgument

    getArgumentType, getPrimitiveType, parseArgument

    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, 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 java.lang.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

    • CustomMapArgument

      public CustomMapArgument(String nodeName, Map<String,SimpleSerializer<?>> knownTypes)

      Creates a new CustomMapArgument that parses a map of key-value pairs from a single argument. This uses a GreedyStringArgument as the base, so the user can type something like:

      
         /mycommand {ammo:5,firemode:2,skipMainhand:false}
       

      Each key must be present in knownTypes, and its value is parsed by the corresponding SimpleSerializer.

      Parameters:
      nodeName - The name (identifier) for this argument
      knownTypes - A map from key -> SimpleSerializer<?>.
  • Method Details

    • 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<Map<String,Object>> clearExecutors()