Skip to main content

RPG Leveling API

API for external mods to interact with the RPG Leveling system. Mod authors are welcome to integrate with RPG Leveling - use this API to grant XP, listen for level-ups, read player level, override config defaults, and more. See Share XP with teammates for an example (PartyPro); dependency setup and full reference are below. Simple integration! Import the API classes directly. Just declare the dependency in manifest.json and the plugin must be installed on the server or same mods folder.

Adding as Dependency

Step 1: Declare Dependency in manifest.json

Add to your plugin’s manifest.json:
Or if you require it:

Step 2: Import and Use

Just import the API classes directly:

Quick Start

Adding Experience

Built-in Sources:
  • XPSource.ENTITY_KILL - XP from killing entities
  • XPSource.COMMAND - XP from admin commands
  • XPSource.BLOCK_BREAK - XP from breaking blocks (mining/woodcutting)
  • XPSource.HARVEST - XP from harvesting crops (F key / sickle)
  • XPSource.TAME - XP from taming creatures (NPC becomes a Tamed_* role)
  • XPSource.create("TAMEWORK") - XP mirrored from Alec’s Tamework companion feed / harvest / breeding (when that mod is installed; internal bridge only)
Create Custom Sources:

Player language

Set the RPG Leveling UI/message language (same codes as languages/MessagesLanguageMapping_<code>.json, e.g. english). Blank string clears the preference (server default from DefaultLanguage in RPGLevelingConfig.json).
Returns false if the plugin/registry is unavailable, the player was not found, or the language code is non-empty but no bundle is loaded for it.

Experience Gained Events

Modify or cancel XP before it’s awarded.

All Available Properties

XPSource Properties

EntityKillContext Properties (for ENTITY_KILL only)

HarvestContext Properties (for HARVEST only)

TameContext Properties (for TAME only)

Example - Entity Kill

Example - Custom Source

Level Up Events

React when players level up.
Available Methods:

Getting Player Information

When you only have a UUID (e.g. from a command or async context), use the UUID overload. It uses Holder only and may return incorrect data when Holder is null.
When you have a PlayerRef and Store (e.g. in a system tick or GUI), use the two-arg overload for correct level/XP. Store is required.

Common Use Cases

Party XP Sharing

Quest Rewards

Level-Based Actions

API Methods Reference

Availability & Version

Listener Management

Level reads (player and monster)

Use the API for all level reads so behavior is consistent across the plugin and external mods.

Getting Player Class Information

Read the player’s selected class, tier, and all class progress.
When you have a PlayerRef, entity Ref, and Store (e.g. in a system tick or GUI), use the three-arg overload for correct data:
PlayerClassInfo Properties:

Class reads (player)

Config Defaults Override API

Override RPG Leveling’s default config values from your mod. Admin-customized values are never overwritten. Call registerConfigDefaults in your plugin’s setup() method. RPG Leveling applies overrides in its start() phase (after all mods have registered).
Config default overrides are startup-only - they are not re-applied on /lvl reload.
Only one mod can override a given field. If two mods both try to set MaxLevel, only the first to register wins - the second is silently ignored (a warning is logged). There is no merging or conflict resolution beyond first-come-first-served. Prefer adding content via array appends (e.g. new instances, zones, rewards) rather than replacing hard-coded scalar values - arrays compose safely across multiple mods, while scalar overrides do not. Only override global values like MaxLevel, RateExp, or DifficultyPreset if your mod absolutely requires it.

Basic Usage

How it works: when the server starts, RPG Leveling reads the on-disk config and its bundled default. If the on-disk value matches the bundled default (meaning the admin hasn’t touched it), the override is applied. If the admin has customized the value, the override is skipped.

Updating a Previous Override

When you release a new version that changes your override value, pass the previous value(s) in alsoReplaces so the applier recognizes them as “not admin-customized”:
Without alsoReplaces, the applier would see 155 on disk, compare it to the bundled default 100, find a mismatch, and skip it (thinking an admin changed it). With alsoReplaces(155), it knows 155 was a previous mod default and migrates it to 200.

Appending to Arrays

Add elements to JSON arrays (e.g. new dungeon instances). The element is only appended if no existing element has the same ID:

Multiple Config Files

Chain overrides for multiple config files in a single call:

Supported Config Files

Any RPG Leveling config file can be targeted:

Behavior Summary

Conflict Resolution

  • Scalar fields: first mod to register for a (configFile, jsonPath) wins. The second mod’s registration is rejected and a warning is logged at startup.
  • Array appends: multiple mods can append different elements. If two mods append an element with the same ID, the first one stays (duplicate skipped at apply time).
  • Startup log: all registered overrides are listed with source mod IDs.

Static Methods

Notes

  • All methods are thread-safe
  • Level reads: Use getPlayerLevelInfo / getPlayerLevel for player level and getMonsterLevel(store, npcRef) for monster level so behavior is consistent everywhere (plugin and external mods use the same API). When you have an entity Store (e.g. in systems or GUI), call getPlayerLevelInfo(playerRef, store) - store is required for correct data when Holder is null.
  • XP amounts must be positive
  • Players must be online to receive XP
  • Level ups are handled automatically
  • Events fire in registration order
  • Handler errors are logged but don’t stop other handlers
  • API instance is automatically refreshed on plugin reload
  • Config default overrides are startup-only (not re-applied on /lvl reload)