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 inmanifest.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’smanifest.json:
Step 2: Import and Use
Just import the API classes directly:Quick Start
Adding Experience
XPSource.ENTITY_KILL- XP from killing entitiesXPSource.COMMAND- XP from admin commandsXPSource.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 aTamed_*role)XPSource.create("TAMEWORK")- XP mirrored from Alec’s Tamework companion feed / harvest / breeding (when that mod is installed; internal bridge only)
Player language
Set the RPG Leveling UI/message language (same codes aslanguages/MessagesLanguageMapping_<code>.json, e.g. english). Blank string clears the preference (server default from DefaultLanguage in RPGLevelingConfig.json).
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.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.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.Class reads (player)
Config Defaults Override API
Override RPG Leveling’s default config values from your mod. Admin-customized values are never overwritten. CallregisterConfigDefaults 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.Basic Usage
Updating a Previous Override
When you release a new version that changes your override value, pass the previous value(s) inalsoReplaces so the applier recognizes them as “not admin-customized”:
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/getPlayerLevelfor player level andgetMonsterLevel(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), callgetPlayerLevelInfo(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)
