Documentation for v1.0

An API to use the new command UI introduced in Minecraft 1.13

Super basic usage

  • Download version 1.0 and add it to your build path
  • Add the plugin as a dependent in the plugin.yml (depend: [CommandAPI])
  • (Make sure the CommandAPI.jar file is included in the plugins folder when running any servers)
  • Create a new instance of the CommandAPI
    CommandAPI commandRegister = new CommandAPI();
    
  • Create a LinkedHashMap<String, ArgumentType> to store your arguments
    LinkedHashMap<String, ArgumentType> arguments = new LinkedHashMap<>();
    //populate hashmap here
    
  • Register the command via the command register
    commandRegister.register("COMMAND_NAME", arguments, (sender, args) -> {/* Command execution goes here */});
    

For an example of this in action, view the example class!

Examples

Multiple arguments with separate outcomes:

// /walkspeed <speed>
// /walkspeed <speed> <target>

CommandAPI commandRegister = new CommandAPI();

LinkedHashMap<String, ArgumentType> arguments = new LinkedHashMap<>();
arguments.put("speed", ArgumentType.FLOAT);

commandRegister.register("walkspeed", arguments, (sender, args) -> {
  //Sender check 
  if(sender instanceof Player) {
    Player player = (Player) sender;
    player.setWalkSpeed((float) args[0]);
  } else {
    sender.sendMessage("You must be a player to use this command");
  }
});

//Adding a new argument, as an additional command to the previous
arguments.put("target", ArgumentType.STRING);

commandRegister.register("walkspeed", arguments, (sender, args) -> {
  //Get target
  Bukkit.getPlayer((String) args[1]).setWalkSpeed((float) args[0]);
});