Archived
3
0
Fork 1

Compare commits

..

No commits in common. "c518e5cee26fb839e8d489aeb8c3429fb70d6139" and "5a6078a158b8056890d3041d2da989ee9022b92b" have entirely different histories.

2 changed files with 5 additions and 97 deletions

View file

@ -1,86 +0,0 @@
<!--
title: API
description: Api usage examples
published: false
date: 2024-12-28T20:39:33.295Z
tags: developers
editor: code
dateCreated: 2024-12-28T20:10:42.650Z
-->
<h1 class="toc-header" id="api-usage"> API Usage</h1>
<p>This guide explains how to integrate the new and improved VehiclesPlus API (v3) into your project.</p>
<h2 class="toc-header" id="adding-vehiclesplus-to-your-project"> Adding VehiclesPlus to Your Project</h2>
<p>To use the VehiclesPlus API in your plugin, follow these steps:</p>
<h3 class="toc-header" id="step-1-add-vehiclesplus-to-your-dependencies"> Step 1: Add VehiclesPlus to Your Dependencies</h3>
<p>Ensure VehiclesPlus is added as a dependency in your project. To always use the latest version, update your dependency configuration as shown below:</p>
<p>Maven (<code>pom.xml</code>):</p>
<pre class="prismjs line-numbers" v-pre="true"><code class="language-xml">&lt;repository&gt;
&lt;id&gt;sbdevelopment-repo&lt;/id&gt;
&lt;url&gt;https://repo.sbdevelopment.tech/releases&lt;/url&gt;
&lt;/repository&gt;
&lt;dependency&gt;
&lt;groupId&gt;tech.sbdevelopment&lt;/groupId&gt;
&lt;artifactId&gt;vehiclesplus&lt;/artifactId&gt;
&lt;version&gt;latest&lt;/version&gt;
&lt;/dependency&gt;
</code></pre>
<p>Gradle (<code>build.gradle</code>):</p>
<pre class="prismjs line-numbers" v-pre="true"><code class="language-gradle">repositories {
maven {
url 'https://repo.sbdevelopment.tech/releases'
}
}
dependencies {
implementation 'tech.sbdevelopment:vehiclesplus:latest'
}
</code></pre>
<blockquote>
<p><strong>Note</strong>: Using <code>latest</code> ensures that your project always fetches the most recent release, but it might cause issues if breaking changes are introduced. For more stability, consider specifying a specific version (e.g., <code>3.0.2</code>).</p>
</blockquote>
<h2 class="toc-header" id="example-adding-a-car-to-someones-garage"> Example: Adding a Car to Someone's Garage</h2>
<p>This example demonstrates how to add a vehicle to any garage:</p>
<pre class="prismjs line-numbers" v-pre="true"><code class="language-java">// Give car to garage
public void giveCar(Garage garage, String vehicleType) {
// Attempt to create a vehicle
StorageVehicle vehicle = VehiclesPlusAPI.createVehicle(vehicleType);
if (vehicle == null) {
System.err.println("Failed to create vehicle of type: " + vehicleType);
return; // Exit if the vehicle could not be created
}
// Add the vehicle's UUID to the garage
garage.addVehicle(vehicle.getUuid());
System.out.println("Vehicle created and added to the garage successfully.");
}
</code></pre>
<h2 class="toc-header" id="example-adding-a-vehicle-to-the-players-default-garage"> Example: Adding a Vehicle to the Player's Default Garage</h2>
<p>This example demonstrates how to add a vehicle to the player's default garage:</p>
<pre class="prismjs line-numbers" v-pre="true"><code class="language-java">// Give car to player's default garage
public void giveCar(Player player, String vehicleType) {
// Attempt to create a vehicle
StorageVehicle vehicle = VehiclesPlusAPI.createVehicle(vehicleType);
// Retrieve the player's default garage
Optional&lt;Garage&gt; optionalGarage = VehiclesPlusAPI.getGarage(player.getName());
if (vehicle == null) {
System.err.println("Failed to create vehicle of type: " + vehicleType);
return; // Exit if the vehicle could not be created
}
if (optionalGarage.isPresent()) {
Garage garage = optionalGarage.get();
garage.addVehicle(vehicle.getUuid());
System.out.println("Vehicle created and added to the garage successfully.");
} else {
System.err.println("Garage not found for player: " + player.getName());
// Optionally, you could create a new garage for the player here if the API allows it.
}
}
</code></pre>
<h2 class="toc-header" id="api-documentation"> API Documentation</h2>
<p>For additional details, examples, and advanced usage, refer to the official <a class="is-external-link" href="https://sbdevelopment.tech/vehiclesplus">VehiclesPlus API Docs</a>.</p>

View file

@ -2,7 +2,7 @@
title: API
description: Api usage examples
published: false
date: 2024-12-28T20:41:56.904Z
date: 2024-12-28T20:14:44.954Z
tags: developers
editor: markdown
dateCreated: 2024-12-28T20:10:42.650Z
@ -17,11 +17,9 @@ This guide explains how to integrate the new and improved VehiclesPlus API (v3)
To use the VehiclesPlus API in your plugin, follow these steps:
### Step 1: Add VehiclesPlus to Your Dependencies
Ensure VehiclesPlus is added as a dependency in your project. To always use the latest version, update your dependency configuration as shown below:
Maven (`pom.xml`):
```xml
<repository>
<id>sbdevelopment-repo</id>
@ -31,12 +29,11 @@ Maven (`pom.xml`):
<dependency>
<groupId>tech.sbdevelopment</groupId>
<artifactId>vehiclesplus</artifactId>
<version>latest</version>
<version>LATEST</version>
</dependency>
```
Gradle (`build.gradle`):
```gradle
repositories {
maven {
@ -45,16 +42,17 @@ repositories {
}
dependencies {
implementation 'tech.sbdevelopment:vehiclesplus:latest'
implementation 'tech.sbdevelopment:vehiclesplus:LATEST'
}
```
> **Note**: Using `LATEST` ensures that your project always fetches the most recent release, but it might cause issues if breaking changes are introduced. For more stability, consider specifying a specific version (e.g., `3.0.2`).
> **Note**: Using `latest` ensures that your project always fetches the most recent release, but it might cause issues if breaking changes are introduced. For more stability, consider specifying a specific version (e.g., `3.0.2`).
## Example: Adding a Car to Someone's Garage
This example demonstrates how to add a vehicle to any garage:
```java
// Give car to garage
public void giveCar(Garage garage, String vehicleType) {
@ -100,7 +98,3 @@ public void giveCar(Player player, String vehicleType) {
}
}
```
## API Documentation
For additional details and advanced usage refer to the official [VehiclesPlus Javadoc](https://sbdevelopment.tech/javadoc/vehiclesplus-v3/index.html).