Skip to content

wf4java/WF-CommandUtils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

WF-CommandUtils:

Maven:

Java(min): 17

  <dependency>
    <groupId>io.github.wf4java</groupId>
    <artifactId>WF-CommandUtils</artifactId>
    <version>1.2.0</version>
  </dependency>

Example:

StringCommandHandler commandHandler = new StringCommandHandler();

commandHandler.addSubcommand(
        SubCommand.builder(String.class)
                .setCommand("set.data")
                .setArguments(
                        new Argument("number", ArgumentType.INTEGER),
                        new Argument("boolean", ArgumentType.BOOLEAN, false, true)
                )
                .setRunnable((sender, command, result) -> {
                    System.out.println("Result: " + result[0]);
                    System.out.println("Result: " + result[1]);
                })
                .build()
);


commandHandler.addSubcommand(
        SubCommand.builder(String.class)
                .setCommand("remove.data")
                .setArguments(
                        new Argument("number", ArgumentType.INTEGER)
                )
                .setRunnable((sender, command, result) -> {
                    System.out.println("Result: " + result[0]);
                })
                .build()
);


commandHandler.onCommand("set data 5", message -> System.out.println("Error: " + message));
commandHandler.onCommand("remove data 4", message -> System.out.println("Error: " + message));
commandHandler.onCommand("remove data false", message -> System.out.println("Error: " + message));

About

CommandUtils for Java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages