Class TopCommand<T extends SubCommand>

  • Type Parameters:
    T - The type of subcommands this class should use SubCommand
    All Implemented Interfaces:
    net.md_5.bungee.api.plugin.Listener
    Direct Known Subclasses:
    Friends, OnlyTopCommand, PartyCommand

    public abstract class TopCommand<T extends SubCommand>
    extends net.md_5.bungee.api.plugin.Command
    implements net.md_5.bungee.api.plugin.Listener
    Represents a TopCommand like /friend, /party or /command. The top command decides if and which subcommand should be executed. Also if no subcommand should be executed it outputs the help of the subcommands.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.ArrayList<T> subCommands
      Contains all subcommands of the TopCommand
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected TopCommand​(java.lang.String[] pCommandNames, java.lang.String pPermission, java.lang.String pPrefix)  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void addCommand​(T pCommand)
      Adds a subcommand to the subCommands list and after the subcommand was added it sorts the list again.
      protected int count​(java.lang.String pString)  
      void execute​(net.md_5.bungee.api.CommandSender pCommandSender, java.lang.String[] args)
      Checks if the sender is a player with the method isPlayer(CommandSender).
      java.lang.String getPrefix()  
      T getSubCommand​(java.lang.Class<? extends SubCommand> pClass)  
      static boolean isPlayer​(net.md_5.bungee.api.CommandSender pCommandSender)  
      protected abstract void onCommand​(OnlinePAFPlayer pPlayer, java.lang.String[] args)
      Decides if a subcommand should be called and if which one.
      protected void playerComplete​(net.md_5.bungee.api.event.TabCompleteEvent pEvent)  
      protected void sort()
      Sorts the subcommands by there priority.
      void tabComplete​(net.md_5.bungee.api.event.TabCompleteEvent pEvent)  
      protected void topCommandComplete​(net.md_5.bungee.api.event.TabCompleteEvent pEvent)  
      • Methods inherited from class net.md_5.bungee.api.plugin.Command

        canEqual, equals, getAliases, getName, getPermission, hashCode, hasPermission, toString
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • subCommands

        protected final java.util.ArrayList<T extends SubCommand> subCommands
        Contains all subcommands of the TopCommand
    • Constructor Detail

      • TopCommand

        protected TopCommand​(java.lang.String[] pCommandNames,
                             java.lang.String pPermission,
                             java.lang.String pPrefix)
        Parameters:
        pCommandNames - The command name and the different aliases of this command. By these names the method can be called.
        pPermission - The permission which is needed to execute this command. If it is blank no permission is needed to execute this command.
        pPrefix - The prefix which should be used by all subcommands. The prefix gets returned by the method getPrefix().
    • Method Detail

      • isPlayer

        public static boolean isPlayer​(net.md_5.bungee.api.CommandSender pCommandSender)
        Parameters:
        pCommandSender - The sender of the command.
        Returns:
        Returns true if the sender of the command is a player. If not it returns false and reloads the plugin.
      • execute

        public void execute​(net.md_5.bungee.api.CommandSender pCommandSender,
                            java.lang.String[] args)
        Checks if the sender is a player with the method isPlayer(CommandSender). If so it executes the method onCommand(OnlinePAFPlayer, String[]). If not it reloads the plugin.
        Specified by:
        execute in class net.md_5.bungee.api.plugin.Command
        Parameters:
        pCommandSender - The sender of the command.
        args - The arguments which are given by the player.
      • onCommand

        protected abstract void onCommand​(OnlinePAFPlayer pPlayer,
                                          java.lang.String[] args)
        Decides if a subcommand should be called and if which one. If no subcommand should be called it shows the help of the commands.
        Parameters:
        pPlayer - The player who executed the command.
        args - The arguments which were given by the player.
      • addCommand

        public void addCommand​(T pCommand)
        Adds a subcommand to the subCommands list and after the subcommand was added it sorts the list again.
        Parameters:
        pCommand - The subcommand which should be added.
      • sort

        protected void sort()
        Sorts the subcommands by there priority. The subcommand with the lowest priority will be the first one in the list and the one with the highest priority the last one after the list was sorted.
      • getSubCommand

        public T getSubCommand​(java.lang.Class<? extends SubCommand> pClass)
        Parameters:
        pClass - The type of the subcommand object which is searched
        Returns:
        Returns a subcommand of the subCommands list, which has an equal type.
      • getPrefix

        public java.lang.String getPrefix()
        Returns:
        Returns the prefix which should be used by all subcommands.
      • tabComplete

        public void tabComplete​(net.md_5.bungee.api.event.TabCompleteEvent pEvent)
      • topCommandComplete

        protected void topCommandComplete​(net.md_5.bungee.api.event.TabCompleteEvent pEvent)
      • playerComplete

        protected void playerComplete​(net.md_5.bungee.api.event.TabCompleteEvent pEvent)
      • count

        protected int count​(java.lang.String pString)