Class TopCommand<T extends SubCommand>
java.lang.Object
net.md_5.bungee.api.plugin.Command
de.simonsator.partyandfriends.api.TopCommand<T>
- Type Parameters:
T
- The type of subcommands this class should useSubCommand
- All Implemented Interfaces:
net.md_5.bungee.api.plugin.TabExecutor
- 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.TabExecutor
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
Modifier and TypeFieldDescriptionContains all subcommands of the TopCommand -
Constructor Summary
ModifierConstructorDescriptionprotected
TopCommand
(String[] pCommandNames, String pPermission, String pPrefix) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCommand
(T pCommand) Adds a subcommand to thesubCommands
list and after the subcommand was added it sorts the list again.void
Checks if the sender is a player with the methodisPlayer(CommandSender)
.getSubCommand
(Class<? extends SubCommand> pClass) static boolean
isPlayer
(net.md_5.bungee.api.CommandSender pCommandSender) protected abstract void
onCommand
(OnlinePAFPlayer pPlayer, String[] args) Decides if a subcommand should be called and if which one.onTabComplete
(net.md_5.bungee.api.CommandSender commandSender, String[] strings) playerComplete
(String[] input) protected void
sort()
Sorts the subcommands by there priority.void
tabComplete
(net.md_5.bungee.api.event.TabCompleteEvent pEvent) Deprecated.Methods inherited from class net.md_5.bungee.api.plugin.Command
canEqual, equals, getAliases, getName, getPermission, getPermissionMessage, hashCode, hasPermission, setPermissionMessage, toString
-
Field Details
-
subCommands
Contains all subcommands of the TopCommand
-
-
Constructor Details
-
TopCommand
- 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 methodgetPrefix()
.
-
-
Method Details
-
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
Checks if the sender is a player with the methodisPlayer(CommandSender)
. If so it executes the methodonCommand(OnlinePAFPlayer, String[])
. If not it reloads the plugin.- Specified by:
execute
in classnet.md_5.bungee.api.plugin.Command
- Parameters:
pCommandSender
- The sender of the command.args
- The arguments which are given by the player.
-
onCommand
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
Adds a subcommand to thesubCommands
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
- 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
- Returns:
- Returns the prefix which should be used by all subcommands.
-
tabComplete
Deprecated. -
playerComplete
-
onTabComplete
public List<String> onTabComplete(net.md_5.bungee.api.CommandSender commandSender, String[] strings) - Specified by:
onTabComplete
in interfacenet.md_5.bungee.api.plugin.TabExecutor
-