-
Notifications
You must be signed in to change notification settings - Fork 40
Implementing Bukkit
First you will need to add the repositories (you should already have Spigot) and the dependency to your pom.xml You will also need to shade the library into your plugin jar.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<repositories>
<repository>
<id>aikar</id>
<url>https://repo.aikar.co/content/groups/aikar/</url>
</repository>
<repository>
<id>spigot</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>taskchain-bukkit</artifactId>
<version>[TASKCHAIN VERSION]</version> <!-- Replace this with the version from TaskChain -->
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
<relocations>
<relocation>
<pattern>co.aikar.taskchain</pattern>
<shadedPattern>[YOUR PLUGIN PACKAGE].taskchain</shadedPattern> <!-- Replace this -->
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Replace [TASKCHAIN VERSION]
with the latest version found on the TaskChain home page.
Replace [YOUR PLUGIN PACKAGE]
with a package to your plugin so that TaskChain is relocated to it.
First you will need to add the repositories (you should already have Spigot) and the dependency to your build.gradle. You will also need to shadow the library into your plugin jar.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.github.jengelman.gradle.plugins:shadow:2.0.2"
}
}
apply plugin: "com.github.johnrengelman.shadow"
repositories {
maven {
url = "https://repo.aikar.co/content/groups/aikar/"
}
maven {
url = "https://hub.spigotmc.org/nexus/content/groups/public/"
}
}
dependencies {
compileOnly "co.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT"
compile "co.aikar:taskchain-bukkit:[TASKCHAIN VERSION]" // Replace TASKCHAIN_VERSION
}
shadowJar {
relocate 'co.aikar.taskchain', '[YOUR PLUGIN PACKAGE].taskchain'
}
build.dependsOn shadowJar
Replace [TASKCHAIN VERSION]
with the latest version found on the TaskChain home page.
Replace [YOUR PLUGIN PACKAGE]
with a package to your plugin so that TaskChain is relocated to it.
Did you see my comment about getting off dinosaurs on the README? Yeah... that applies here too. Please use a modern build tool like Maven or Gradle!
But if you really do need Ant, you can find artfacts here:
https://repo.aikar.co/content/groups/aikar/co/aikar/taskchain-core/
https://repo.aikar.co/content/groups/aikar/co/aikar/taskchain-bukkit/
Download both of the same version, and include core and then bukkit in your build.
Once the Dependency is added, you need to create a factory and store a reference to it.
It is recommended to set up static helper methods to create chains, here is an example of integrating it into your plugin:
import co.aikar.taskchain.BukkitTaskChainFactory;
import co.aikar.taskchain.TaskChainFactory;
import co.aikar.taskchain.TaskChain;
import org.bukkit.plugin.java.JavaPlugin;
public class MyPlugin extends JavaPlugin {
private static TaskChainFactory taskChainFactory;
public static <T> TaskChain<T> newChain() {
return taskChainFactory.newChain();
}
public static <T> TaskChain<T> newSharedChain(String name) {
return taskChainFactory.newSharedChain(name);
}
@Override
public void onEnable() {
taskChainFactory = BukkitTaskChainFactory.create(this);
}
}
That is it!
You may now use
MyPlugin.newChain()./* tasks */.execute();
Anywhere in your plugin!