API

Please keep in mind that this wiki only shows a limited selection of methods, functions and possibilites.

For further questions regarding the development of addons, methods, or just general questions about what is possible, ask us on our discord server. Do read the entire page here though.


Using the API

Step 1:

Create a /libs folder in your project, and drag and drop the Vehicles jar into the folder.

Step 2:

Add the following to your pom.xml if you are using Maven:

<dependency>
  <groupId>Vehicles</groupId>
  <artifactId>Vehicles</artifactId>
  <scope>system</scope>
  <version>1.0</version>
  <systemPath>${pom.basedir}/src/main/java/<path>/<to>/<folder>/libs/Vehicles.jar</systemPath>
</dependency>

Depending on how you called your Vehicles.jar, you may also need to change that part in the systemPath.

Step 3:

You can now use the Vehicles API. Don't forget to add Vehicles as a dependency to your plugin.yml


Limitations of the API

No custom Vehicles

As our FAQ already hinted towards, you can't create your own Vehicles with this plugin. Not even using the API.

No automatic Vehicle movement

You can't force Vehicles to follow a specific path (eg: like TrainCarts).

Want something added?

Tell us on our discord and the developer can see what is possible. Don't ask about new Vehicles though =).

Movement tracking is resource intensive

Default MoveEvents from Bukkit and other checks don't work, as only the armorstand moves. ProtocolLib offers a VehicleSteerPacket, which can register the movement.


Available Events

VehicleEnterEvent

This event gets fired when a player right clicks a Vehicle to mount it. You can not manually fire this event.

Methods

VehicleExitEvent

This event gets fired when a player tries to dismount a Vehicle. You can not manually fire this event.

Methods

VehiclePickupEvent

This event gets fired when a player tries to pick a Vehicle up. You can not manually fire this event.

Methods

VehiclePlaceEvent

This event gets fire when a player tries to place a Vehicle. You can not manually fire this event.

Methods

VehicleSpawnedEvent

This event gets fired AFTER a Vehicle has been spawned and AFTER the VehiclePlaceEvent has been. You can not manually fire this event.

Methods

VehicleInventoryOpenEvent

This event gets fired when a player is trying to open the trunk of a Vehicle. You can not manually fire this event.

Methods

VehicleCollideEvent

This event gets fired whenever a Vehicle encounters a block that it can not drive up. You can not manually fire this event.

Methods

General API Methods

The following code selections are based off of the VehiclesMain instance:

Get current mounted Vehicle from Player

Generate subtype from String

Get all current mounted Vehicles as a Hashmap

Get other config options:

Theres a bit more...

Ask us on the Discord and we can surely help you find a solution you need!


The following code selections are generalised and should give insight on what info you can get/set from Vehicles. Please keep in mind, that you call these methods with a Vehicle object.

Get the mainstand of a Vehicle

Edit Vehicle stats

Get current Players on Vehicle

Get Type / Subtype of Vehicle


Code Examples

Spawn a new Vehicle

Spawning is done via the VehicleManager. Each Vehicle has its own Manager.

Instant Mount a Player on a Vehicle

Due to Vehicles having a 20L delay when all interaction is blocked with it, you need to delay the mounting as well. Mounting only works by firing a playerInteractAtEntityEvent manually.

Last updated