Sueta

Rafoudiablol's Command API

2019-08-09

Create commands with automatic arguments management.

·Plugin

8-line overview:

@Executor 
 public   void  doAnotherCommand  (  ConsoleCommandSender sender,  int  firstArg,   String   secondArg  )  
 {  
     for   (   int  i  =   0   ;  i  <  firstArg  ;  i  ++   )  
     {  
        sender.  sendMessage   (  secondArg  )   ;  
     }  
 }
Output
> /repeat 10 Hello 
> Hello 
> Hello 
> Hello 
> Hello 
> Hello 
> Hello 
> Hello 
> Hello 
> Hello 
> Hello


Concrete example

import   net.rafoudiablol.command.PluginCommandExecutor   ;  
 import   net.rafoudiablol.command.mapper.Executor   ;  
 import   org.bukkit.command.ConsoleCommandSender   ;  
 import   org.bukkit.entity.Player   ;  

 /** 
*  As a player, 
* 
*      /my_command_name 
* 
* 
*  As a console, 
* 
*      /my_command_name 10 SpamMe! 
*/  

 public   class  TestExecutor  extends  PluginCommandExecutor  {  

    @Executor 
     public   void  doMyCommand  (  Player player  )   {  

        player.  sendMessage   (   "Hello there!"   )   ;  
     }  

    @Executor 
     public   void  doAnotherCommand  (  ConsoleCommandSender sender,  int  firstArg,   String   secondArg  )   {  

         for   (   int  i  =   0   ;  i  <  firstArg  ;  i  ++   )   {  

            sender.  sendMessage   (  secondArg  )   ;  
         }  
     }  
 }

PluginCommandExecutor is a CommandExecutor .

Installation instruction

Import the JAR into your project.
You don't need to put the JAR into the plugins/ folder.

Dependencies

spigot-1.14.4 ( not included )
Reflections ( included )

Future features
  • wrap end of the command (with spaces) into one argument
  • smart argument binding
  • more types
    • player
      • uuid
      • pseudo
    • other primitive types
      • long
      • float
      • boolean
    • ...
  • policy
    • positive number
    • negative number
    • custom
    • ...

Works only with int and String for now.

-----------------------------------------------------------------------

Similar projects

Plugin →