Skip to main content

Getting Started

On this page: How to import and prepare your project

Adding KTools as dependency

<repository>
<id>jitpack.io</id>
<url>https://jitpack.io/</url>
</repository>

<dependency>
<groupId>com.github.KPGTB</groupId>
<artifactId>KTools</artifactId>
<version>{VERSION}</version>
<scope>provided</scope>
</dependency>
note

Remember to replace {VERSION} to version of KTools that you want to use!

You also need to add KTools as dependency in your plugin.yml

plugin.yml
depend: [KTools]

Preparing plugin

After adding KTools as dependency, you can start cooding. First of all, you need to get ToolsObjectWrapper. To make it, in onEnable() crete new instance of ToolsInitializer. With that, you can create new instance of ToolsObjectWrapper.

public final class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
ToolsInitializer initializer = new ToolsInitializer(this);
ToolsObjectWrapper wrapper = new ToolsObjectWrapper(initializer);
}
}

Initializer creates also BukkitAudiences from AdventureAPI, so you need to handle it.

public final class MyPlugin extends JavaPlugin {
private BukkitAudiences adventure;
@Override
public void onEnable() {
ToolsInitializer initializer = new ToolsInitializer(this);
this.adventure = initializer.getAdventure();
ToolsObjectWrapper wrapper = new ToolsObjectWrapper(initializer);
}
@Override
public void onDisable() {
if (adventure != null) adventure.close();
}
}
tip

ToolsObjectWrapper is an object that will be accessed via constructors in commands, listeners, items etc. You can extend it like you want.