Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Extensions

PizzaCrust edited this page Feb 13, 2017 · 3 revisions

Fromage is extremely abstract, even Sponge is abstracted upon after being abstracted on Minecraft! This makes your job as a developer for making addons or extensions to this plugin easy! Fromage finds libraries on the classpath using the Reflections library for all types that have the @FromageLib. However, Fromage enforces a strict policy to only allow annotated elements that inherit from LuaObject.Static which is a LuaObject but is accessed statically.

For example, if we wanted to create a static function; but you have to reference the class, you simply do this in your @FromageLib class:

@FromageLib
public class ExampleLib extends LuaObject.Static {
   @LuaFunction
   public void exampleMethod() {}
}

This means is processed and compiled into this: ExampleLib.exampleMethod() for Lua users to use. However, if you want to use a regular LuaObject, it doesn't hold static methods. It is a instance that can be given from a static object. This object is completely local and instance based, similarly to regular objects. There are also, global functions that do not require a reference to the originating class. Similar to the broadcast(msg) function showed in the README.md; since this object is only a instance face, you do not need the annotation of @FromageLib, since it doesn't use static functions. For example:

public class ExampleLib extends LuaObject {
  @GlobalFunction
  public void globalFunc() {}
  @LuaFunction
  public void luaFunc(){}
}

The global function is processed and compiled into a state similarly to this: globalFunc() from anywhere in the script. However, #luaFunc is processed into exampleLibInstance.luaFunc(). After you finished your library class, build it and place it in the config/fromage/ directory. It automatically identifies your library JAR and discovers your object classes and library classes automatically and processes them.

Clone this wiki locally