-
Notifications
You must be signed in to change notification settings - Fork 58
Developer API
The X-Prison public API lives in a dedicated project: X-PrisonAPI on GitHub
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]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.getCurrencyApi() // Currency balances
api.getGangsAPI() // Gangs
api.getMultipliersApi() // Global, player, and rank multipliersCustom 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 |
Listen to X-Prison events like any Bukkit event. All events are in the dev.drawethree.xprison.api package hierarchy.
| Event | Cancellable | Description |
|---|---|---|
XPrisonEnchantPrestigeEvent |
Yes | Fired when a player prestige an enchant. Exposes getOldPrestige(), getNewPrestige() (mutable), and the enchantment. Cancelling prevents the prestige. |
| Event | Cancellable | Description |
|---|---|---|
XPrisonRankupEvent |
Yes | Player ranks up |
XPrisonPrestigeEvent |
Yes | Player prestiges |
XPrisonRebirthEvent |
Yes | Player rebirths |
| Event | Cancellable | Description |
|---|---|---|
XPrisonBlockBreakEvent |
No | Fired for every block broken by an X-Prison pickaxe |
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.
- The API jar is
providedscope — 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.
- Currencies
- Ranks
- Prestiges
- Rebirths
- Mines
- AutoSell
- AutoMiner
- Enchants
- Pickaxe Levels
- Pickaxe Skins
- Gangs
- Multipliers
- Blocks
- Bombs
- History
- Mining Stats
- Nicknames
- Battle Pass
- Quests
- Daily Rewards
- config.yml
- autominer.yml
- autosell.yml
- block-rewards.yml
- enchants.yml
- currencies.yml
- multipliers.yml
- ranks.yml
- prestiges.yml
- pickaxe-levels.yml
- pickaxe-skins.yml
- gangs.yml
- mines.yml
- bombs.yml
- blocks.yml
- history.yml
- mining-stats.yml
- rebirths.yml
- battlepass.yml
- quests.yml
- dailyrewards.yml
- efficiency.json
- fortune.json
- unbreaking.json
- haste.json
- speed.json
- fly.json
- nightvision.json
- jumpboost.json
- autosell.json
- tokenfinder.json
- gemfinder.json
- salary.json
- charity.json
- blessing.json
- gangvaluefinder.json
- prestigefinder.json
