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
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:
You can use these fields to display kit choices in your own inventory menus, command outputs, or scoreboards before calling
loadPublicKit.
plugin.yml Setup
DeclarePerPlayerKit as a hard dependency so Paper guarantees it loads before your plugin:
plugin.yml
