addXp

fun addXp(amount: Long)

Adds experience points to the player's total XP.

This method provides a safe way to modify player XP with automatic dirty tracking. Only modifies the XP and dirty flag if the amount is non-zero, avoiding unnecessary database operations.

Usage Examples:

playerData.addXp(100L)  // Adds 100 XP
playerData.addXp(-50L) // Removes 50 XP
playerData.addXp(0L) // No change, no dirty flag set

Side Effects:

  • Updates the xp property

  • Sets isDirty to true if amount is non-zero

  • May trigger level-up calculations in other systems

Parameters

amount

The amount of XP to add (can be negative to subtract)