Skip to content

Extensions

etkmlm edited this page Oct 4, 2024 · 4 revisions

Extensions API

Welcome to the developers' area! If you want to make an extension for the launcher, you're at the right place.

Setting Up

The launcher written in Java, so you have to develop your extension in Java.

1 - Creating a Maven Project

I'm using IntelliJ Idea to create the project. You can use anything you want, the point is the same.

Steps

  1. Fill the required personal fields. (name, location, groupId, and artifactId)
  2. Select the build system as Maven.
  3. Select the JDK. (17 recommended)
  4. Create.

2 - Including The Launcher Into The Game

Now, we need to add the Core Launcher JAR file into the project.

  1. Download the latest file from here.

  1. Open the project structure panel from File > Project Structure.

  1. Navigate to the Libraries and click on the + button. Select Java and your JAR file. Click OK button.

  2. It should see like this:

  1. Click 'OK'

3 - Introducing Yourself To The Launcher

We are in the last step before we start developing.

  1. Create a file named info.properties into the resources folder. An example file:
name=Test Extension
mainPackage=com.laeben
mainClass=Main
description=Welcome to the tutorial :)
author=etkmlm
version=1.0
target=>=1.16
  1. It should see like this:

  1. If you want, you can add an PNG icon file to the same folder named icon.png on size 128x128.

  1. Go to the Main class or create one that exactly with the name you wrote it in the properties file.

    • You can delete the main method, we don't need it.
  2. Create a method named init with a parameter for type Extension

This is the place where your adventure will begin. You can start to developing your extension now.

4 - Publishing Your Extension

You can pack your project into a JAR file. Go to Maven Menu > Lifecycle > package and after the hard work, your JAR file will be shown in your project directory > target folder as Name-Version-SNAPSHOT.jar

API

Main Class API

void init(Extension)

Called before the UI initialization after the load of the all classes.

You can register your listener classes, or init your variables here. Just for an example, I will set the name of the variable to ext

Register your listener class

ext.registerListener(new MyListener());

Register a translate file

First, you have to create a resource bundle in your resources folder.

Translator.registerSource(a -> ResourceBundle.getBundle("YourBundleName", a));

Listener API

Listeners handles all launcher activity.

void onUILoad()

Called when the UI loaded.

void onTabLoad(CTab)

Called when a tab loaded.

void onWindowCreate(Object)

Called when a window created.

For now, the launcher have only one window named as Main

void onDialogCreate(CDialog)

Called when a dialog created.

Clone this wiki locally