Skip to content

Plugin Creator

RedstoneAlmeida edited this page Feb 28, 2022 · 3 revisions

Getting started with plugins

The proxy works with a javascript plugin system, all are interconnected, it is for simple systems, but can be improved with some pull-request

Just create a javascript file in the plugins folder automatically generated by the proxy

What is the plugin base?

See the code below

var name = "Teste"; // plugin name
var version = "0.0.1"; // plugin version

function onEnable()
{
    // after proxy and plugin loaded
}

function getName() {
    return this.name; // function is required to load plugin
}

function getVersion() {
    return this.version; // function is required to load plugin
}

Creating commands

function onEnable()
{
    // manager is global variable
    // createCommand(commandName, commandFunction)
    manager.createCommand("hello", "onHello");
}

// values is array of parameters command
// example "hello ok"
// values contains ok
function onHello(values)
{
    print("Hello");
}

Events

Events are simple and practical. See events in events

// event loaded by class name
// if class name is TestEvent, you call "function TestEvent(event)"
function SessionCreateEvent(event)
{
    // event.getSessionId() return SessionID
    // event.getSession() return Session class
}

function SessionInitializeEvent(event)
{
    // event.setServerName(string) defines SessionName
    // event.getSessionName()
}

// cancellable example
// if the event is canceled it will not run until the end
function SessionDataPacketSendEvent(event)
{
    event.setCancelled(true);
}

Creating Loops/Tasks

function onEnable()
{
    manager.createTask("repeat", 5, true); // loop repeat in five seconds interval
}

// handler is to cancel, example handler.cancel(); you cancel task
function repeat(handler)
{
    print("I am loop");
}

See:

image

Global Variables

manager; loader; scheduler

Clone this wiki locally