Skip to content

Developer API

Jan Kluka edited this page May 22, 2026 · 31 revisions

Developer API

The X-Prison public API lives in a dedicated project: X-PrisonAPI on GitHub


Adding X-PrisonAPI as a Dependency

Add the API artifact to your plugin's build tool. The API is published to the Drawethree Maven repository.

Maven:

<repository>
    <id>drawethree-repo</id>
    <url>https://repo.drawethree.dev/releases</url>
</repository>

<dependency>
    <groupId>dev.drawethree</groupId>
    <artifactId>X-PrisonAPI</artifactId>
    <version>LATEST</version>
    <scope>provided</scope>
</dependency>

Gradle (Kotlin DSL):

repositories {
    maven("https://repo.drawethree.dev/releases")
}

dependencies {
    compileOnly("dev.drawethree:X-PrisonAPI:LATEST")
}

Declare X-Prison as a dependency in your plugin.yml:

depend: [X-Prison]
# or if optional:
softdepend: [X-Prison]

Accessing the API

import dev.drawethree.xprison.api.XPrisonAPI;

XPrisonAPI api = XPrison.getInstance().getAPI();

Each module exposes its own sub-API through the main API instance. For example:

api.getEnchantsAPI()     // Enchant system
api.getRanksAPI()        // Ranks
api.getPrestigesAPI()    // Prestiges
api.getRebirthsAPI()     // Rebirths
api.getBlocksAPI()       // Block tracking
api.getCurrenciesAPI()   // Currency balances
api.getGangsAPI()        // Gangs

Registering a Custom Enchant

Custom enchants must extend XPrisonEnchantment and be registered via the API. They are driven by JSON configuration files (placed in plugins/X-Prison/enchants/) just like built-in enchants.

@Override
public void onEnable() {
    XPrisonAPI api = XPrison.getInstance().getAPI();
    MyCustomEnchant enchant = new MyCustomEnchant();
    api.getEnchantsAPI().registerEnchant(enchant);
}

@Override
public void onDisable() {
    api.getEnchantsAPI().unregisterEnchant(enchant);
}

Your enchant class overrides three methods:

Method Called when
onEquip(Player, ItemStack, int) Player picks up or equips the pickaxe
onUnequip(Player, ItemStack, int) Player removes or drops the pickaxe
onBlockBreak(BlockBreakEvent, int) A block is broken in a mine with this enchant
reload() The plugin is reloaded — re-read your config values here

Events

Listen to X-Prison events like any Bukkit event. All events are in the dev.drawethree.xprison.api package hierarchy.

Enchant Events

Event Cancellable Description
XPrisonEnchantPrestigeEvent Yes Fired when a player prestige an enchant. Exposes getOldPrestige(), getNewPrestige() (mutable), and the enchantment. Cancelling prevents the prestige.

Progression Events

Event Cancellable Description
XPrisonRankupEvent Yes Player ranks up
XPrisonPrestigeEvent Yes Player prestiges
XPrisonRebirthEvent Yes Player rebirths

Block Events

Event Cancellable Description
XPrisonBlockBreakEvent No Fired for every block broken by an X-Prison pickaxe

PrestigeableEnchant Interface

Enchants that support prestiging implement dev.drawethree.xprison.api.enchants.model.PrestigeableEnchant:

public interface PrestigeableEnchant {
    boolean isPrestigeEnabled();
    int getMaxPrestige();
    double getMultiplierPerPrestige();
    long getRequiredActivations(int currentPrestige);
}

Use this to check whether an enchant supports prestiging and read its configuration at runtime.


Notes

  • The API jar is provided scope — do not shade it into your plugin.
  • Check the X-PrisonAPI GitHub repository for the most up-to-date interface documentation and example addons.
  • For questions about the API, open a ticket in the Discord server.

XPrison Logo

General

Modules

Default Configs

Enchant Configs — Passive

Enchant Configs — Currency Rewards

Enchant Configs — Key & Item Rewards

Enchant Configs — Area of Effect

Enchant Configs — Multipliers

Enchant Configs — Templates

Enchant Configs — Addons

Addons

Support

For Developers

Others

Clone this wiki locally