T
- The type of subcommands this class should use
SubCommand
net.md_5.bungee.api.plugin.Listener
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
Modifier and Type | Field | Description |
---|---|---|
protected java.util.ArrayList<T> |
subCommands |
Contains all subcommands of the TopCommand
|
Modifier | Constructor | Description |
---|---|---|
protected |
TopCommand(java.lang.String[] pCommandNames,
java.lang.String pPermission,
java.lang.String pPrefix) |
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. |
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 |
sort() |
Sorts the subcommands by there priority.
|
void |
tabComplete(net.md_5.bungee.api.event.TabCompleteEvent pEvent) |
protected final java.util.ArrayList<T extends SubCommand> subCommands
protected TopCommand(java.lang.String[] pCommandNames, java.lang.String pPermission, java.lang.String pPrefix)
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()
.public static boolean isPlayer(net.md_5.bungee.api.CommandSender pCommandSender)
pCommandSender
- The sender of the command.public void execute(net.md_5.bungee.api.CommandSender pCommandSender, java.lang.String[] args)
isPlayer(CommandSender)
.
If so it executes the method onCommand(OnlinePAFPlayer, String[])
.
If not it reloads the plugin.execute
in class net.md_5.bungee.api.plugin.Command
pCommandSender
- The sender of the command.args
- The arguments which are given by the player.protected abstract void onCommand(OnlinePAFPlayer pPlayer, java.lang.String[] args)
pPlayer
- The player who executed the command.args
- The arguments which were given by the player.public void addCommand(T pCommand)
subCommands
list
and after the subcommand was added it sorts the list again.pCommand
- The subcommand which should be added.protected void sort()
public T getSubCommand(java.lang.Class<? extends SubCommand> pClass)
pClass
- The type of the subcommand object which is searchedsubCommands
list, which has an equal type.public java.lang.String getPrefix()
public void tabComplete(net.md_5.bungee.api.event.TabCompleteEvent pEvent)