L2J Server on Debian

L2J is a complex piece of software engineering, it's divided in three main components, login server, game server and datapack.

  • Install OpenJDK

    L2J is built using Java SE, to build you need Java JDK as well.

    $ mkdir -p /opt/l2j && cd /opt/l2j
    $ wget https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz
    $ tar zxvf openjdk-11.0.2_linux-x64_bin.tar.gz -C /usr/lib/jvm
    $ update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-11.0.2/bin/java 1102
    $ update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-11.0.2/bin/javac 1102
    $ java -version
    openjdk version ”11.0.2” 2019-01-15
    OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
    OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
    
    # Optional
    $ rm -f openjdk-11.0.2_linux-x64_bin.tar.gz
    We recommend OpenJDK due to licencing changes from Oracle.
    We use OpenJDK 11 since it is the lastest stable LTS.
  • Install Git

    L2J uses Git as version control system on BitBucket, use it to get the latest versions.

    $ apt-get install git
    We recommend getting the source code directly from our public repositories.
  • Install Maven

    L2J uses Maven to build the components from the source code.

    $ wget https://www-us.apache.org/dist/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz -P /tmp
    $ tar xf /tmp/apache-maven-*.tar.gz -C /opt
    $ ln -s /opt/apache-maven-3.6.1 /opt/maven
    $ vi /etc/profile.d/maven.sh
    # Paste
    export JAVA_HOME=/usr/lib/jvm/jdk-11.0.2/
    export M2_HOME=/opt/maven
    export MAVEN_HOME=/opt/maven
    export PATH=${M2_HOME}/bin:${PATH}
    $ chmod +x /etc/profile.d/maven.sh
    $ source /etc/profile.d/maven.sh
  • Install the Database Server

    Get latest version from here.

    # Create MariaDB.list file and add the following content:
    $ vi /etc/apt/sources.list.d/MariaDB.list
    # MariaDB 10.4 repository list - created 2019-08-12 01:57 UTC
    # http://downloads.mariadb.org/mariadb/repositories/
    deb [arch=amd64] http://mirror.hosting90.cz/mariadb/repo/10.4/debian buster main
    deb-src http://mirror.hosting90.cz/mariadb/repo/10.4/debian buster main
    $ apt update
    $ apt install mariadb-server
  • Get the Source Code

    Our official repositores are the ones listed bellow.

    $ mkdir -p /opt/l2j/git && cd /opt/l2j/git
    $ git clone https://bitbucket.org/l2jserver/l2j-server-login.git
    $ git clone https://bitbucket.org/l2jserver/l2j-server-game.git
    $ git clone https://bitbucket.org/l2jserver/l2j-server-datapack.git
  • Build the Server from Source Code

    Our official repositores are the ones listed bellow.

    $ cd /opt/l2j/git/l2j-server-login && mvn install
    $ cd /opt/l2j/git/l2j-server-game && mvn install
    $ cd /opt/l2j/git/l2j-server-datapack && mvn install
  • Deploy the Server

    The deployment process at the moment is simply unzipping the built files.

    $ mkdir -p /opt/l2j/server/login
    $ unzip /opt/l2j/git/l2j-server-login/target/l2jlogin.zip -d /opt/l2j/server/login
    $ mkdir -p /opt/l2j/server/game
    $ unzip /opt/l2j/git/l2j-server-game/target/l2j-server-game-2.6.1.0-SNAPSHOT.zip -d /opt/l2j/server/game
    $ unzip /opt/l2j/git/l2j-server-datapack/target/l2j-server-datapack-2.6.1.0-SNAPSHOT.zip -d /opt/l2j/server/game
  • Get L2J CLI and Install the Database

    L2J CLI is a tool developed by Zoey76 that allows us to implement automated deployments and initial configurations.

    $ mkdir -p /opt/l2j/cli && cd /opt/l2j/cli
    $ wget https://github.com/L2J/l2j-server-cli/releases/download/1.0.0-alpha1/l2jcli-1.0.0.zip -P /tmp
    $ unzip /opt/l2j/l2jcli.zip -d /opt/l2j/cli
    $ chmod 755 l2jcli.sh
    $ ./l2jcli.sh
    > db install -l /opt/l2j/server/login/sql -u l2j -pw l2jserver2019 -m FULL -t LOGIN
    > db install -l /opt/l2j/server/game/sql -u l2j -pw l2jserver2019 -m FULL -t GAME
    > quit
  • Initial Configuration

    You need to give certain permissions for the server to run properly.

    $ cd /opt/l2j/server/login && mkdir -p log
    $ chmod 755 LoginServer_loop.sh
    $ chmod 755 startLoginServer.sh
    $ chmod 755 startSQLAccountManager.sh
    $ cd /opt/l2j/server/game && mkdir -p log
    $ chmod 755 GameServer_loop.sh
    $ chmod 755 startGameServer.sh
  • Create Administrator Account

    Use the L2J CLI to create an administrator account, 8 is the maximum account level (master).

    $ cd /opt/l2j/cli
    $ ./l2jcli.sh
    > account create -u Zoey76 -p -a 8
    > quit
  • Start the Server

    To start the server you need to run two scripts.

    $ cd /opt/l2j/server/login
    $ ./startLoginServer.sh
    $ cd /opt/l2j/server/game
    $ ./startGameServer.sh
  • Connect to the Server

    In order to connect to the server you have the following options:

    HOSTS file

    Edit C:\Windows\System32\drivers\etc\hosts and add this line:

    127.0.0.1 l2authd.lineage2.com

    BAT file

    Create a .bat file with the following content:

    @start l2.bin IP=127.0.0.1

    Custom exe

    Here is a C++ Win32 exe example:

    #define _WIN32_WINNT _WIN32_WINNT_WINXP
    #define NOMINMAX
    #include <windows.h>
    #include <cstdlib>
    
    // Start L2 as .bin with IP as parameter.
    // You can use IP or DNS as IP parameter.
    // You could include other parameters.
    // You can change the path to the .bin file to avoid including the L2.exe inside the System folder.
    // Author: Zoey76
    int _stdcall wWinMain(HINSTANCE hInst, HINSTANCE prevInst, LPWSTR szCmdLine, int nCmdShow)
    {
    	ShellExecute(0, L"open", L"cmd.exe", L"/C start l2.bin IP=127.0.0.1", 0, SW_HIDE);
    }

    More information here.