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

public abstract class MTVehicleSubCommand extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    protected String[]
    Arguments for the command
    protected boolean
    Whether the sender is a player
    protected 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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    checkPermission​(String permission)
    Check whether the command sender has a permission to use the subcommand
    abstract boolean
    Code executed by a subcommand
    protected 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 sender
    void
    setPlayerCommand​(boolean playerCommand)
    Set whether the subcommand may only be used by players (and not in console)

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • sender

      protected org.bukkit.command.CommandSender sender
      The command sender
    • player

      @Nullable protected org.bukkit.entity.Player player
      Player who sent the command (may be null if the sender is not a player)
    • isPlayer

      protected boolean isPlayer
      Whether the sender is a player
    • arguments

      protected String[] arguments
      Arguments for the command
  • Constructor Details

    • MTVehicleSubCommand

      public MTVehicleSubCommand()
  • Method Details

    • onExecute

      public boolean onExecute(org.bukkit.command.CommandSender sender, org.bukkit.command.Command cmd, String s, String[] args)
    • execute

      public abstract boolean execute()
      Code executed by a subcommand
      Returns:
      True if successful
    • sendMessage

      public void sendMessage(String message)
      Send a message to the command sender. Consider using sendMessage(Message) instead.
      Parameters:
      message - Message
    • sendMessage

      public void sendMessage(Message message)
      Send a message to the command sender
      Parameters:
      message - Message
    • checkPermission

      public boolean checkPermission(String permission)
      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

      protected Vehicle 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