Class SpawnedVehicle
java.lang.Object
nl.sbdeveloper.vehiclesplus.api.vehicles.Vehicle
nl.sbdeveloper.vehiclesplus.api.vehicles.impl.SpawnedVehicle
- All Implemented Interfaces:
IVehicle
- Direct Known Subclasses:
DrivableVehicle,PersistentVehicle
An abstract class that represents a spawned vehicle.
Implemented by a
PersistentVehicle and a DrivableVehicle.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.bukkit.entity.ArmorStandThe main holder of this vehicleprotected final StorageVehicleThe vehicle that is spawned -
Method Summary
Modifier and TypeMethodDescription<T extends MovementStrategy>
voidapplyToStrategy(MovementType type, Consumer<T> applyFunction) Apply a function to a specific strategy.protected booleandespawn(boolean force, org.bukkit.entity.Player despawner) Despawn this vehicle.Despawn this vehicle.despawn(VehicleDespawnEvent.DespawnReason reason, boolean force) Despawn this vehicle.despawn(org.bukkit.entity.Player despawner) Despawn this vehicle.protected StorageVehicleInternal method to despawn the vehicle.boolean@Nullable DrivableVehicleGet the vehicle as aDrivableVehicle.@Nullable PersistentVehicleGet the vehicle as aPersistentVehicle.The collision handler of this vehicle<T extends MovementStrategy,R>
RgetFromStrategy(MovementType type, Function<T, R> applyFunction, R defaultValue) org.bukkit.entity.ArmorStandThe main holder of this vehicleGet the information of this vehicleorg.bukkit.LocationThe last known location of this vehicle<V> VGet the first occurrence of a specific type.<V> Optional<V> Get the first part of a specific class that match the filter.getPart(org.bukkit.entity.ArmorStand stand) Get a part from the holder stand.getParts()Get all the parts of this vehicle.<V> @NotNull List<V> Get all the parts of a specific type.<V> List<V> Get all parts of a specific class that match the filter.Get the statics of this vehicle.The vehicle that is spawnedgetUuid()Get the UUID of this vehicleGet the basevehicle / type of this vehiclebooleanCheck if this vehicle has any addon parts.inthashCode()booleanCheck if this vehicle is drivable or not.booleanCheck if this vehicle is persistent or not.voidsetHolder(org.bukkit.entity.ArmorStand holder) The main holder of this vehicletoString()voidupdate()Update the vehicle (check for collisions).Methods inherited from class nl.sbdeveloper.vehiclesplus.api.vehicles.Vehicle
getGarage, getSpawnedVehicle, getStorageVehicle, isSpawned, remove, remove
-
Field Details
-
storageVehicle
The vehicle that is spawned -
holder
protected org.bukkit.entity.ArmorStand holderThe main holder of this vehicle
-
-
Method Details
-
isPersistent
public boolean isPersistent()Check if this vehicle is persistent or not.- Returns:
- Check if this vehicle is persistent.
-
isDrivable
public boolean isDrivable()Check if this vehicle is drivable or not.- Returns:
- Check if this vehicle is drivable.
-
getAsDrivableVehicle
Get the vehicle as aDrivableVehicle.- Returns:
- The DrivableVehicle if that is the correct type, or null.
-
getAsPersistentVehicle
Get the vehicle as aPersistentVehicle.- Returns:
- The PersistentVehicle if that is the correct type, or null.
-
despawn
Despawn this vehicle.- Parameters:
reason- The reason why the vehicle gets despawned.- Returns:
- The StorageVehicle if despawned, or null if failed because the event has been cancelled.
-
despawn
Despawn this vehicle.- Parameters:
reason- The reason why the vehicle gets despawned.force- Should the despawn be forced? If so, the event can't cancel the despawn.- Returns:
- The StorageVehicle if despawned, or null if failed because the event has been cancelled.
-
despawn
Despawn this vehicle.- Parameters:
despawner- The player who despawned the vehicle.- Returns:
- The StorageVehicle if despawned, or null if failed because the event has been cancelled.
-
despawn
Despawn this vehicle.- Parameters:
force- Should the despawn be forced? If so, the event can't cancel the despawn.despawner- The player who despawned the vehicle.- Returns:
- The StorageVehicle if despawned, or null if failed because the event has been cancelled.
-
despawnVehicle
Internal method to despawn the vehicle. Usedespawn(VehicleDespawnEvent.DespawnReason)ordespawn(boolean, Player)instead.- Returns:
- The StorageVehicle if despawned.
-
getParts
Description copied from class:VehicleGet all the parts of this vehicle. -
getParts
Description copied from class:VehicleGet all the parts of a specific type. -
getPart
Description copied from class:VehicleGet the first occurrence of a specific type. -
getParts
Get all parts of a specific class that match the filter.- Type Parameters:
V- The type of the part.- Parameters:
partClass- The class of the part.filter- The filter to apply.- Returns:
- A list of parts that match the filter.
-
getPart
Get the first part of a specific class that match the filter.- Type Parameters:
V- The type of the part.- Parameters:
partClass- The class of the part.filter- The filter to apply.- Returns:
- An optional of the part that match the filter.
-
getPart
Description copied from class:VehicleGet a part from the holder stand. -
hasAddedParts
public boolean hasAddedParts()Description copied from class:VehicleCheck if this vehicle has any addon parts.- Specified by:
hasAddedPartsin classVehicle- Returns:
- If this vehicle has any addon parts.
-
getStatics
Description copied from class:VehicleGet the statics of this vehicle.- Specified by:
getStaticsin classVehicle- Returns:
- The statics of this vehicle
-
getUuid
Description copied from class:VehicleGet the UUID of this vehicle -
getVehicleModel
Description copied from class:VehicleGet the basevehicle / type of this vehicle- Specified by:
getVehicleModelin classVehicle- Returns:
- The basevehicle / type of this vehicle
-
getInfoList
Description copied from class:VehicleGet the information of this vehicle- Specified by:
getInfoListin classVehicle- Returns:
- A list with the formatted information
-
update
public void update()Update the vehicle (check for collisions). -
getFromStrategy
public <T extends MovementStrategy,R> R getFromStrategy(MovementType type, Function<T, R> applyFunction, @NotNull R defaultValue) -
applyToStrategy
public <T extends MovementStrategy> void applyToStrategy(MovementType type, Consumer<T> applyFunction) Apply a function to a specific strategy.- Type Parameters:
T- The type of the strategy.- Parameters:
type- The type of the strategy.applyFunction- The function to apply.
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-
getStorageVehicle
The vehicle that is spawned- Overrides:
getStorageVehiclein classVehicle- Returns:
- The StorageVehicle if not spawned, or null.
-
getHolder
public org.bukkit.entity.ArmorStand getHolder()The main holder of this vehicle -
setHolder
public void setHolder(org.bukkit.entity.ArmorStand holder) The main holder of this vehicle -
getLastKnownLocation
public org.bukkit.Location getLastKnownLocation()The last known location of this vehicle -
getCollisionHandler
The collision handler of this vehicle
-