Class MTVehicleSubCommand
java.lang.Object
nl.mtvehicles.core.infrastructure.models.MTVSubCommand
- Direct Known Subclasses:
VehicleAddMember,VehicleAddRider,VehicleDelete,VehicleEdit,VehicleFuel,VehicleGiveCar,VehicleGiveVoucher,VehicleHelp,VehicleInfo,VehicleLanguage,VehicleMenu,VehiclePrivate,VehiclePublic,VehicleRefill,VehicleReload,VehicleRemoveMember,VehicleRemoveRider,VehicleRepair,VehicleRestore,VehicleSetOwner,VehicleTrunk,VehicleUpdate,VehicleVersion
Abstract class for the plugin's /mtv subcommands
- BEWARE! THIS IS IMPORTANT:
- This class may be renamed (most probably to 'MTVSubCommand') in v2.5.0. Bear it in mind if you're using it in your addon.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String[]Arguments for the commandprotected booleanWhether the sender is a playerprotected org.bukkit.entity.PlayerPlayer who sent the command (may be null if the sender is not a player)protected org.bukkit.command.CommandSenderThe command sender -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckPermission(String permission)Check whether the command sender has a permission to use the subcommandabstract booleanexecute()Code executed by a subcommandprotected VehicleGet vehicle used in the command.protected booleanCheck whether the player is holding a vehicle - Used in commands which mustn't be used while player is sitting inside a vehicle.booleanCheck whether the subcommand may only be used by players (and not in console)booleanonExecute(org.bukkit.command.CommandSender sender, org.bukkit.command.Command cmd, String s, String[] args)voidsendMessage(String message)Send a message to the command sender.voidsendMessage(Message message)Send a message to the command sendervoidsetPlayerCommand(boolean playerCommand)Set whether the subcommand may only be used by players (and not in console)
-
Field Details
-
sender
protected org.bukkit.command.CommandSender senderThe command sender -
player
@Nullable protected org.bukkit.entity.Player playerPlayer who sent the command (may be null if the sender is not a player) -
isPlayer
protected boolean isPlayerWhether the sender is a player -
arguments
Arguments for the command
-
-
Constructor Details
-
MTVehicleSubCommand
public MTVehicleSubCommand()
-
-
Method Details
-
onExecute
-
execute
public abstract boolean execute()Code executed by a subcommand- Returns:
- True if successful
-
sendMessage
Send a message to the command sender. Consider usingsendMessage(Message)instead.- Parameters:
message- Message
-
sendMessage
Send a message to the command sender- Parameters:
message- Message
-
checkPermission
Check whether the command sender has a permission to use the subcommand- Parameters:
permission- Permission necessary to use the subcommand- Returns:
- True if sender has the permission
-
isPlayerCommand
public boolean isPlayerCommand()Check whether the subcommand may only be used by players (and not in console)- Returns:
- True if the subcommand can't be used in console
-
setPlayerCommand
public void setPlayerCommand(boolean playerCommand)Set whether the subcommand may only be used by players (and not in console)- Parameters:
playerCommand- True if the subcommand can't be used in console
-
getVehicle
Get vehicle used in the command.- Returns:
- Firstly, it is checked whether the player is SITTING in a vehicle and is ITS OWNER. If not,the method checks whether the player is HOLDING a vehicle. Otherwise, this returns null and sends the player a message. (If a player is not set, this also returns null but doesn't send any message.)
-
isHoldingVehicle
protected boolean isHoldingVehicle()Check whether the player is holding a vehicle - Used in commands which mustn't be used while player is sitting inside a vehicle.- Returns:
- True if the player is holding a vehicle
-