|
| 1 | +# ZenithProxy Example Plugin |
| 2 | + |
| 3 | +[ZenithProxy](https://github.com/rfresh2/ZenithProxy) is a Minecraft proxy and bot. |
| 4 | + |
| 5 | +This repository is an example core plugin for ZenithProxy, allowing you to add custom modules and commands. |
| 6 | + |
| 7 | +## Installing Plugins |
| 8 | + |
| 9 | +Plugins are only supported on the `java` ZenithProxy release channel (i.e. not `linux`). |
| 10 | + |
| 11 | +Place plugin jars in the `plugins` folder inside the same folder as the ZenithProxy launcher. |
| 12 | + |
| 13 | +Restart ZenithProxy to load plugins. Loading plugins after launch or hot reloading is not supported. |
| 14 | + |
| 15 | +## Creating Plugins |
| 16 | + |
| 17 | +Use this repository as a template to create your own plugin repository. |
| 18 | + |
| 19 | +### Plugin Structure |
| 20 | + |
| 21 | +Each plugin needs a main class that implements `ZenithProxyPlugin` and is annotated with `@Plugin`. |
| 22 | + |
| 23 | +Plugin metadata like its unique id, version, and supported MC versions is defined in the `@Plugin` annotation. |
| 24 | + |
| 25 | +[See example](https://github.com/rfresh2/ZenithProxyExamplePlugin/blob/1.21.0/src/main/java/org/example/ExamplePlugin.java) |
| 26 | + |
| 27 | +### Plugin API |
| 28 | + |
| 29 | +The `ZenithProxyPlugin` interface requires you to implement an `onLoad` method. |
| 30 | + |
| 31 | +This method provides a `PluginAPI` object that you can use to register modules, commands, and config files. |
| 32 | + |
| 33 | +`Module` and `Command` classes are implemented the same as in the ZenithProxy source code. |
| 34 | + |
| 35 | +I recommend looking at existing modules and commands for examples. |
| 36 | + |
| 37 | +* [Module](https://github.com/rfresh2/ZenithProxy/tree/1.21.0/src/main/java/com/zenith/module) |
| 38 | +* [Command](https://github.com/rfresh2/ZenithProxy/tree/1.21.0/src/main/java/com/zenith/command) |
| 39 | + |
| 40 | +### Building Plugins |
| 41 | + |
| 42 | +Execute the Gradle `build` task: `./gradlew build` - or double-click the task in Intellij |
| 43 | + |
| 44 | +The built plugin jar will be in the `build/libs` directory. |
| 45 | + |
| 46 | +### Testing Plugins |
| 47 | + |
| 48 | +Execute the `run` task: `./gradlew run` - or double-click the task in Intellij |
| 49 | + |
| 50 | +This will run ZenithProxy with your plugin loaded in the `run` directory. |
| 51 | + |
| 52 | +### New Plugin Checklist |
| 53 | + |
| 54 | +1. Edit `gradle.properties`: |
| 55 | + - `plugin_name` - Name of your plugin, used in the plugin jar name (e.g. `ExamplePlugin`) |
| 56 | + - `maven_group` - Java package for your project (e.g. `com.github.rfresh2`) |
| 57 | +1. Move files to your new corresponding package / maven group: |
| 58 | + - Example: `src/main/java/org/example` -> `src/main/java/com/github/rfresh2` |
| 59 | + - First create the new package in `src/main/java`. Then click and drag original subpackages/classes to your new one |
| 60 | + - Do this with Intellij to avoid manually editing all the source files |
| 61 | + - You must also move folders/package for the `src/main/templates` folder |
| 62 | + - Also make sure to update the package import at the very top of `BuiltConstants.java`, it will not be done automatically |
| 63 | +1. Edit `ExamplePlugin.java`, or remove it and create a new main class |
| 64 | + - Make sure to update the `@Plugin` annotation |
0 commit comments