-
Notifications
You must be signed in to change notification settings - Fork 2
Creating your first plugin
Make sure you have checked out the Setting up your workspace article before making a plugin.
-
Before setting up the project to be directed at plugin making, create a Gradle project. If you don't know how to do that, please check out the Creating a Gradle project article.
-
Open the
build.gradlefile in the project's root directory. -
Change whatever version identifier is located after
sourceCompatibilityto 1.8. -
Add
maven { url "https://jitpack.io" }to the bottom of therepositoriesblock. This allows us to use GitHub repositories as dependencies. -
Add
compile 'com.github.Wingman:wingman:VERSION'to the top of thedependenciesblock, whereVERSIONis to be replaced by the latest Wingman release version found here. You can also opt-in to usecom.github.Wingman:wingman:-SNAPSHOTif you want your plugin to always use the latest API.
-
Navigate to the Gradle directory
src\main\java, and create a new package calledcom.<your GitHub name>.myplugin, then create a class namedMyPlugininside that package. -
Annotate it with the
Pluginclass, like so:
@Plugin(
id = "MyPlugin",
name = "My Plugin",
version = "1.0.0",
description = ""
)
public class MyPlugin {
}-
For this tutorial, set the id value to "MyPlugin", the name value to "My Plugin", the version value to "1.0.0" and leave the description empty. Keep in mind however that the client dislikes having multiple plugins loaded with the same ID, so make sure to release your plugin with a unique ID. This can be done by adding a random string of characters to the end of the ID.
-
Create a new
public voidmethod named anything, preferablyactivate, and annotate it with Plugin.Activate.
@Plugin(
id = "MyPlugin",
name = "My Plugin",
version = "1.0.0",
description = ""
)
public class MyPlugin {
@Plugin.Activate
public void activate() {
System.out.println("Hi there!");
}
}Using IntelliJ IDEA:
- Open the Run/Debug Configurations screen.
- Add a new Application configuration.
- Set the Wingman
Mainclass as the entry point (press the button next to the Main class input box, press Project at the top and navigate to the class).
- Set the configuration module to
MyPlugin_main.
- Run or debug the project.
- Wingman should launch and after a while activate your new plugin.
INFO MyPlugin - Hi there! should appear in the console box.
Using IntelliJ IDEA:
-
Press the Gradle button on the right-hand side of the IDE interface.
-
Open Tasks, build, and double-click the
buildtask.
- Your plugin is now archived in a
.jarfile. By default it'll be namedMyPlugin-1.0-SNAPSHOT.jarand be located inbuild\libs. You can now distribute that plugin archive to a mate if you want, telling them to install it by following the instructions here.
Using the console:
-
Open a console window,
Command Promptorcmd.exeon Windows. -
Navigate to your plugin's root directory using the
cdcommand. -
Type
gradlew buildto use Gradle to build the project. -
Your plugin is now archived in a
.jarfile. By default it'll be namedMyPlugin-1.0-SNAPSHOT.jarand be located inbuild\libs. You can now distribute that plugin archive to a mate if you want, telling them to install it by following the instructions here.
You've created your first plugin!
You can now continue by checking out other plugin related wiki articles and tutorials.
Please join our Slack if you notice anything wrong or would like to contribute to the wiki.
- General
- Installing a plugin
- The plugin loading process
- Development
- Setting up your workspace
- Creating a Gradle project
- Plugin Development
- Creating your first plugin
- Using event listeners





