17.3. A quick Example (Macros)

First, let's see a quick example of an implemented plugin. To implement a macro plugin you must create a java class that implements the IMacro interface:

public interface IMacro extends IPlugin {
   MacroDefinition getDefinition();
   byte[] execute(IValue[] parameters, IEngine engine);

The interface has two methods, one that gets parameters that defines the macro, and one executes it. This is the basic structure of nearly all the plugins. The MacroDefinition class is really simple. It consist of a getter and setters for the defining properties. Since the only defining property of a macro is its name, it looks like this:

public class MacroDefinition {
   // Properties
   private String name;

   // Getters/setters for properties, in this case getName() and setName(name)

A simple example of a macro implementation that prints ‘Hello World from MyMacro!’ and returns zero bytes looks like this:

package test.plugins.macros;
import kickass.plugins.interf.general.IEngine;
import kickass.plugins.interf.general.IValue;
import kickass.plugins.interf.macro.IMacro;
import kickass.plugins.interf.macro.MacroDefinition;

public class MyMacro implements IMacro {
   MacroDefinition definition;
   public MyMacro() {
      definition = new MacroDefinition();

   public MacroDefinition getDefinition() {
      return definition;

   public byte[] execute(IValue[] parameters, IEngine engine) {
      engine.print("Hello world from mymacro!");
      return new byte[0];

You execute it as a normal macro:

.plugin "test.plugins.macros.MyMacro"

The ‘arguments’ parameter is the arguments parsed to the macro. You can read about these in the 'general communication classes' section. The same goes for the ‘engine’ parameter which is used to do additional communication with the Kick Assembler engine.