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

public abstract class SpawnedVehicle extends Vehicle
An abstract class that represents a spawned vehicle. Implemented by a PersistentVehicle and a DrivableVehicle.
  • Field Details

    • storageVehicle

      protected final StorageVehicle storageVehicle
      The vehicle that is spawned
    • holder

      protected org.bukkit.entity.ArmorStand holder
      The 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

      @Nullable public @Nullable DrivableVehicle getAsDrivableVehicle()
      Get the vehicle as a DrivableVehicle.
      Returns:
      The DrivableVehicle if that is the correct type, or null.
    • getAsPersistentVehicle

      @Nullable public @Nullable PersistentVehicle getAsPersistentVehicle()
      Get the vehicle as a PersistentVehicle.
      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

      public StorageVehicle despawn(VehicleDespawnEvent.DespawnReason reason, boolean force)
      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

      public StorageVehicle despawn(org.bukkit.entity.Player despawner)
      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

      public StorageVehicle despawn(boolean force, org.bukkit.entity.Player despawner)
      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

      protected StorageVehicle despawnVehicle()
      Internal method to despawn the vehicle. Use despawn(VehicleDespawnEvent.DespawnReason) or despawn(boolean, Player) instead.
      Returns:
      The StorageVehicle if despawned.
    • getParts

      @NotNull public @NotNull List<Part> getParts()
      Description copied from class: Vehicle
      Get all the parts of this vehicle.
      Specified by:
      getParts in class Vehicle
      Returns:
      A list of all the parts.
    • getParts

      @NotNull public <V> @NotNull List<V> getParts(Class<V> partClass)
      Description copied from class: Vehicle
      Get all the parts of a specific type.
      Specified by:
      getParts in class Vehicle
      Type Parameters:
      V - The part itself.
      Parameters:
      partClass - The class of the part.
      Returns:
      A list of all the parts of that type.
    • getPart

      public <V> V getPart(@NotNull @NotNull Class<V> partClass)
      Description copied from class: Vehicle
      Get the first occurrence of a specific type.
      Specified by:
      getPart in class Vehicle
      Type Parameters:
      V - The part itself.
      Parameters:
      partClass - The class of the part.
      Returns:
      The part of that type, or null if not found.
    • getParts

      public <V> List<V> getParts(Class<V> partClass, Predicate<? super V> filter)
      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

      public <V> Optional<V> getPart(Class<V> partClass, Predicate<? super V> filter)
      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

      public Part getPart(org.bukkit.entity.ArmorStand stand)
      Description copied from class: Vehicle
      Get a part from the holder stand.
      Specified by:
      getPart in class Vehicle
      Parameters:
      stand - The holder stand.
      Returns:
      The part.
    • hasAddedParts

      public boolean hasAddedParts()
      Description copied from class: Vehicle
      Check if this vehicle has any addon parts.
      Specified by:
      hasAddedParts in class Vehicle
      Returns:
      If this vehicle has any addon parts.
    • getStatics

      public VehicleStatics getStatics()
      Description copied from class: Vehicle
      Get the statics of this vehicle.
      Specified by:
      getStatics in class Vehicle
      Returns:
      The statics of this vehicle
    • getUuid

      public UUID getUuid()
      Description copied from class: Vehicle
      Get the UUID of this vehicle
      Specified by:
      getUuid in class Vehicle
      Returns:
      The UUID of this vehicle
    • getVehicleModel

      public VehicleModel getVehicleModel()
      Description copied from class: Vehicle
      Get the basevehicle / type of this vehicle
      Specified by:
      getVehicleModel in class Vehicle
      Returns:
      The basevehicle / type of this vehicle
    • getInfoList

      public List<String> getInfoList()
      Description copied from class: Vehicle
      Get the information of this vehicle
      Specified by:
      getInfoList in class Vehicle
      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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getStorageVehicle

      public StorageVehicle getStorageVehicle()
      The vehicle that is spawned
      Overrides:
      getStorageVehicle in class Vehicle
      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

      public CollisionHandler getCollisionHandler()
      The collision handler of this vehicle