Package net.lapismc.lapiscore.commands
Class LapisCoreCommand
- java.lang.Object
-
- org.bukkit.command.Command
-
- org.bukkit.command.defaults.BukkitCommand
-
- net.lapismc.lapiscore.commands.LapisCoreCommand
-
public abstract class LapisCoreCommand extends org.bukkit.command.defaults.BukkitCommandAn utility class to make custom commands that are not in the plugin.yml
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedLapisCoreCommand(LapisCorePlugin core, java.lang.String name, java.lang.String desc, java.util.List<java.lang.String> aliases)If in doubt use this constructorprotectedLapisCoreCommand(LapisCorePlugin core, java.lang.String name, java.lang.String desc, java.util.List<java.lang.String> aliases, boolean takeConflicts)This constructor allows you to take conflicting commands and aliases
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanexecute(org.bukkit.command.CommandSender sender, java.lang.String commandLabel, java.lang.String[] args)java.util.List<java.lang.String>getTakenAliases()Get a list of aliases that this command has attempted to override from other pluginsprotected booleanisNotPlayer(org.bukkit.command.CommandSender sender, java.lang.String key)Test if the sender is a player and send them a message if they are not a playerprotected booleanisPermitted(org.bukkit.command.CommandSender sender, LapisPermission permission)Check if a sender is permitted, requiresLapisCorePermissionsto be registered inLapisCorePluginprotected abstract voidonCommand(org.bukkit.command.CommandSender sender, java.lang.String[] args)Implement this to process commandsprotected voidonCommand(org.bukkit.command.CommandSender sender, java.lang.String commandLabel, java.lang.String[] args)This is here to allow legacy commands to be moved over to this API easilyprotected voidregisterTabCompleter(org.bukkit.command.TabCompleter completer)Registers the given class as the tab completer for this commandprotected voidsendMessage(org.bukkit.command.CommandSender sender, java.lang.String... keys)Send message(s) from the messages.yml to the command sender provided, requiresLapisCoreConfigurationto be registered inLapisCorePluginjava.util.List<java.lang.String>tabComplete(org.bukkit.command.CommandSender sender, java.lang.String alias, java.lang.String[] args)Calls the default behaviour unless a tab completer has been set withregisterTabCompleter(TabCompleter), from 1.13 onwards this is constantly triggered for possible completions displayed above the chat bar-
Methods inherited from class org.bukkit.command.Command
broadcastCommandMessage, broadcastCommandMessage, getAliases, getDescription, getLabel, getName, getPermission, getPermissionMessage, getUsage, isRegistered, register, setAliases, setDescription, setLabel, setName, setPermission, setPermissionMessage, setUsage, tabComplete, testPermission, testPermissionSilent, toString, unregister
-
-
-
-
Constructor Detail
-
LapisCoreCommand
protected LapisCoreCommand(LapisCorePlugin core, java.lang.String name, java.lang.String desc, java.util.List<java.lang.String> aliases)
If in doubt use this constructor- Parameters:
core- TheLapisCorePluginthat the command should be registered toname- The name of the command, this wont include the slashdesc- The description for the /help menualiases- Any aliases that should run this command
-
LapisCoreCommand
protected LapisCoreCommand(LapisCorePlugin core, java.lang.String name, java.lang.String desc, java.util.List<java.lang.String> aliases, boolean takeConflicts)
This constructor allows you to take conflicting commands and aliases- Parameters:
core- TheLapisCorePluginthat the command should be registered toname- The name of the command, this wont include the slashdesc- The description for the /help menualiases- Any aliases that should run this commandtakeConflicts- Set to true if you would like to forcefully take control of any commands of the same name or alias
-
-
Method Detail
-
getTakenAliases
public java.util.List<java.lang.String> getTakenAliases()
Get a list of aliases that this command has attempted to override from other plugins- Returns:
- A list of command names as strings
-
registerTabCompleter
protected void registerTabCompleter(org.bukkit.command.TabCompleter completer)
Registers the given class as the tab completer for this command- Parameters:
completer- The class you wish to deal with tab completions for this command
-
isPermitted
protected boolean isPermitted(org.bukkit.command.CommandSender sender, LapisPermission permission)Check if a sender is permitted, requiresLapisCorePermissionsto be registered inLapisCorePlugin- Parameters:
sender- The sender of a command, player or consolepermission- The LapisPermission you wish to check- Returns:
- Returns true if the value of the given permission is greater than 0 or if the sender is not a
Player
-
sendMessage
protected void sendMessage(org.bukkit.command.CommandSender sender, java.lang.String... keys)Send message(s) from the messages.yml to the command sender provided, requiresLapisCoreConfigurationto be registered inLapisCorePlugin- Parameters:
sender- The command sender who you wish to send a message tokeys- The keys for the messages in the messages.yml
-
isNotPlayer
protected boolean isNotPlayer(org.bukkit.command.CommandSender sender, java.lang.String key)Test if the sender is a player and send them a message if they are not a player- Parameters:
sender- The command sender you wish to test forkey- The key of the message they should receive if they are not a player- Returns:
- Returns true if the sender is not a player, otherwise returns false
-
execute
public boolean execute(org.bukkit.command.CommandSender sender, java.lang.String commandLabel, java.lang.String[] args)- Specified by:
executein classorg.bukkit.command.Command
-
onCommand
protected void onCommand(org.bukkit.command.CommandSender sender, java.lang.String commandLabel, java.lang.String[] args)This is here to allow legacy commands to be moved over to this API easily- Parameters:
sender- The sender of the command, could be a player or consolecommandLabel- The string representation of the form of the command being usedargs- The arguments provided with the command
-
onCommand
protected abstract void onCommand(org.bukkit.command.CommandSender sender, java.lang.String[] args)Implement this to process commands- Parameters:
sender- The sender of the command, could be a player or consoleargs- The arguments provided with the command
-
tabComplete
public java.util.List<java.lang.String> tabComplete(org.bukkit.command.CommandSender sender, java.lang.String alias, java.lang.String[] args)Calls the default behaviour unless a tab completer has been set withregisterTabCompleter(TabCompleter), from 1.13 onwards this is constantly triggered for possible completions displayed above the chat bar- Overrides:
tabCompletein classorg.bukkit.command.Command- Parameters:
sender- The sender who has attempted to tab completealias- Alias of the command that they are usingargs- The current arguments of the command- Returns:
- Returns a list of possible completions for the current arguments
-
-