Skip to main content

Auxiliary Libraries

We use several auxiliary libraries as dependencies for our main components.

We publish our libraries using JitPack!

JitPack.io is a package repository service that enables easy sharing and distribution of Java libraries by building source code from Git repositories on-demand.

The process to publish a new version consists of creating a new tag with the name as the component version and push it.

It's required to add this repository declaration to your project to use it:

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

MMO Core

MMOCore is a foundational component of the project, it is a library that provides and abstract implementation of network engine. It is used by the Login Server and the Game Server to send/receive data to/from clients, there are two (main) methods to cipher/decipher that should be implemented on the game server. The buffer handling is done at SelectorThread class.

We are using a non-blocking multiplexed single-threaded architecture for in/out plus a thread-pool to process receivable packets. DrHouse

<dependency>
<groupId>org.bitbucket.l2jserver</groupId>
<artifactId>l2j-server-mmocore</artifactId>
<version>2.6.5.0</version>
</dependency>

Discussion about Asynchronous I/O, Multi-threaded MMOCore and here

L2J Geo Driver

It's the default implementation of the Geodata Engine.

<dependency>
<groupId>org.bitbucket.l2jserver</groupId>
<artifactId>l2j-server-geo-driver</artifactId>
<version>2.6.5.0</version>
</dependency>

L2J Commons

It is a utility library that contains several classes that resolve a variate of problems with in the Login and Game server.

<dependency>
<groupId>org.bitbucket.l2jserver</groupId>
<artifactId>l2j-server-commons</artifactId>
<version>2.6.7.0</version>
</dependency>

UPnP Service

Universal Plug and Play (UPnP) is a set of networking protocols that enables devices in a local network to automatically discover and communicate with each other. It simplifies device connectivity and configuration. UPnP can also be used for port forwarding, which allows remote access to devices behind a router. With UPnP, devices can request the router to automatically create and manage port forwarding rules, eliminating the need for manual router configuration. This makes it easier for users to enable remote access to their devices without requiring extensive networking knowledge or complex setup procedures.

info

Enabled by default.

Connection Factory and Connection Pool

L2J Server uses plain JDBC (Java Database Connectivity), it can improve performance over higher-level frameworks like JPA (Java Persistence API) or other options because it provides direct and low-level access to the database, allowing for fine-grained control and optimization of SQL queries, data fetching strategies, and database-specific features.

L2J Server uses a connection pool to manage a pool of database connections, allowing the server to reuse and share connections to a database. It helps improve performance and scalability by reducing the overhead of establishing new database connections for each request.

By default, L2J Server uses HikariCP, a high-performance JDBC connection pool library for Java applications. HikariCP offers several features that make it a popular choice for connection pooling, including lightweight footprint, low latency, high throughput, and automatic connection management.

Blowfish Engine

The Blowfish algorithm is a symmetric block cipher that operates on blocks of data and uses a variable-length key. It was designed by Bruce Schneier in 1993 and is known for its flexibility and security.

The tryEncryptBlock and tryDecryptBlock methods perform error checking to ensure that the input and output buffers are of sufficient size. The encryptBlock and decryptBlock methods actually perform the encryption and decryption operations on the blocks of data using the Blowfish algorithm.

Utils

HexUtils

The HexUtils class is a utility class that provides methods for converting data into hexadecimal character representations and performing related operations, such as generating hex dumps. It includes functions for converting bytes and integers to their hexadecimal representations, generating hex dumps of byte arrays, and converting byte arrays to ASCII characters.

IPv4Filter

This class is an implementation of an IPv4 filter that allows or denies connections based on flood protection for specific IP addresses.

Rnd

Rnd that provides random number generation functionality. It offers different types of random number generators based on the specified RandomType.

The available types are:

  • SECURE: Uses SecureRandom for best random quality.
  • UNSECURE_ATOMIC: Uses java.util.Random for average random quality.
  • UNSECURE_THREAD_LOCAL: Uses ThreadLocalRandom for parallel access speed. Each thread has its own random instance.
  • UNSECURE_VOLATILE: Uses NonAtomicRandom for faster parallel access speed. It may generate the same seed for two threads.

Util

The class contains several static methods that offer different functionalities.

Here is a summary of the methods provided by the Util class:

  • isInternalHostname(String host): This method checks if a host name is internal by verifying if it is a site-local address or a loopback address.
  • printData(byte[] data, int len): This method generates a hexadecimal representation of a byte array. It takes the byte array and the length of data to be represented and returns the hexadecimal representation as a string.
  • printData(byte[] data): This method is a shorthand for printData(byte[] data, int len) and prints the entire byte array in hexadecimal format.
  • printData(ByteBuffer buf): This method represents the remaining bytes of a ByteBuffer as a hexadecimal string.
  • generateHex(int size): This method generates a random sequence of bytes of the specified size and returns it as a byte array.
  • getStackTrace(Throwable t): This method takes a Throwable object and returns its stack trace as a string.
  • replaceIllegalCharacters(String str): This method replaces most invalid characters in a string with an underscore character.
  • isValidFileName(String name): This method verifies if a file name is valid by creating a File object with the given name and checking if it can retrieve its canonical path without throwing an exception.
  • splitWords(String input): This method splits words in a string by inserting a space between a lowercase letter followed by an uppercase letter.
  • getNextClosestDateTime(DayOfWeek[] daysOfWeek, int hour, int min): This method calculates the next or same closest date from the specified days of the week at the specified hour and minute.
  • getNextClosestDateTime(List<DayOfWeek> daysOfWeek, int hour, int min): This is an overloaded version of the previous method that accepts a list of DayOfWeek objects instead of an array.
  • mapToFunction(Map<K, V> map): This method converts a map to a function, where the function returns the value associated with a given key in the map.
  • parseArg(String[] args, String arg, boolean hasArgValue): This method parses a given argument from the Java program arguments. It can retrieve either the argument itself or its value if specified.
  • randomPassword(int length): This method generates a random password of the specified length. The password contains a combination of lowercase characters, uppercase characters, and digits.