Summary

Plugins are modular components that extend Recaf's capabilities by using plugin api located in the package me.coley.recaf.plugin.

Plugins are distributed as jar files.

Setup

To start developing a plugin, download the workspace from github here (Plugin maven workspace). Most IDE's should be capable of importing the pom.xml into a maven project.

Make sure the project compiles. If you want to do this from your IDE you only need to specify the goal of package.

Extension

This is what the plugin should look like at bare minimum:

package me.yourname.pluginname;

import org.plugface.core.annotations.Plugin;
import me.coley.recaf.plugin.*;

@Plugin(name = "Example")
public class ExamplePlugin implements PluginBase {
    @Override
    public String name() {
        return "Example";
    }

    @Override
    public String version() {
        return "1.0";
    }
    
    @Override
    public void onLoad() {
        // Optional, but useful to show that it loads in the console output
        System.out.println("Hello");
    }
}

Plugins by default only need the name and version methods, but with additional interface implmentations extra functionality can be added.

Launchable allows access to command-line arguments. The following classes are found in the me.coley.recaf.plugin package

import javafx.application.Application.Parameters;

/** Interface applied to plugins that have access to the launch arguments. */
public interface Launchable {
    /**
     * Called before the paramaters are parsed internally by Recaf.
     */
    void preparse(Parameters params);

    /**
     * Called after the paramaters are parsed internally by Recaf.
     */
    void postparse(Parameters params);
}

Stageable allows the plugin to be shown in the plugins drop-down menu. Clicking the plugin name in the drop-down will open a window with the content you supply.

/** Interface applied to plugins that will be shown in 
 *  the menu-bar under the "plugins" menu. */
public interface Stageable {
    /** @return Content of stage to create. */
    Parent content();

    /** @return Title of stage to create. */
    String title();

    /** @return Width of stage to create. */
    int width();

    /** @return Height of stage to create. */
    int height();

    // default methods ommited, check src for 
    // optional methods to override
}

Exporting

The plugin API works via simple annotation-based jar loading. To compile your plugin use maven mvn package. This will generate a jar file in the target directory. Copying this file into Recaf's plugins folder will install it. Launch Recaf to verify that your plugin does indeed load.

Examples

For examples implmentations of the plugin api check out these sample plugins: