Subcommands Interface
Introduction#
The Subcommands interface allows plugins to register their own subcommands under the /polar command, and to inspect or adjust the subcommands that ship with Polar.
It is accessed through PolarApi#subcommands().
Methods#
registerSubcommand#
java
void registerSubcommand(Subcommand subcommand, Plugin plugin);Description:
Registers a custom subcommand. Once registered, it is executed as /polar <label> [args...].
Parameters:
subcommand- The Subcommand implementation to register.plugin- The BukkitPluginregistering the subcommand.
Returns:
Nothing.
subcommands#
java
Map<String, Subcommand> subcommands(Plugin plugin);Description:
Gets the subcommands registered by a specific plugin.
Parameters:
plugin- The BukkitPluginthat registered the subcommands.
Returns:
A map of the plugin's registered Subcommands, keyed by label.
polarSubcommands#
java
Map<String, PolarSubcommand> polarSubcommands();Description:
Gets the subcommands built into Polar (for example alerts, reload, help). Each entry can be relabelled, hidden or disabled through the PolarSubcommand interface.
Returns:
A map of built-in PolarSubcommands, keyed by label.
Example#
java
api.subcommands().registerSubcommand(new Subcommand("hello", false, "myplugin.polar.hello") {
@Override
public void execute(User sender, String label, String[] args) {
sender.bukkitPlayer().ifPresent(p -> p.sendMessage("Hello, " + sender.username() + "!"));
}
@Override
public List<String> onTabComplete(User sender, String[] args) {
return Collections.emptyList();
}
}, myPlugin);