This project in an example to show how a proper plugin for Lambda Client is set up. The advantage of plugins for a utility mod is that they allow the user to decide what features their personalized client will have. Plugins work in plug and play manner, and can be downloaded and activated inside the ingame menu without reloading the client as long as no mixins are used for the plugin. If you are scared about the Kotlin in this project be aware that Kotlin is a wrapper language for Java. That means that plugins can also be natively written in Java.
To achieve coding building and publishing your own plugin most of the following steps are required.
This is a template repository and can be used as a base to create a custom plugin. Press the Use as template button on GitHub to automatically create a linked fork to this repository.
Clone the repository to your local machine. Use the link of either your fork or the main repository.
git clone https://github.com/lambda-client/ExamplePlugin
In this guide we will use IntelliJ IDEA as IDE.
- Open the project from
File > Open... - Let the IDE collect dependencies and index the code.
- Goto
File > Project Structure... > SDKsand make sure an SDK for Java 8 is installed and selected, if not download it here. - Run the
genIntellijRunsGradle task, or run./gradlew genIntellijRuns. - Open with
CTRL+left_clickonPluginModuleinExampleModuleto open the decompiled lambda dependency. To see the original source code go in the top right corner you can addSources...and select thelambda-*-api-source.jar.
Test if the environment is set up correctly by building the plugin jar using the Gradle tab on the right side of the IDE.
- Go to
ExamplePlugin > Tasks > build > buildin the Gradle tab and run the script - IntelliJ will create a new directory called
build. The final built jar will be inbuild/libs
Configure the metadata of your plugin in plugin_info.json.
The flag main_class must contain the target main class Plugin in this case it is PluginExample.kt
The plugin main class will act as a register for the functions a plugin can provide.
For example when a new module class is created you have to add this to the onLoad() function of the plugin class.
modules.add(ExampleModule)
Every service is required to be added to the main class in order to index the contents.
A module represents a utility module inside the game.
The PluginModule class acts as a wrapper for Module class. For many examples on how a module can work check out the native modules of lambda, or the given example in this project.
The difference from the native Module class is that each component of a plugin requires a reference to the main Plugin class.
pluginMain = ExamplePlugin
Every PluginModule class will need to be registered to the main plugin class
Plugins use the same class as the native client for registering commands. Feel free to check out the commands of Lambda Client as a reference.
A LabelHud is used to display information in the player GUI.
The PluginLabelHud class acts as a wrapper for LabelHud class. For many examples on how a hud can work check out the native hud elements of lambda, or the given example in this project.
The difference to the native LabelHud class is that a referral to the main plugin class is given in the object data.
pluginMain = ExamplePlugin
Every PluginLabelHud class will need to be registered to the main Plugin class.
If coroutines are needed background jobs can be registered using
bgJobs.add(BackgroundJob)
To use mixins, you have to:
- Register the files in the
plugin_info.jsonin themixinslist. - Add the
refmappath frommixins.ExamplePlugin.jsonto thebuild.gradlesource sets.
- Go to
ExamplePlugin > Tasks > shadow > shadowJarin the Gradle tab and run the script - IntelliJ will create a new directory called
buildthe final built jar will be inbuild/libs - Put the
ExamplePlugin-1.0.jarinto your./minecraft/lambda/pluginsfolder and run the game.
Publish your repository in Discord, and we may fork you, or transfer your repository to official plugin organization of Lambda. After review, your plugin may get added to the native marketplace.