Package nl.sbdeveloper.vehiclesplus.api
Class VehiclesPlusAPI
java.lang.Object
nl.sbdeveloper.vehiclesplus.api.VehiclesPlusAPI
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidAdds a garage to the garage map.static StorageVehiclecreateVehicle(@NotNull String modelID) Create a vehicle using a vehicle model.static StorageVehiclecreateVehicle(@NotNull String modelID, @NotNull Function<StorageVehicle, StorageVehicle> updater) Create a vehicle using a vehicle model.static StorageVehiclecreateVehicle(@NotNull String modelID, @NotNull Garage garage) Create a vehicle using a vehicle model.static StorageVehiclecreateVehicle(@NotNull String modelID, @NotNull Garage garage, @NotNull Function<StorageVehicle, StorageVehicle> updater) Create a vehicle using a vehicle model.static @NotNull StorageVehiclecreateVehicle(@NotNull VehicleModel model) Create a vehicle using a vehicle model.static StorageVehiclecreateVehicle(@NotNull VehicleModel model, @NotNull Function<StorageVehicle, StorageVehicle> updater) Create a vehicle using a vehicle model.static @NotNull StorageVehiclecreateVehicle(@NotNull VehicleModel model, @NotNull Garage garage) Create a vehicle using a vehicle model.static StorageVehiclecreateVehicle(@NotNull VehicleModel model, Garage garage, Function<StorageVehicle, StorageVehicle> updater) Create a vehicle using a vehicle model.static booleandoesPlayerOwnVehicles(@NotNull org.bukkit.OfflinePlayer p) Check if a player owns any vehicles.getFuelType(@NotNull String fuelType) Get a fuel type by its name.All the registered fuel typesGet a garage by name.Get a garage by a vehicle.All the garages.getGarages(@NotNull org.bukkit.OfflinePlayer player) Get the garages the player owns or is member in.getGarages(@NotNull org.bukkit.OfflinePlayer player, boolean ownerOnly) Get the garages the player owns or is member in.getHooks()static @NotNull GaragegetPersonalGarage(@NotNull org.bukkit.OfflinePlayer player) Get the personal garage of a player.getRimDesign(@NotNull String rimDesignID) Get a rimdesign by its ID.All the registered rim designsstatic @NotNull List<SpawnedVehicle> Get all theSpawnedVehiclesstatic @NotNull List<SpawnedVehicle> getSpawnedVehicles(@NotNull org.bukkit.OfflinePlayer p) Get the spawned vehicles owned by this player.static @NotNull List<StorageVehicle> Get all theStorageVehiclesstatic @NotNull List<StorageVehicle> getStorageVehicles(@NotNull org.bukkit.OfflinePlayer p, boolean force) Get the vehicles owned by this player.static VehiclegetVehicle(UUID vehicleUUID) Get a vehicle by its UUID.static @NotNull Optional<SpawnedVehicle> getVehicle(@NotNull org.bukkit.entity.Player p) Get the vehicle a player is driving.static @NotNull Optional<SpawnedVehicle> getVehicleFromHolder(@NotNull org.bukkit.entity.ArmorStand stand) Get the vehicle by a holderArmorStand.static @NotNull Optional<SpawnedVehicle> getVehicleFromPart(@NotNull org.bukkit.entity.ArmorStand stand) Get the vehicle by a partArmorStand.static @NotNull Optional<VehicleModel> getVehicleModel(@NotNull String modelID) Get a vehicle model by its ID.static Map<String, VehicleModel> All the registered vehicle modelsAll the vehicles, can be both stored or spawned.getVehicles(@NotNull org.bukkit.OfflinePlayer p) Get the vehicles owned by this player.static @NotNull Optional<VehicleType> getVehicleType(@NotNull String typeID) Get a vehicletype by its ID.static Map<String, VehicleType> All the registered vehicle typesstatic voidregisterHook(Runnable hook) Register a new API hook.static voidregisterPart(@NotNull Class<? extends Part> partClass) Register a new custom Partstatic booleanremoveGarage(@NotNull String name) Remove aGaragefrom a Player's garages.
-
Method Details
-
getFuelType
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
Create a vehicle using a vehicle model.- Parameters:
modelID- The ID of the vehicle model.- Returns:
- The
Vehiclecreated, or null if the model does not exist. The function also saves theStorageVehicle.
-
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
Vehiclecreated, or null if the model does not exist. The function also saves theStorageVehicleand theGarageit 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
StorageVehiclecreated, with the updater function applied, or null if the model does not exist or the function returned null. The function also saves theStorageVehicle.
-
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
StorageVehiclecreated, with the updater function applied, or null if the model does not exist or the function returned null. The function also saves theStorageVehicleand theGarageit was added to.
-
createVehicle
Create a vehicle using a vehicle model.- Parameters:
model- The vehicle model.- Returns:
- The
StorageVehiclecreated. The function also saves theStorageVehicle.
-
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
StorageVehiclecreated. The function also saves theStorageVehicleand theGarageit 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
StorageVehiclecreated, with the updater function applied, or null if the function returned null. The function also saves theStorageVehicle.
-
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
StorageVehiclecreated, with the updater function applied, or null if the function returned null. The function also saves theStorageVehicleand theGarageit was added to.
-
getVehicle
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
Optionalwith theSpawnedVehicle
-
getVehicleFromHolder
@NotNull public static @NotNull Optional<SpawnedVehicle> getVehicleFromHolder(@NotNull @NotNull org.bukkit.entity.ArmorStand stand) Get the vehicle by a holderArmorStand.- Parameters:
stand- The holder armorstand.- Returns:
- An
Optionalwith theSpawnedVehicle
-
getVehicleFromPart
@NotNull public static @NotNull Optional<SpawnedVehicle> getVehicleFromPart(@NotNull @NotNull org.bukkit.entity.ArmorStand stand) Get the vehicle by a partArmorStand.- Parameters:
stand- The part armorstand.- Returns:
- An
Optionalwith theSpawnedVehicle
-
getStorageVehicles
Get all theStorageVehicles- Returns:
- An
Listwith theStorageVehicles
-
getSpawnedVehicles
Get all theSpawnedVehicles- Returns:
- An
Listwith theSpawnedVehicles
-
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
Adds a garage to the garage map. Construct your ownGarageusing the constructor. Make sure to save the garage yourself usingQueuedSavable.save()!- Parameters:
garage- TheGarageto add.force- Should the garage be overwritten if already in the map?
-
removeGarage
Remove aGaragefrom a Player's garages.- Parameters:
name- TheGarageto 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
Garageof 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. -
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. -
getGarage
Get a garage by name. -
getGarage
Get a garage by a vehicle. -
registerHook
Register a new API hook. Hooks can be used to run code when the API is loaded.- Parameters:
hook- The hook to register.
-
registerPart
Register a new custom Part- Parameters:
partClass- The class of the part. Must extendPartand be annotated withPartTypeName.
-
getFuelTypes
All the registered fuel typesKey = FuelTypeID Value = FuelType
-
getRimDesigns
All the registered rim designsKey = RimDesignID Value = RimDesign
-
getVehicleTypes
All the registered vehicle typesKey = TypeID Value = Type
-
getVehicleModels
All the registered vehicle modelsKey = ModelID Value = Model
-
getVehicles
All the vehicles, can be both stored or spawned.Key = Vehicle UUID Value = Vehicle
-
getGarages
All the garages.Key = Garage UUID Value = Garage
-
getHooks
-