Skip to content

Plugin API Docs

Pedro Amaro edited this page Jul 5, 2020 · 2 revisions

Events

There are 3 kinds of events available: chat, join, and leave.

Chat Event

Is called when a player sends a message to chat.

Usage

global.Brikkit.on('chat', evt => ...

Fields
Field Description Getter
Date Date object containing the date the event happened on Brickadia. evt.getDate()
Sender Player object with details of the sender evt.getSender()
Content Content of the message evt.getContent()
Type Type of the event ("chat") evt.getType()

Join Event

Is called when a player joins the server.

Usage

global.Brikkit.on('join', evt => ...

Fields
Field Description Getter
Date Date object containing the date the event happened on Brickadia. evt.getDate()
Player Player object with details of the player who joined evt.getPlayer()
Type Type of the event ("join") evt.getType()

Leave Event

Is called when a player joins the server.

Usage

global.Brikkit.on('leave', evt => ...

Fields
Field Description Getter
Date Date object containing the date the event happened on Brickadia. evt.getDate()
Player Player object with details of the player who left evt.getPlayer()
Type Type of the event ("join") evt.getType()

Server Interface

These commands interface with the server, allowing you to interact with it. Only the commands that were deemed useful were added to this list.

Say

Broadcasts a message to the whole server.

Usage

global.Brikkit.say('hello world!');

Save Bricks

Saves the bricks in the server to a file.

Usage

global.Brikkit.saveBricks('seattle');

Load Bricks

Loads the bricks from a file to the server.

Usage

global.Brikkit.loadBricks('seattle');

Get Saves

Get all builds that were saved as an unordered array, without the .brs extension.

Usage
global.Brikkit.getSaves(saves => {
	// loads the first save if it exists
	if(saves.length > 0)
		global.Brikkit.loadBricks(saves[0]);
});

Clear All Bricks

DANGER: clears all bricks in the server.

Usage

global.Brikkit.clearAllBricks();

Set Water Level

Sets the water level. Only works on Peaks.

Usage

global.Brikkit.setWaterLevel(10000);

Change Map

Changes the map the server is running on. Will disconnect all players.

Usage

global.Brikkit.changeMap('Studio'); The maps available are: Studio_Night, Studio_Day, Studio, Plate, Peaks.

Get Player From Username

Finds a player object by their username.

Usage

global.Brikkit.getPlayerFromUsername(username);

Get Plugin System

Returns the plugin system of the server, allowing you to load mods on the fly. Do not load plugins twice!

Usage
const pluginSystem = global.Brikkit.getPluginSystem(address);
pluginSystem.loadPlugin('example.zip'); // loads a plugin from a zip
pluginSystem.loadPlugin('hello world'); // loads a plugin from a directory

Get Scraper

Returns the Brikkit scrapper, allowing you to scrape user profiles based on the user id.

Usage
const scraper = global.Brikkit.getScraper();
scraper.getProfile('402ff04c-a0f8-4d07-9471-801889fa0fb2', profile => {
	console.log(`Hello ${profile.getUsername()}!`);
});

Objects

The join and leave events return a Player object, which must be further queried to retrieve more information. Details about these kinds of objects are available here.

Player Object

Field Description Getter
Username The user name of the player getUsername()
UserID The user id of the player getUserId()
HandleId The handle id of the player (similar to user id, but is only valid for a single play session) getHandleId()

Profile Object

Field Description Getter
Username The user name of the player getUsername()
UserID The user id of the player getUserId()
Gender The gender of the player ('male', 'female' or null, if there is no gender selected) getGender()
Where Whether the player is ingame or in real life (can be 'ingame' or 'outside') getWhere()
Last Seen Date object representing when the player was last seen getLastSeen()
Location The location of the player getLocation()
User Text The user text of the player getUserText()