# java > Handles Java 11 development, L2J package structure, singleton patterns, and thread-safe coding conventions. Use when: Writing new classes, managers, handlers, or modifying existing Java code in the L2J codebase. - 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~java:20260202145225 --- --- name: java description: | Handles Java 11 development, L2J package structure, singleton patterns, and thread-safe coding conventions. Use when: Writing new classes, managers, handlers, or modifying existing Java code in the L2J codebase. allowed-tools: Read, Edit, Write, Glob, Grep, Bash, mcp__context7__resolve-library-id, mcp__context7__query-docs --- # Java Skill Java 11 development for the Tales of Aden L2J server. This codebase follows L2J conventions: underscore-prefixed private fields, singleton managers, handler interfaces, and intention-based AI patterns. All code targets Java 11—do not use features from newer versions. ## Quick Start ### Singleton Manager Pattern ```java public class YourManager { private static final Logger _log = Logger.getLogger(YourManager.class.getName()); private static class SingletonHolder { protected static final YourManager _instance = new YourManager(); } public static YourManager getInstance() { return SingletonHolder._instance; } private YourManager() { // initialization } } ``` ### Handler Implementation ```java public class YourHandler implements IAdminCommandHandler { private static final String[] ADMIN_COMMANDS = { "admin_your_command", "admin_your_other_command" }; @Override public boolean useAdminCommand(String command, Player activeChar) { if (command.startsWith("admin_your_command")) { // handle command } return true; } @Override public String[] getAdminCommandList() { return ADMIN_COMMANDS; } } ``` ## Key Concepts | Concept | Convention | Example | |---------|------------|---------| | Private fields | Underscore prefix | `_log`, `_actor`, `_thinking` | | Constants | SCREAMING_SNAKE | `AVOID_RADIUS`, `MAX_DELAY` | | Config keys | PascalCase | `Config.ENABLE_AIO_SYSTEM` | | Packages | lowercase | `net.sf.l2j.event.tvt` | | Entity classes | L2 prefix | `L2Summon`, `L2Skill` | ## Common Patterns ### Database Access with Try-With-Resources **When:** Any database operation ```java try (Connection con = ConnectionPool.getConnection(); PreparedStatement ps = con.prepareStatement("SELECT * FROM table WHERE id = ?")) { ps.setInt(1, id); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { // process results } } } catch (SQLException e) { _log.warning("Failed to load data: " + e.getMessage()); } ``` ### Scheduled Tasks **When:** Periodic operations (events, cleanup, updates) ```java private ScheduledFuture _task; public void startTask() { _task = ThreadPool.scheduleAtFixedRate(() -> { // periodic work }, 1000, 60000); // initial delay, period (ms) } public synchronized void stopTask() { if (_task != null) { _task.cancel(false); _task = null; } } ``` ### Thread-Safe State Flags **When:** AI or concurrent operations ```java private volatile boolean _thinking; @Override protected void onEvtThink() { if (_thinking || _actor.isCastingNow()) return; _thinking = true; try { // process AI logic } finally { _thinking = false; } } ``` ## See Also - [patterns](references/patterns.md) - Singleton, handler, AI patterns - [types](references/types.md) - Collections, concurrency, logging - [modules](references/modules.md) - Package organization, manager registration - [errors](references/errors.md) - Exception handling, database errors ## Related Skills - See the **ant** skill for build configuration - See the **mariadb** skill for database queries - See the **l2j-gameserver** skill for game server specifics - See the **ai-system** skill for AI implementation - See the **item-handlers** skill for item handler patterns - See the **pvp-events** skill for event manager patterns ## Documentation Resources > Fetch latest Java 11 documentation with Context7. **How to use Context7:** 1. Use `mcp__context7__resolve-library-id` to search for "java 11" 2. **Prefer website documentation** (IDs starting with `/websites/`) over source code repositories 3. Query with `mcp__context7__query-docs` using the resolved library ID **Recommended Queries:** - "java concurrency patterns" - "java try with resources" - "java logging best practices"