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 Play

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

target property is a limit for the launchers' version.

>=1.16 means it allows all versions bigger than or equal to 1.16 (1.1.6)
>1.16 means it allows all versions bigger than 1.16 (1.1.6)
1.16 means it allows only the version 1.16 (1.1.6)
<1.16 means it allows all version lower than 1.16 (1.1.6)
<=1.16 means it allows all versions lower than or equal to 1.16 (1.1.6)
  1. It should see like this:

  1. If you want, you can add a PNG icon file into the 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 function named init with a parameter for type Extension.

This is the place where your adventure will begin. You can start to develop 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

5 - Running Your Extension

After you published your extension, you need to use it in the launcher, right?

The launcher loads the extensions from a folder in the launcher executable path. So, you need to get into the launcher's application folder. Then create a folder named extensions and move your extension into it. Done!

Sample view

More details for the extensions page here.

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 argument 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 handle 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