Implement the Plugin interface

The first thing you must do in order to create a forge plugin, is create a new class and implement the interface. Notice that the interface has no methods, this is because you will be adding your own custom commands later.

public class ExamplePlugin implements Plugin

You might also use the “plugins new-plugin” command to do this a little more quickly:

[example] example $ plugins new-plugin --named ExamplePlugin
? In which package would you like to create [ExamplePlugin], or enter for default: [com.example]

Wrote ~/example/src/main/java/com/example/
Picked up type <JavaResource>: com.example.ExamplePlugin

[example] $ ls -a

package com.example;
import javax.inject.Inject;

public class ExamplePlugin implements Plugin {
  @Inject private ShellPrompt prompt;
  public void run(PipeOut out, @Option(name="value") final String arg){
    out.println("Executed command with value: " + arg);
[example] $

As you can see, in addition to creating the Plugin class, this action has already created a blank command for us to customize.