# l2j-gameserver > Implements L2J gameserver architecture, networking, and player interactions for the Tales of Aden private server. Use when: writing game logic, adding handlers, creating packets, or modifying core server behavior - Author: valeriybaranyshyn-pixel - Repository: valeriybaranyshyn-pixel/Tales-of-Aden - Version: 20260202145225 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-06 - Source: https://github.com/valeriybaranyshyn-pixel/Tales-of-Aden - Web: https://mule.run/skillshub/@@valeriybaranyshyn-pixel/Tales-of-Aden~l2j-gameserver:20260202145225 --- --- name: l2j-gameserver description: | Implements L2J gameserver architecture, networking, and player interactions for the Tales of Aden private server. Use when: writing game logic, adding handlers, creating packets, or modifying core server behavior allowed-tools: Read, Edit, Write, Glob, Grep, Bash --- # L2J GameServer Skill The GameServer is the core gameplay engine handling all player actions, NPCs, combat, events, and world state. It uses a layered architecture: NIO network → packet handlers → game logic handlers → entity model → database. ## Quick Start ### Register a New Skill Handler ```java // 1. Create handler implementing ISkillHandler public class MySkill implements ISkillHandler { private static final L2SkillType[] SKILL_IDS = { L2SkillType.MY_TYPE }; @Override public void useSkill(Creature activeChar, L2Skill skill, L2Object[] targets) { for (L2Object obj : targets) { if (!(obj instanceof Creature)) continue; Creature target = (Creature) obj; // Apply skill logic int damage = (int) Formulas.calcPhysDam(activeChar, target, skill, shld, crit, ss); target.reduceCurrentHp(damage, activeChar, skill); } } @Override public L2SkillType[] getSkillIds() { return SKILL_IDS; } } // 2. Register in SkillHandler constructor registerSkillHandler(new MySkill()); ``` ### Create a Voiced Command ```java // Implement IVoicedCommandHandler in handler/voicedcommandhandlers/ public class MyCommand implements IVoicedCommandHandler { private static final String[] COMMANDS = { "mycommand" }; @Override public boolean useVoicedCommand(String command, Player activeChar, String target) { activeChar.sendMessage("Command executed!"); return true; } @Override public String[] getVoicedCommandList() { return COMMANDS; } } // Register conditionally in VoicedCommandHandler if (Config.ENABLE_MY_COMMAND) { registerHandler(new MyCommand()); } ``` ## Key Concepts | Concept | Usage | Example | |---------|-------|---------| | Singleton Manager | Thread-safe lazy init via inner class | `SingletonHolder._instance` | | Handler Pattern | Type-dispatch via ordinal/hashCode | `_datatable.put(type.ordinal(), handler)` | | Packet Template | read() → readImpl(), run() → runImpl() | `L2GameClientPacket` | | AI State Machine | Intention → Event → State change | `setIntention(ATTACK)` → `onEvtThink()` | | Skill Hash | Fast lookup: `skillId * 256 + level` | `SkillTable.getSkillHashCode()` | ## Common Patterns ### Schedule a Task **When:** Delayed or periodic execution needed ```java // One-time delayed task ThreadPool.schedule(() -> { player.sendMessage("5 seconds passed!"); }, 5000); // Periodic task ThreadPool.scheduleAtFixedRate(() -> { broadcastStatus(); }, 0, 60000); // Every 60 seconds ``` ### Send Packet to Player **When:** Client needs visual/data update ```java // Direct send player.sendPacket(new MagicSkillUse(activeChar, target, skillId, level, hitTime, reuseDelay)); // Broadcast to nearby activeChar.broadcastPacket(new Attack(activeChar, target, damage, miss, crit, shld)); ``` ## See Also - [patterns](references/patterns.md) - Singleton, handler, and packet patterns - [workflows](references/workflows.md) - Adding features, debugging, testing ## Related Skills When working with L2J GameServer: - See the **java** skill for Java 11 conventions and L2J coding patterns - See the **ant** skill for building the server JAR - See the **mariadb** skill for database schema and queries - See the **ai-system** skill for L2SummonAI and creature AI implementation - See the **packet-protocol** skill for L2 binary protocol details - See the **skill-system** skill for L2Skill data model and effects - See the **pvp-events** skill for TvT, CTF, DeathMatch implementation