Class LapisCoreCommand


  • public abstract class LapisCoreCommand
    extends org.bukkit.command.defaults.BukkitCommand
    An utility class to make custom commands that are not in the plugin.yml
    • Field Summary

      • Fields inherited from class org.bukkit.command.Command

        description, timings, usageMessage
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      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
      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
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean execute​(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 plugins
      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
      protected boolean isPermitted​(org.bukkit.command.CommandSender sender, LapisPermission permission)
      Check if a sender is permitted, requires LapisCorePermissions to be registered in LapisCorePlugin
      protected abstract void onCommand​(org.bukkit.command.CommandSender sender, java.lang.String[] args)
      Implement this to process commands
      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
      protected void registerTabCompleter​(org.bukkit.command.TabCompleter completer)
      Registers the given class as the tab completer for this command
      protected void sendMessage​(org.bukkit.command.CommandSender sender, java.lang.String key)
      Send a message from the messages.yml to the command sender provided, requires LapisCoreConfiguration to be registered in LapisCorePlugin
      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 with registerTabCompleter(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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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 - The LapisCorePlugin that the command should be registered to
        name - The name of the command, this wont include the slash
        desc - The description for the /help menu
        aliases - 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 - The LapisCorePlugin that the command should be registered to
        name - The name of the command, this wont include the slash
        desc - The description for the /help menu
        aliases - Any aliases that should run this command
        takeConflicts - 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, requires LapisCorePermissions to be registered in LapisCorePlugin
        Parameters:
        sender - The sender of a command, player or console
        permission - 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 key)
        Send a message from the messages.yml to the command sender provided, requires LapisCoreConfiguration to be registered in LapisCorePlugin
        Parameters:
        sender - The command sender who you wish to send a message to
        key - The key for the message 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 for
        key - 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:
        execute in class org.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 console
        commandLabel - The string representation of the form of the command being used
        args - 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 console
        args - 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 with registerTabCompleter(TabCompleter), from 1.13 onwards this is constantly triggered for possible completions displayed above the chat bar
        Overrides:
        tabComplete in class org.bukkit.command.Command
        Parameters:
        sender - The sender who has attempted to tab complete
        alias - Alias of the command that they are using
        args - The current arguments of the command
        Returns:
        Returns a list of possible completions for the current arguments