-
Notifications
You must be signed in to change notification settings - Fork 38
Implementing Sponge
These docs may not be 100% correct yet. Please report any corrections needed.
Requires Sponge 5.1-SNAPSHOT
First you will need to add the repositories (you should already have Sponge) 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:1.2.4"
}
}
apply plugin: "com.github.johnrengelman.shadow"
repositories {
maven {
url = "https://repo.aikar.co/content/groups/aikar/"
}
maven {
url "http://repo.spongepowered.org/maven/"
}
}
dependencies {
compile "co.aikar:taskchain-sponge:<TASKCHAIN_VERSION>"
}
build.dependsOn shadowJar
Replace <TASKCHAIN_VERSION> with the latest version found on the TaskChain home page
First you will need to add the repositories (you should already have Sponge) 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>http://ci.emc.gs/nexus/content/groups/aikar/</url>
</repository>
<repository>
<id>sponge-maven-repo</id>
<name>Sponge maven repo</name>
<url>http://repo.spongepowered.org/maven</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>taskchain-sponge</artifactId>
<version>TASKCHAIN VERSION</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
</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
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:
http://ci.emc.gs/nexus/content/groups/aikar/co/aikar/taskchain-core/
http://ci.emc.gs/nexus/content/groups/aikar/co/aikar/taskchain-sponge/
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.SpongeTaskChainFactory;
import co.aikar.taskchain.TaskChainFactory;
import co.aikar.taskchain.TaskChain;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.game.state.GameStartedServerEvent;
@Plugin(id = "myplugin", name = "My Plugin", version = "1.0")
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);
}
@Listener
public void onServerStart(GameStartedServerEvent event)
taskChainFactory = SpongeTaskChainFactory.create(this);
}
}
That is it!
You may now use
MyPlugin.newChain()./* tasks */.execute();
Anywhere in your plugin!