Class MTVSubCommand
java.lang.Object
nl.mtvehicles.core.infrastructure.models.MTVSubCommand
- Direct Known Subclasses:
VehicleAddMember
,VehicleAddRider
,VehicleBuyCar
,VehicleBuyVoucher
,VehicleDelete
,VehicleDespawn
,VehicleEdit
,VehicleFuel
,VehicleGiveCar
,VehicleGiveFuel
,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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String[]
Arguments for the commandprotected boolean
Whether the sender is a playerprotected org.bukkit.entity.Player
Player who sent the command (may be null if the sender is not a player)protected org.bukkit.command.CommandSender
The command sender -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
checkPermission
(String permission) Check whether the command sender has a permission to use the subcommandabstract boolean
execute()
Code executed by a subcommandprotected Vehicle
Get vehicle used in the command.protected boolean
Check whether the player is holding a vehicle - Used in commands which mustn't be used while player is sitting inside a vehicle.boolean
Check whether the subcommand may only be used by players (and not in console)boolean
onExecute
(org.bukkit.command.CommandSender sender, org.bukkit.command.Command cmd, String s, String[] args) void
sendMessage
(String message) Send a message to the command sender.void
sendMessage
(Message message) Send a message to the command sendervoid
setPlayerCommand
(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
-
MTVSubCommand
public MTVSubCommand()
-
-
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
-