Skip to content

Multiple command signatures #99

@0xivb

Description

@0xivb

Example:

// Getting own balance
@SubCommand("balance")
@Permission("myplugin.balance")
public void balance(CommandSender sender) {
    if(!(sender instanceof Player)) {
        sender.sendMessage(Component.text("Player only command! (Console cannot have balance)"));
        return;
    }

    sender.sendMessage(getBalance((Player) sender));
}

// Getting another player's balance
@SubCommand("balance")
@Permission("myplugin.balance.others")
public void balanceOther(CommandSender sender, Player player) {
    sender.sendMessage(getBalance(player));
}

The different argument signatures would be used by the plugin to find the right method.

This approach would provide a more readable solution compared to doing argument validation manually (and in this case permission validation too).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions