-
Notifications
You must be signed in to change notification settings - Fork 2
Home
This step-by-step tutorial explains how you can make your plugin hook into PetDragon.
In order to build against PetDragon, you have to add it as a local dependency. To do so, you have to build against the jar as released on Spigot.
Either add this jar to your local Maven repository or use a system dependency to link to the file itself. For both, use the following (along with a systemPath
for the second option):
<dependencies>
<dependency>
<groupId>com.ericdebouwer</groupId>
<artifactId>PetDragon</artifactId>
<version>1.5.2</version> <!-- replace with the latest version -->
</dependency>
</dependencies>
Add "PetDragon" as a (soft)depend in your plugin.yml
. See the snippet below for an example. If you set it as a softdepend, don't forget to actually check if the plugin is present before accessing the API.
name: ExamplePlugin
version: 1.0
main: your.main.path.here
depend: [PetDragon]
Once everything is setup, you can start using the API. All available methods can be found under the PetDragonAPI
class. You can for example spawn a PetDragon for a player, in quite a similar fashion to how you spawn entities in the Spigot API. In the example below I spawn a dragon, and rename it to "Hello World" before it is spawned in.
Player player = ...
EnderDragon dragon = PetDragonAPI.getInstance().spawnDragon(player.getLocation(), player.getUniqueId(), (dragon) -> {
dragon.setCustomName("Hello World");
dragon.setCustomNameVisible(true);
});
If you want to know how to use a method, you can look at the source code hosted here. If you have any question, you can always ask them here or on Spigot.