Class VehiclesPlusAPI

java.lang.Object
nl.sbdeveloper.vehiclesplus.api.VehiclesPlusAPI

public class VehiclesPlusAPI extends Object
  • Method Details

    • getFuelType

      @NotNull public static @NotNull Optional<FuelType> getFuelType(@NotNull @NotNull String fuelType)
      Get a fuel type by its name.
      Parameters:
      fuelType - The fuel type to load.
      Returns:
      The FuelType
    • getRimDesign

      @NotNull public static @NotNull Optional<RimDesign> getRimDesign(@NotNull @NotNull String rimDesignID)
      Get a rimdesign by its ID.
      Parameters:
      rimDesignID - The ID of the rimdesign.
      Returns:
      The RimDesign
    • getVehicleType

      @NotNull public static @NotNull Optional<VehicleType> getVehicleType(@NotNull @NotNull String typeID)
      Get a vehicletype by its ID.
      Parameters:
      typeID - The ID of the vehicletype.
      Returns:
      The VehicleType
    • getVehicleModel

      @NotNull public static @NotNull Optional<VehicleModel> getVehicleModel(@NotNull @NotNull String modelID)
      Get a vehicle model by its ID.
      Parameters:
      modelID - The ID of the vehicle model.
      Returns:
      The VehicleModel
    • createVehicle

      @Nullable public static StorageVehicle createVehicle(@NotNull @NotNull String modelID)
      Create a vehicle using a vehicle model.
      Parameters:
      modelID - The ID of the vehicle model.
      Returns:
      The Vehicle created, or null if the model does not exist. The function also saves the StorageVehicle.
    • createVehicle

      @Nullable public static StorageVehicle createVehicle(@NotNull @NotNull String modelID, @NotNull @NotNull Garage garage)
      Create a vehicle using a vehicle model.
      Parameters:
      modelID - The ID of the vehicle model.
      garage - The garage to add the vehicle to.
      Returns:
      The Vehicle created, or null if the model does not exist. The function also saves the StorageVehicle and the Garage it was added to.
    • createVehicle

      @Nullable public static StorageVehicle createVehicle(@NotNull @NotNull String modelID, @NotNull @NotNull Function<StorageVehicle,StorageVehicle> updater)
      Create a vehicle using a vehicle model.
      Parameters:
      modelID - The ID of the vehicle model.
      updater - Function to update the StorageVehicle created before saving it.
      Returns:
      The StorageVehicle created, with the updater function applied, or null if the model does not exist or the function returned null. The function also saves the StorageVehicle.
    • createVehicle

      @Nullable public static StorageVehicle createVehicle(@NotNull @NotNull String modelID, @NotNull @NotNull Garage garage, @NotNull @NotNull Function<StorageVehicle,StorageVehicle> updater)
      Create a vehicle using a vehicle model.
      Parameters:
      modelID - The ID of the vehicle model.
      garage - The garage to add the vehicle to.
      updater - Function to update the StorageVehicle created before saving it.
      Returns:
      The StorageVehicle created, with the updater function applied, or null if the model does not exist or the function returned null. The function also saves the StorageVehicle and the Garage it was added to.
    • createVehicle

      @NotNull public static @NotNull StorageVehicle createVehicle(@NotNull @NotNull VehicleModel model)
      Create a vehicle using a vehicle model.
      Parameters:
      model - The vehicle model.
      Returns:
      The StorageVehicle created. The function also saves the StorageVehicle.
    • createVehicle

      @NotNull public static @NotNull StorageVehicle createVehicle(@NotNull @NotNull VehicleModel model, @NotNull @NotNull Garage garage)
      Create a vehicle using a vehicle model.
      Parameters:
      model - The vehicle model.
      garage - The garage to add the vehicle to.
      Returns:
      The StorageVehicle created. The function also saves the StorageVehicle and the Garage it was added to.
    • createVehicle

      @Nullable public static StorageVehicle createVehicle(@NotNull @NotNull VehicleModel model, @NotNull @NotNull Function<StorageVehicle,StorageVehicle> updater)
      Create a vehicle using a vehicle model.
      Parameters:
      model - The vehicle model.
      updater - Function to update the StorageVehicle created before saving it.
      Returns:
      The StorageVehicle created, with the updater function applied, or null if the function returned null. The function also saves the StorageVehicle.
    • createVehicle

      @Nullable public static StorageVehicle createVehicle(@NotNull @NotNull VehicleModel model, @Nullable Garage garage, @Nullable Function<StorageVehicle,StorageVehicle> updater)
      Create a vehicle using a vehicle model.
      Parameters:
      model - The vehicle model.
      garage - The garage to add the vehicle to.
      updater - Function to update the StorageVehicle created before saving it.
      Returns:
      The StorageVehicle created, with the updater function applied, or null if the function returned null. The function also saves the StorageVehicle and the Garage it was added to.
    • getVehicle

      @Nullable public static Vehicle getVehicle(UUID vehicleUUID)
      Get a vehicle by its UUID.
      Parameters:
      vehicleUUID - The UUID of the vehicle.
      Returns:
      The Vehicle
    • doesPlayerOwnVehicles

      public static boolean doesPlayerOwnVehicles(@NotNull @NotNull org.bukkit.OfflinePlayer p)
      Check if a player owns any vehicles.
      Parameters:
      p - The player to check for.
      Returns:
      true if the player owns vehicles, false if not.
    • getVehicles

      @NotNull public static @NotNull List<Vehicle> getVehicles(@NotNull @NotNull org.bukkit.OfflinePlayer p)
      Get the vehicles owned by this player.
      Parameters:
      p - The player who owns the vehicles.
      Returns:
      A list of the Vehicles this player owns.
    • getVehicle

      @NotNull public static @NotNull Optional<SpawnedVehicle> getVehicle(@NotNull @NotNull org.bukkit.entity.Player p)
      Get the vehicle a player is driving.
      Parameters:
      p - The player who is driving the vehicle.
      Returns:
      An Optional with the SpawnedVehicle
    • getVehicleFromHolder

      @NotNull public static @NotNull Optional<SpawnedVehicle> getVehicleFromHolder(@NotNull @NotNull org.bukkit.entity.ArmorStand stand)
      Get the vehicle by a holder ArmorStand.
      Parameters:
      stand - The holder armorstand.
      Returns:
      An Optional with the SpawnedVehicle
    • getVehicleFromPart

      @NotNull public static @NotNull Optional<SpawnedVehicle> getVehicleFromPart(@NotNull @NotNull org.bukkit.entity.ArmorStand stand)
      Get the vehicle by a part ArmorStand.
      Parameters:
      stand - The part armorstand.
      Returns:
      An Optional with the SpawnedVehicle
    • getStorageVehicles

      @NotNull public static @NotNull List<StorageVehicle> getStorageVehicles()
      Get all the StorageVehicles
      Returns:
      An List with the StorageVehicles
    • getSpawnedVehicles

      @NotNull public static @NotNull List<SpawnedVehicle> getSpawnedVehicles()
      Get all the SpawnedVehicles
      Returns:
      An List with the SpawnedVehicles
    • getStorageVehicles

      @NotNull public static @NotNull List<StorageVehicle> getStorageVehicles(@NotNull @NotNull org.bukkit.OfflinePlayer p, boolean force)
      Get the vehicles owned by this player.
      Parameters:
      p - The player who owns the vehicles.
      force - If true, spawned vehicles will be casted to storage vehicles. If false, it will not return spawned vehicles.
      Returns:
      A list of the StorageVehicles this player owns.
    • getSpawnedVehicles

      @NotNull public static @NotNull List<SpawnedVehicle> getSpawnedVehicles(@NotNull @NotNull org.bukkit.OfflinePlayer p)
      Get the spawned vehicles owned by this player.
      Parameters:
      p - The player who owns the vehicles.
      Returns:
      A list of the SpawnedVehicles this player owns.
    • addGarage

      public static void addGarage(@NotNull @NotNull Garage garage, boolean force)
      Adds a garage to the garage map. Construct your own Garage using the constructor. Make sure to save the garage yourself using QueuedSavable.save()!
      Parameters:
      garage - The Garage to add.
      force - Should the garage be overwritten if already in the map?
    • removeGarage

      public static boolean removeGarage(@NotNull @NotNull String name)
      Remove a Garage from a Player's garages.
      Parameters:
      name - The Garage to remove.
      Returns:
      true if removed, false if not.
    • getPersonalGarage

      @NotNull public static @NotNull Garage getPersonalGarage(@NotNull @NotNull org.bukkit.OfflinePlayer player)
      Get the personal garage of a player. If the player does not have a personal garage, it will create one.
      Parameters:
      player - The player to get the garage from.
      Returns:
      The Garage of the player.
    • getGarages

      @NotNull public static @NotNull List<Garage> getGarages(@NotNull @NotNull org.bukkit.OfflinePlayer player)
      Get the garages the player owns or is member in.
      Parameters:
      player - The player where you want to get the garage(s) from.
      Returns:
      An List with the Garage
    • getGarages

      @NotNull public static @NotNull List<Garage> getGarages(@NotNull @NotNull org.bukkit.OfflinePlayer player, boolean ownerOnly)
      Get the garages the player owns or is member in.
      Parameters:
      player - The player where you want to get the garage(s) from.
      ownerOnly - toggles to only fetch garages where the player is owner from.
      Returns:
      An List with the Garage
    • getGarage

      @NotNull public static @NotNull Optional<Garage> getGarage(@NotNull @NotNull String name)
      Get a garage by name.
      Parameters:
      name - The name of the garage you want to get.
      Returns:
      An Optional with the Garage
    • getGarage

      @NotNull public static @NotNull Optional<Garage> getGarage(@NotNull @NotNull Vehicle vehicle)
      Get a garage by a vehicle.
      Parameters:
      vehicle - The garage where the vehicle should be in.
      Returns:
      An Optional with the Garage
    • registerHook

      public static void registerHook(Runnable hook)
      Register a new API hook. Hooks can be used to run code when the API is loaded.
      Parameters:
      hook - The hook to register.
    • registerPart

      public static void registerPart(@NotNull @NotNull Class<? extends Part> partClass)
      Register a new custom Part
      Parameters:
      partClass - The class of the part. Must extend Part and be annotated with PartTypeName.
    • getFuelTypes

      public static Map<String,FuelType> getFuelTypes()
      All the registered fuel types

      Key = FuelTypeID Value = FuelType

    • getRimDesigns

      public static Map<String,RimDesign> getRimDesigns()
      All the registered rim designs

      Key = RimDesignID Value = RimDesign

    • getVehicleTypes

      public static Map<String,VehicleType> getVehicleTypes()
      All the registered vehicle types

      Key = TypeID Value = Type

    • getVehicleModels

      public static Map<String,VehicleModel> getVehicleModels()
      All the registered vehicle models

      Key = ModelID Value = Model

    • getVehicles

      public static Map<UUID,Vehicle> getVehicles()
      All the vehicles, can be both stored or spawned.

      Key = Vehicle UUID Value = Vehicle

    • getGarages

      public static Map<String,Garage> getGarages()
      All the garages.

      Key = Garage UUID Value = Garage

    • getHooks

      public static List<Runnable> getHooks()