Skip to main content
This page walks through a complete, working example of integrating the PerPlayerKit API into your own Paper plugin. You will see how to obtain the API singleton, fetch the list of configured public kits, and apply a kit to a player — all within a standard Bukkit event listener.

Full Working Example

The example below loads the first configured public kit for every player the moment they join the server. It covers event registration, API access, and safe list handling in one self-contained class.
ExamplePlugin.java
import dev.noah.perplayerkit.API;
import dev.noah.perplayerkit.PublicKit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.List;

public class ExamplePlugin extends JavaPlugin {

    @Override
    public void onEnable() {
        // Register event listener
        getServer().getPluginManager().registerEvents(this, this);
    }

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent e) {
        // Get the API instance
        API api = API.getInstance();

        // Get a list of all available public kits
        List<PublicKit> publicKits = api.getPublicKits();

        if (!publicKits.isEmpty()) {
            // Load the first public kit for the joining player
            api.loadPublicKit(e.getPlayer(), publicKits.get(0));
        }
    }
}

Step-by-Step Explanation

1

Obtain the API singleton

Call API.getInstance() to retrieve the shared API object. PerPlayerKit creates and holds this singleton during its own onEnable(), so as long as you have declared PerPlayerKit as a depend in your plugin.yml, the instance is always available by the time your code runs.
2

Fetch the list of public kits

Call api.getPublicKits() to get all public kits currently configured in PerPlayerKit. The method returns a copy of the internal list, so iterating or modifying the returned list will not affect PerPlayerKit’s own data.
3

Load a kit for a player

Pass an online Player and a PublicKit object to api.loadPublicKit(player, kit). PerPlayerKit applies the kit to the player’s inventory silently — no message is sent to the player or broadcast to the server.

The PublicKit Object

PublicKit is a simple data class with three public fields:
FieldTypeDescription
idStringUnique identifier for the kit, used internally by PerPlayerKit.
nameStringHuman-readable display name of the kit.
iconorg.bukkit.MaterialThe material used to represent the kit in GUIs.
You can use these fields to display kit choices in your own inventory menus, command outputs, or scoreboards before calling loadPublicKit.

plugin.yml Setup

Declare PerPlayerKit as a hard dependency so Paper guarantees it loads before your plugin:
plugin.yml
name: ExamplePlugin
version: 1.0
main: com.example.ExamplePlugin
depend:
  - PerPlayerKit
If PerPlayerKit is optional for your plugin — for example, you only use it when it happens to be installed — list it under softdepend instead of depend. Your plugin will then load regardless of whether PerPlayerKit is present. Remember to null-check API.getInstance() and guard your PerPlayerKit code paths accordingly.
Always check publicKits.isEmpty() before accessing the list by index. If no public kits have been configured in PerPlayerKit, getPublicKits() returns an empty list and calling publicKits.get(0) will throw an IndexOutOfBoundsException.