Overview
Handlers are specialized scripts that extend core game functionality. Unlike quests and AI scripts, handlers implement specific interfaces and are automatically registered with the HandlerManager.Handler Types
L2J Mobius supports multiple handler categories:Item Handlers
Control item usage behavior (potions, scrolls, shots)
Admin Commands
GM commands for server administration
Voiced Commands
Player commands (
.menu, .online, etc.)Effect Handlers
Skill effect implementations
Target Handlers
Skill targeting logic
User Commands
Built-in user commands (
/loc, /time)Item Handlers
Item handlers control what happens when players use items.Structure
handlers/itemhandlers/SoulShots.java
Real Example: Soul Shots
handlers/itemhandlers/SoulShots.java (lines 39-114)
Simple Item Handler Example
Admin Command Handlers
Admin commands provide GM tools for server management.Structure
Real Example: Admin Spawn
FromAdminSpawn.java:
handlers/admincommandhandlers/AdminSpawn.java (lines 391-471)
Simple Admin Command
Voiced Command Handlers
Voiced commands are player-accessible commands starting with.
Structure
Effect Handlers
Effect handlers define skill effect behavior.Structure
Handler Registration
Handlers are automatically discovered and registered if placed in the correct package.Master Handler Pattern
Some handler types use a master handler class:Handler Configuration
Item Template Configuration
Link items to handlers indata/stats/items/*.xml:
Skill Configuration
Link skills to effect handlers:Common Handler Patterns
Validation Pattern
Command Parsing Pattern
handlers/admincommandhandlers/AdminSpawn.java (lines 369-389)
Best Practices
Error Handling
Error Handling
Always validate input and handle exceptions gracefully:
Return Values
Return Values
Return
true only if the handler successfully completed:- Item handlers:
trueif item was consumed/used - Command handlers:
trueif command was handled
Null Safety
Null Safety
Check for null before accessing objects:
Handler Types Reference
| Package | Interface | Purpose |
|---|---|---|
itemhandlers/ | IItemHandler | Item usage |
admincommandhandlers/ | IAdminCommandHandler | GM commands |
voicedcommandhandlers/ | IVoicedCommandHandler | Player commands |
effecthandlers/ | AbstractEffect | Skill effects |
targethandlers/ | ITargetTypeHandler | Skill targeting |
usercommandhandlers/ | IUserCommandHandler | User commands |
chathandlers/ | IChatHandler | Chat commands |
punishmenthandlers/ | IPunishmentHandler | Punishment types |
bypasshandlers/ | IBypassHandler | HTML bypass |
Next Steps
Quest Scripts
Return to quest scripting guide
AI Scripts
Return to AI scripting guide