Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Command Builder #2

@Manered

Description

@Manered

So what we have now for the CommandBuilder class is quite literally nothing important, it is basically the exact same as the CommandExecutor class.

So, I was thinking of something like this:

  1. Without Arguments:
CommandBuilder cmd = new CommandBuilder("test")
    .setPermission("test.command")
    .setUsage("Correct Usage: /<command>")
    .setDescription("This command is a test. This is also shown in /help testcommand")
    .setShortDescription("This is a short description shown in /help testcommand")
    .setAliases("testcommand")
    .addAlias("testing")
    .setExecutor((CommandSender sender, CommandArguments args) -> {
        sender.sendMessage("Just some random implementation.");
        return;
    })
    .register();
  1. With Arguments:
CommandBuilder cmd = new CommandBuilder("broadcast")
    .setArguments(new JoinedStringArgument(0)) // Special characters can be used and can have spaces.
    .setPermission("broadcast.command")
    .setUsage("Correct Usage: /<command> <message>")
    .setDescription("Broadcasts the message set in the arguments of the command.")
    .setShortDescription("Broadcasts a message.")
    .setAliases("bc")
    .addAlias("broadcastmsg")
    .setExecutor((CommandSender sender, CommandArguments args) -> {
        if (args.get(0) == null) {
            sender.sendMessage("Correct Usage: /broadcast <message>")
            return true;
        }

        Bukkit.broadcastMessage("BROADCAST: " + args.get(0));
        return true;
    })
    .register();

Metadata

Metadata

Assignees

Labels

suggestionNew feature or request/suggestion

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions