Skip to content
Matthias Ngeo edited this page May 8, 2019 · 10 revisions

Tell Command

Partial command execution Partial Command Execution

Full command execution Full Command Execution

import com.karuslabs.commons.command.Executable;
import com.karuslabs.commons.command.tree.nodes.Literal;
import com.karuslabs.commons.command.tree.nodes.Argument;
import com.karuslabs.commons.command.types.PlayersType;
import com.mojang.brigadier.arguments.StringArgumentType;     
         
Argument.Builder<CommandSender, List<Player>> players = Argument.of("players", new PlayersType()); // Inbuilt players type provided by Chimera
Argument.Builder<CommandSender, String> message = Argument.of("message", StringArgumentType.string()) // Inbuilt string type provided by Mojang
                                                          .executes(context -> {
                                                              CommandSender sender = context.getSource();
                                                              List<Player> recipents = context.getArgument("players", List.class);
                                                              String entered = context.getArgument("message", String.class);
                                                           
                                                              recipents.forEach(p -> p.sendMessage(sender.getName() + " says: " + entered));
                                                           })
                                                          .suggests((context, builder) -> builder.suggest("\"Hello World!\"").buildFuture());
     
Argument<CommandSender, List<Player>> arguments = players.then(message).build();

Literal<CommandSender> tell = Literal.of("tell").alias("t")
                                     .executes(context -> context.getSource().sendMessage("Hello darkness my old friend"))
                                     .then(arguments)
                                     .build();

Dispatcher dispatcher = Dispatcher.of(yourPlugin);
dispatcher.getRoot().addChild(tell);
dispatcher.update(); // Only needed if we added "tell" after YourPlugin.onLoad() and YourPlugin.onEnable() has been called.

3D Tracer Command

3D Coordiantes Selector

var tracer = Literal.of("tracer").then(Argument.of("location", new Position3DType()));

Hoverable Suggestions

The meaning of life

var meaning = Literal.of("meaning_of_life").then(Argument.of("?", IntegerArgumentType.integer(30, 43))
                                                         .suggests((context, builder) -> builder.suggest(42, new LiteralMessage("The answer to life the universe and everything")).buildFuture()));

Clientside Suggestions

Clientside suggestions

var clientside = Literal.of("clientside").then(Argument.of("entities", StringArgumentType.word()).suggests(ClientsideProvider.ENTITIES));

Further Reference

Clone this wiki locally