-
Notifications
You must be signed in to change notification settings - Fork 7
Shadeable Version
UltimateAdvancementAPI comes with a shadeable version. The shadeable version is a special version of the API that can be included in your project jar (usually this is done using a build tool like maven). Thus, you can package it alongside your project classes in a single jar and not install it as a separate plugin. However, this is not always the best solution.
You may use the shadeable version when:
- You don't need the commands present in the plugin version. Commands are not bundled in the shadeable version.
- Other plugins don't need to use UltimateAdvancementAPI as well. It is preferable to use the plugin version if multiple plugins will need the API. It is useless to have the same code repeated over and over.
- Dependencies of your plugin won't need to use the shaded API. Since the API will be shaded, the packages will become unclear due to relocation and someone could use the not-relocated ones instead. So it is prefereable to use the plugin version in this cases for cleareness.
To shade UltimateAdvancementAPI you need Maven or Gradle. This guide will use Maven, but the same can be done using Gradle.
Firstly, you need to add the following artifact as dependency instead of the standard ultimateadvancementapi
. Remember to add the official maven repository.
Warning
If you have JitPack declared in your repositories, make sure to declare the UltimateAdvancementAPI Maven repository before it! JitPack provides an empty jar instead of the correct one and this has already caused many issues in the past.
<repositories>
<repository>
<id>fren_gor</id>
<url>https://nexus.frengor.com/repository/public/</url>
</repository>
</repositories>
<dependency>
<groupId>com.frengor</groupId>
<artifactId>ultimateadvancementapi-shadeable</artifactId>
<version>2.4.3</version>
<scope>compile</scope>
</dependency>
Important
If you're using a Mojang mapped server (like Paper), you'll need to shade the Mojang mapped version of UltimateAdvancementAPI instead, which can be done simply adding the mojang-mapped
classifier:
<dependency>
<groupId>com.frengor</groupId>
<artifactId>ultimateadvancementapi-shadeable</artifactId>
<version>2.4.3</version>
<classifier>mojang-mapped</classifier>
<scope>compile</scope>
</dependency>
Then, you need to use the maven-shade-plugin to relocate the com.fren_gor.ultimateAdvancementAPI
package to something like *yourPackage*.libs.com.fren_gor.ultimateAdvancementAPI
. This avoids having duplicate classes in different jars.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>false</minimizeJar>
<relocations>
<relocation>
<pattern>com.fren_gor.ultimateAdvancementAPI</pattern>
<shadedPattern>*your package*.libs.com.fren_gor.ultimateAdvancementAPI</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
Note
This automatically adds to your jar the folder META-INF/.libs
with the licenses of UltimateAdvancementAPI's dependencies, so you don't need to worry about them.
Also, remember to include the files LICENSE
, LGPL
, and NOTICE
from UltimateAdvancementAPI in your final jar to follow the LGPL license terms. UltimateAdvancementAPI is licensed under LGPL. This means that you can use whatever license you want for your project, but you must include a copy of the LGPL, GPL, and NOTICE files in your final jar.
A tip is to add those files into the META-INF
directory, so they don't get mixed with the real license of your project.
Finally, you have to call the load()
, enable()
and disable()
methods.
public class MainClass extends JavaPlugin {
private AdvancementMain main;
private UltimateAdvancementAPI api;
@Override
public void onLoad() {
main = new AdvancementMain(this);
main.load();
// Rest of your code
}
@Override
public void onEnable() {
// Enable UltimateAdvancementAPI using file based database (SQLite)
// You can use other enable<DatabaseMode>() methods, like enableMySQL(), instead of the next line.
main.enableSQLite(new File(getDataFolder(), "database.db"));
// After the initialisation of AdvancementMain you can get an instance of the UltimateAdvancementAPI class
api = UltimateAdvancementAPI.getInstance(this);
// Rest of your code
}
@Override
public void onDisable() {
main.disable();
// Rest of your code
}
}
UltimateAdvancementAPI Wiki © 2021 fren_gor, EscanorTargaryen is licensed under CC BY-SA 4.0.
Except where otherwise noted, code snippets inside the wiki are licensed under The Unlicense.