Class VehicleUtils
java.lang.Object
nl.mtvehicles.core.infrastructure.vehicle.VehicleUtils
Useful methods for vehicles
- See Also:
Vehicle
- BEWARE! THIS IS IMPORTANT:
- This class may be moved in v2.5.0. Bear it in mind if you're using it in your addon.
-
Field Summary
FieldsModifier and TypeFieldDescriptionHashMap containing information about which trunk a player has opened (determined by vehicle's license plate) -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Check whether a player can ride/drive the vehicle.static boolean
Check whether a player can sit in the vehicle.static void
enterVehicle(String licensePlate, org.bukkit.entity.Player p)
CreateVehicleData
(necessary for driving to work) and make player enter a vehicle.static boolean
existsByLicensePlate(String licensePlate)
Check whether this vehicle exists in the database (vehicleData.yml)static Vehicle
getByLicensePlate(String licensePlate)
Deprecated.static org.bukkit.inventory.ItemStack
getCarItem(String carUUID)
Get a vehicle item by UUID.static String
getCarUUID(String licensePlate)
Get the UUID of a car by its license platestatic boolean
getHornByDamage(int damage)
Check whether horn is enabled on this vehicle.static org.bukkit.inventory.ItemStack
getItemByUUID(org.bukkit.entity.Player p, String uuid)
Create a vehicle and get its item by UUID (UUID may be found in vehicles.yml)static String
getLicensePlate(@Nullable org.bukkit.entity.Entity entity)
Get license plate of an entity (which should be a vehicle - seeisVehicle(Entity)
.static String
getLicensePlate(org.bukkit.inventory.ItemStack item)
Get license plate from a vehicle itemstatic double
getMaxHealthByDamage(int damage)
Check what is the max health of this vehicle.static UUID
getOwnerUUID(String licensePlate)
Get the UUID of the vehicle's ownerstatic String
getRidersAsString(String licensePlate)
Deprecated.UsecanRide(Player, String)
instead.static Vehicle
getVehicle(String licensePlate)
Get the Vehicle instance by a vehicle's license placestatic boolean
isInsideVehicle(org.bukkit.entity.Player p)
Check whether a player is inside a vehiclestatic boolean
isVehicle(org.bukkit.entity.Entity entity)
Check whether an entity is a vehiclestatic void
Open a vehicle's trunk to a playerstatic void
pickupVehicle(String license, org.bukkit.entity.Player player)
Pick up a vehicle and put it to player's inventorystatic void
spawnVehicle(String licensePlate, org.bukkit.Location location)
Spawn a vehicle
-
Field Details
-
openedTrunk
HashMap containing information about which trunk a player has opened (determined by vehicle's license plate)
-
-
Method Details
-
spawnVehicle
public static void spawnVehicle(String licensePlate, org.bukkit.Location location) throws IllegalArgumentExceptionSpawn a vehicle- Parameters:
licensePlate
- Vehicle's license platelocation
- Location where the vehicle should be spawned- Throws:
IllegalArgumentException
- If vehicle with given license plate does not exist
-
getLicensePlate
Get license plate from a vehicle item- Parameters:
item
- Vehicle as Item- Returns:
- Vehicle's license plate
-
getItemByUUID
public static org.bukkit.inventory.ItemStack getItemByUUID(org.bukkit.entity.Player p, String uuid)Create a vehicle and get its item by UUID (UUID may be found in vehicles.yml)- Parameters:
p
- Vehicle's owneruuid
- Vehicle's UUID (UUID may be found in vehicles.yml)- Returns:
- Vehicle item
-
getHornByDamage
public static boolean getHornByDamage(int damage)Check whether horn is enabled on this vehicle.- Parameters:
damage
- The vehicle item's durability- Returns:
- True if horn is enabled
-
getMaxHealthByDamage
public static double getMaxHealthByDamage(int damage)Check what is the max health of this vehicle.- Parameters:
damage
- The vehicle item's durability- Returns:
- Max health of the vehicle
-
getCarItem
Get a vehicle item by UUID. Does not create a new vehicle - just for aesthetic purposes. (Otherwise, usegetItemByUUID(Player, String)
)- Parameters:
carUUID
- Vehicle's UUID (UUID may be found in vehicles.yml)- Returns:
- The vehicle item - just aesthetic
-
isVehicle
public static boolean isVehicle(org.bukkit.entity.Entity entity)Check whether an entity is a vehicle- Parameters:
entity
- Checked entity- Returns:
- True if the entity is a vehicle
-
getLicensePlate
Get license plate of an entity (which should be a vehicle - seeisVehicle(Entity)
.- Parameters:
entity
- Vehicle's main armor stand- Returns:
- Vehicle's license plate
-
getCarUUID
Get the UUID of a car by its license plate- Parameters:
licensePlate
- Vehicle's license plate- Returns:
- Vehicle's UUID
-
getByLicensePlate
Deprecated.Renamed togetVehicle(String)
.Get the Vehicle instance by a vehicle's license place- Parameters:
licensePlate
- Vehicle's license plate- Returns:
- Vehicle instance
-
getVehicle
Get the Vehicle instance by a vehicle's license place- Parameters:
licensePlate
- Vehicle's license plate- Returns:
- Vehicle instance
- See Also:
Vehicle
-
existsByLicensePlate
Check whether this vehicle exists in the database (vehicleData.yml)- Parameters:
licensePlate
- Vehicle's license plate- Returns:
- True if vehicle is in the database (vehicleData.yml)
-
canRide
Check whether a player can ride/drive the vehicle.- Parameters:
player
- PlayerlicensePlate
- Vehicle's license plate- Returns:
- True if player is the vehicle's set rider.
-
canSit
Check whether a player can sit in the vehicle.- Parameters:
player
- PlayerlicensePlate
- Vehicle's license plate- Returns:
- True if player is the vehicle's set passenger/member.
-
getOwnerUUID
Get the UUID of the vehicle's owner- Parameters:
licensePlate
- Vehicle's license plate- Returns:
- UUID of vehicle's owner
-
openTrunk
Open a vehicle's trunk to a player- Parameters:
p
- Player who is opening the trunklicense
- Vehicle's license plate
-
isInsideVehicle
public static boolean isInsideVehicle(org.bukkit.entity.Player p)Check whether a player is inside a vehicle- Parameters:
p
- Player- Returns:
- True if player is inside any MTV vehicle
-
getRidersAsString
Deprecated.UsecanRide(Player, String)
instead.Get all the vehicle's set drivers/riders.- Parameters:
licensePlate
- Vehicle's license plate- Returns:
- String of all the drivers/riders separated by commas
-
pickupVehicle
Pick up a vehicle and put it to player's inventory- Parameters:
license
- Vehicle's license plateplayer
- Player
-
enterVehicle
CreateVehicleData
(necessary for driving to work) and make player enter a vehicle.- Parameters:
licensePlate
- Vehicle's license platep
- Player who is entering the vehicle
-
getVehicle(String)
.