diff --git a/pom.xml b/custom model/pom.xml
similarity index 88%
rename from pom.xml
rename to custom model/pom.xml
index c398563..050853c 100644
--- a/pom.xml
+++ b/custom model/pom.xml
@@ -5,11 +5,11 @@
4.0.0tech.sbdevelopment
- vp3apitest
+ customModel1.0jar
- vp3apitest
+ CustomModel21
@@ -59,6 +59,11 @@
sonatypehttps://oss.sonatype.org/content/groups/public/
+
+ sbdevelopment-repo-releases
+ SBDevelopment Repository
+ https://repo.sbdevelopment.tech/releases
+
@@ -71,7 +76,7 @@
nl.sbdeveloperVehiclesPlus-API
- 3.0.0-SNAPSHOT
+ 3.0.2provided
diff --git a/src/main/java/tech/sbdevelopment/vp3apitest/VP3APItest.java b/custom model/src/main/java/tech/sbdevelopment/customModel/CustomModel.java
similarity index 72%
rename from src/main/java/tech/sbdevelopment/vp3apitest/VP3APItest.java
rename to custom model/src/main/java/tech/sbdevelopment/customModel/CustomModel.java
index 2917c3a..78063cf 100644
--- a/src/main/java/tech/sbdevelopment/vp3apitest/VP3APItest.java
+++ b/custom model/src/main/java/tech/sbdevelopment/customModel/CustomModel.java
@@ -1,10 +1,10 @@
-package tech.sbdevelopment.vp3apitest;
+package tech.sbdevelopment.customModel;
import nl.sbdeveloper.vehiclesplus.api.VehiclesPlusAPI;
import org.bukkit.plugin.java.JavaPlugin;
-import tech.sbdevelopment.vp3apitest.parts.Vent;
+import tech.sbdevelopment.customModel.parts.Vent;
-public final class VP3APItest extends JavaPlugin {
+public final class CustomModel extends JavaPlugin {
@Override
public void onEnable() {
VehiclesPlusAPI.registerHook(() -> {
diff --git a/src/main/java/tech/sbdevelopment/vp3apitest/models/DefaultSubmarine.java b/custom model/src/main/java/tech/sbdevelopment/customModel/models/DefaultSubmarine.java
similarity index 96%
rename from src/main/java/tech/sbdevelopment/vp3apitest/models/DefaultSubmarine.java
rename to custom model/src/main/java/tech/sbdevelopment/customModel/models/DefaultSubmarine.java
index 223f473..7fbb871 100644
--- a/src/main/java/tech/sbdevelopment/vp3apitest/models/DefaultSubmarine.java
+++ b/custom model/src/main/java/tech/sbdevelopment/customModel/models/DefaultSubmarine.java
@@ -1,4 +1,4 @@
-package tech.sbdevelopment.vp3apitest.models;
+package tech.sbdevelopment.customModel.models;
import nl.sbdeveloper.vehiclesplus.api.vehicles.HolderItemPosition;
import nl.sbdeveloper.vehiclesplus.api.vehicles.VehicleModel;
@@ -12,7 +12,7 @@ import nl.sbdeveloper.vehiclesplus.utils.jackson.ColorList;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.Sound;
-import tech.sbdevelopment.vp3apitest.parts.Vent;
+import tech.sbdevelopment.customModel.parts.Vent;
public class DefaultSubmarine extends DefaultVehicleModel {
@Override
diff --git a/src/main/java/tech/sbdevelopment/vp3apitest/parts/Vent.java b/custom model/src/main/java/tech/sbdevelopment/customModel/parts/Vent.java
similarity index 97%
rename from src/main/java/tech/sbdevelopment/vp3apitest/parts/Vent.java
rename to custom model/src/main/java/tech/sbdevelopment/customModel/parts/Vent.java
index a5813a3..5b8dfbb 100644
--- a/src/main/java/tech/sbdevelopment/vp3apitest/parts/Vent.java
+++ b/custom model/src/main/java/tech/sbdevelopment/customModel/parts/Vent.java
@@ -1,4 +1,4 @@
-package tech.sbdevelopment.vp3apitest.parts;
+package tech.sbdevelopment.customModel.parts;
import nl.sbdeveloper.vehiclesplus.api.vehicles.HolderItemPosition;
import nl.sbdeveloper.vehiclesplus.api.vehicles.movement.MovementInput;
diff --git a/src/main/resources/plugin.yml b/custom model/src/main/resources/plugin.yml
similarity index 100%
rename from src/main/resources/plugin.yml
rename to custom model/src/main/resources/plugin.yml
diff --git a/website example/pom.xml b/website example/pom.xml
new file mode 100644
index 0000000..d5b33f5
--- /dev/null
+++ b/website example/pom.xml
@@ -0,0 +1,83 @@
+
+
+ 4.0.0
+
+ tech.sbdevelopment
+ websiteExample
+ 1.0-SNAPSHOT
+ jar
+
+ websiteExample
+
+
+ 21
+ UTF-8
+
+
+
+ clean package
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.13.0
+
+
+ ${java.version}
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.5.3
+
+
+ package
+
+ shade
+
+
+
+
+
+
+
+ src/main/resources
+ true
+
+
+
+
+
+
+ papermc-repo
+ https://repo.papermc.io/repository/maven-public/
+
+
+ sonatype
+ https://oss.sonatype.org/content/groups/public/
+
+
+ sbdevelopment-repo-releases
+ SBDevelopment Repository
+ https://repo.sbdevelopment.tech/releases
+
+
+
+
+
+ io.papermc.paper
+ paper-api
+ 1.21-R0.1-SNAPSHOT
+ provided
+
+
+ nl.sbdeveloper
+ VehiclesPlus-API
+ 3.0.2
+ provided
+
+
+
diff --git a/website example/src/main/java/tech/sbdevelopment/websiteExample/WebsiteExample.java b/website example/src/main/java/tech/sbdevelopment/websiteExample/WebsiteExample.java
new file mode 100644
index 0000000..7d51987
--- /dev/null
+++ b/website example/src/main/java/tech/sbdevelopment/websiteExample/WebsiteExample.java
@@ -0,0 +1,16 @@
+package tech.sbdevelopment.websiteExample;
+
+import org.bukkit.plugin.java.JavaPlugin;
+
+public final class WebsiteExample extends JavaPlugin {
+
+ @Override
+ public void onEnable() {
+
+ }
+
+ @Override
+ public void onDisable() {
+
+ }
+}
diff --git a/website example/src/main/java/tech/sbdevelopment/websiteExample/examples/DeleteVehicle.java b/website example/src/main/java/tech/sbdevelopment/websiteExample/examples/DeleteVehicle.java
new file mode 100644
index 0000000..53b995e
--- /dev/null
+++ b/website example/src/main/java/tech/sbdevelopment/websiteExample/examples/DeleteVehicle.java
@@ -0,0 +1,59 @@
+package tech.sbdevelopment.websiteExample.examples;
+
+import nl.sbdeveloper.vehiclesplus.api.VehiclesPlusAPI;
+import nl.sbdeveloper.vehiclesplus.api.garages.Garage;
+import nl.sbdeveloper.vehiclesplus.api.vehicles.Vehicle;
+import nl.sbdeveloper.vehiclesplus.storage.db.exceptions.DataStorageException;
+
+import java.util.Optional;
+
+public class DeleteVehicle {
+ /**
+ * Removes a specific vehicle from the "police" garage based on the given model name.
+ * This method retrieves the police garage, searches for a vehicle with the specified model name,
+ * and removes the vehicle from the garage if found.
+ * It handles the case where the garage or vehicle doesn't exist and logs appropriate messages.
+ *
+ * @param vehicleModelName The model name of the vehicle to remove from the police garage.
+ */
+ public void removeVehicleFromPoliceGarage(String vehicleModelName) {
+ // Retrieve the "police" garage using its name
+ Optional policeGarageOptional = VehiclesPlusAPI.getGarage("police");
+
+ // Check if the police garage exists, and if not, print an error message and exit
+ if (policeGarageOptional.isEmpty()) {
+ System.err.println("Error: The 'police' garage does not exist.");
+ return;
+ }
+
+ // Get the actual garage object
+ Garage policeGarage = policeGarageOptional.get();
+
+ // Search for the vehicle with the given model name within the "police" garage
+ Optional vehicleToRemoveOptional = policeGarage.getVehicles().stream()
+ // Convert the vehicle UUID to an actual StorageVehicle object
+ .map(VehiclesPlusAPI::getVehicle)
+ // Filter vehicles to match the given model name
+ .filter(vehicle -> vehicle != null && vehicle.getVehicleModel().getId().equals(vehicleModelName))
+ // Select the first match
+ .findFirst();
+
+ // If a matching vehicle is found, attempt to remove it
+ if (vehicleToRemoveOptional.isPresent()) {
+ Vehicle vehicleToRemove = vehicleToRemoveOptional.get();
+
+ try {
+ // Remove the vehicle from the garage
+ vehicleToRemove.remove();
+ System.out.println("Vehicle with model '" + vehicleModelName + "' has been successfully removed from the police garage.");
+ } catch (DataStorageException e) {
+ // Handle any errors that occur during the removal process
+ System.err.println("Error: Failed to remove vehicle with model '" + vehicleModelName + "' from the garage.");
+ throw new RuntimeException("Error while removing vehicle", e);
+ }
+ } else {
+ // If no matching vehicle was found, print an error message
+ System.err.println("Error: No vehicle with model '" + vehicleModelName + "' found in the police garage.");
+ }
+ }
+}
diff --git a/website example/src/main/java/tech/sbdevelopment/websiteExample/examples/DespawnVehicle.java b/website example/src/main/java/tech/sbdevelopment/websiteExample/examples/DespawnVehicle.java
new file mode 100644
index 0000000..221a133
--- /dev/null
+++ b/website example/src/main/java/tech/sbdevelopment/websiteExample/examples/DespawnVehicle.java
@@ -0,0 +1,63 @@
+package tech.sbdevelopment.websiteExample.examples;
+
+import nl.sbdeveloper.vehiclesplus.api.VehiclesPlusAPI;
+import nl.sbdeveloper.vehiclesplus.api.events.impl.VehicleDespawnEvent;
+import nl.sbdeveloper.vehiclesplus.api.vehicles.Vehicle;
+import nl.sbdeveloper.vehiclesplus.api.vehicles.impl.SpawnedVehicle;
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Comparator;
+import java.util.List;
+import java.util.Optional;
+
+public class DespawnVehicle {
+ /**
+ * Despawns the first spawned vehicle of a player.
+ * If the player has multiple spawned vehicles, this method will despawn the first one retrieved.
+ *
+ * @param player The player whose vehicle is to be despawned.
+ */
+ public void despawnFirstVehicle(Player player) {
+ // Retrieve the first spawned vehicle of the player
+ Optional firstSpawnedVehicleOptional = VehiclesPlusAPI.getVehicle(player);
+
+ // Check if a vehicle is present to despawn
+ if (firstSpawnedVehicleOptional.isPresent()) {
+ // Despawn the vehicle using the API's despawn reason
+ firstSpawnedVehicleOptional.get().despawn(VehicleDespawnEvent.DespawnReason.API);
+ System.out.println("Vehicle despawned successfully.");
+ } else {
+ // Handle the case where the player doesn't have a spawned vehicle
+ System.err.println("Player does not have a spawned vehicle.");
+ }
+ }
+
+ /**
+ * Despawns the closest spawned vehicle to the executor player.
+ * The executor player is the one determining which vehicle is closest to them.
+ *
+ * @param executor The player who is looking for the closest vehicle to despawn.
+ * @param targetPlayer The player whose vehicles will be checked.
+ */
+ public void despawnClosestVehicle(Player executor, Player targetPlayer) {
+ // Retrieve a list of all spawned vehicles belonging to the target player
+ @NotNull List vehiclesOfTargetPlayer = VehiclesPlusAPI.getVehicles(targetPlayer);
+
+ // Find the closest spawned vehicle to the executor player
+ Optional closestVehicleOptional = vehiclesOfTargetPlayer.stream()
+ .filter(vehicle -> vehicle instanceof SpawnedVehicle) // Only consider spawned vehicles
+ .map(vehicle -> (SpawnedVehicle) vehicle)
+ .min(Comparator.comparingDouble(vehicle -> vehicle.getHolder().getLocation().distance(executor.getLocation())));
+
+ // Check if the closest vehicle was found
+ if (closestVehicleOptional.isPresent()) {
+ // Despawn the closest vehicle using the API's despawn reason
+ closestVehicleOptional.get().despawn(VehicleDespawnEvent.DespawnReason.API);
+ System.out.println("Closest vehicle despawned successfully.");
+ } else {
+ // Handle the case where no spawned vehicles are found for the target player
+ System.err.println("Target player does not have any spawned vehicles.");
+ }
+ }
+}
diff --git a/website example/src/main/java/tech/sbdevelopment/websiteExample/examples/GiveVehicle.java b/website example/src/main/java/tech/sbdevelopment/websiteExample/examples/GiveVehicle.java
new file mode 100644
index 0000000..6dc5390
--- /dev/null
+++ b/website example/src/main/java/tech/sbdevelopment/websiteExample/examples/GiveVehicle.java
@@ -0,0 +1,56 @@
+package tech.sbdevelopment.websiteExample.examples;
+
+import nl.sbdeveloper.vehiclesplus.api.VehiclesPlusAPI;
+import nl.sbdeveloper.vehiclesplus.api.garages.Garage;
+import nl.sbdeveloper.vehiclesplus.api.vehicles.impl.StorageVehicle;
+import org.bukkit.entity.Player;
+
+public class GiveVehicle {
+
+ /**
+ * Gives a vehicle to a specific garage.
+ * Attempts to create a vehicle of the specified type and add it to the provided garage.
+ *
+ * @param targetGarage The garage where the vehicle will be stored.
+ * @param vehicleType The type of vehicle to be created.
+ */
+ public void giveVehicleToGarage(Garage targetGarage, String vehicleType) {
+ // Attempt to create a new vehicle of the given type
+ StorageVehicle createdVehicle = VehiclesPlusAPI.createVehicle(vehicleType);
+
+ // If vehicle creation fails, log the error and exit
+ if (createdVehicle == null) {
+ System.err.println("Failed to create vehicle of type: " + vehicleType);
+ return; // Exit if the vehicle could not be created
+ }
+
+ // Add the created vehicle's UUID to the target garage
+ targetGarage.addVehicle(createdVehicle.getUuid());
+ System.out.println("Vehicle created and added to the garage successfully.");
+ }
+
+ /**
+ * Gives a vehicle to the player's default garage.
+ * Attempts to create a vehicle of the specified type and add it to the player's personal garage.
+ *
+ * @param player The player whose default garage will receive the vehicle.
+ * @param vehicleType The type of vehicle to be created.
+ */
+ public void giveVehicleToPlayerGarage(Player player, String vehicleType) {
+ // Attempt to create a new vehicle of the given type
+ StorageVehicle createdVehicle = VehiclesPlusAPI.createVehicle(vehicleType);
+
+ // Retrieve the player's personal garage (will create a new garage if none exists)
+ Garage playerGarage = VehiclesPlusAPI.getPersonalGarage(player);
+
+ // If vehicle creation fails, log the error and exit
+ if (createdVehicle == null) {
+ System.err.println("Failed to create vehicle of type: " + vehicleType);
+ return; // Exit if the vehicle could not be created
+ }
+
+ // Add the created vehicle's UUID to the player's personal garage
+ playerGarage.addVehicle(createdVehicle.getUuid());
+ System.out.println("Vehicle created and added to the player's personal garage successfully.");
+ }
+}
diff --git a/website example/src/main/resources/plugin.yml b/website example/src/main/resources/plugin.yml
new file mode 100644
index 0000000..08ada31
--- /dev/null
+++ b/website example/src/main/resources/plugin.yml
@@ -0,0 +1,4 @@
+name: websiteExample
+version: '1.0-SNAPSHOT'
+main: tech.sbdevelopment.websiteExample.WebsiteExample
+api-version: '1.21'