-
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.gradle
file in the project's root directory. -
Change whatever version identifier is located after
sourceCompatibility
to 1.8. -
Add
maven { url "https://jitpack.io" }
to the bottom of therepositories
block. This allows us to use GitHub repositories as dependencies. -
Add
compile 'com.github.Wingman:wingman:VERSION'
to the top of thedependencies
block, whereVERSION
is to be replaced by the latest Wingman release version found here. You can also opt-in to usecom.github.Wingman:wingman:-SNAPSHOT
if 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 namedMyPlugin
inside that package. -
Annotate it with the
Plugin
class, 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 void
method 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
Main
class 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
build
task.
- Your plugin is now archived in a
.jar
file. By default it'll be namedMyPlugin-1.0-SNAPSHOT.jar
and 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 Prompt
orcmd.exe
on Windows. -
Navigate to your plugin's root directory using the
cd
command. -
Type
gradlew build
to use Gradle to build the project. -
Your plugin is now archived in a
.jar
file. By default it'll be namedMyPlugin-1.0-SNAPSHOT.jar
and 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