Omegga API
The Omegga global (and the omegga passed to a plugin constructor)
implements OmeggaLike. It is an event emitter, so everything in
Events is available on it too.
OmeggaLike
Extends OmeggaCore, LogWrangling, InjectedCommands, MockEventEmitter.
| Property | Type | Description |
|---|---|---|
version | number | game CL version |
Console | ConsoleCommands | version-resolved Brickadia console command names, nested by namespace. e.g. Omegga.Console.Bricks.Clear resolves to the command string for the running game version (“Bricks.Clear” or “br.Bricks.Clear”) |
verbose | boolean | verbose logging is enabled |
players | OmeggaPlayer[] | list of players |
host? | { id: string; name: string } | server host |
started | boolean | server is started |
starting | boolean | server is starting |
stopping | boolean | server is stopping |
currentMap | string | current map |
configPath | string | path to config files |
savePath | string | path to saves |
worldPath | string | path to worlds |
prefabPath | string | path to prefabs |
presetPath | string | path to presets |
path | string | path to containing dir |
binaryPath | string | null | path to the directory containing the game server binary - null when the install is launcher-managed and the binary location isn’t known |
writeln
writeln(line: string): void
getPlugin
getPlugin(name: string): Promise<PluginInterop | null>
get a plugin’s name, documentation, and loaded status If run in an unsafe plugin, the emitPlugin method sends events from an “unsafe” plugin
Declared in src/plugin.ts.
OmeggaCore
getPlayers
getPlayers(): { id: string; name: string; displayName: string; controller: string; state: string; }[]
get a list of players
Returns list of players {id: uuid, name: name} objects
getPlayer
getPlayer(target: string): OmeggaPlayer | null
find a player by name, id, controller, or state
| Param | Type | Description |
|---|---|---|
target | string | name, id, controller, or state |
findPlayerByName
findPlayerByName(name: string): OmeggaPlayer | null
find a player by rough name, prioritize exact matches and get fuzzier
| Param | Type | Description |
|---|---|---|
name | string | player name, fuzzy |
getHostId
getHostId(): string
get the host’s ID
Returns Host Id
broadcast
broadcast(...messages: string[]): void
broadcast messages to chat messages are broken by new line multiple arguments are additional lines all messages longer than 512 characters are deleted automatically, though omegga wouldn’t have sent them anyway
| Param | Type | Description |
|---|---|---|
...messages | string[] | unescaped chat messages to send. may need to wrap messages with quotes |
whisper
whisper(target: string | OmeggaPlayer, ...messages: string[]): void
whisper messages to a player’s chat messages are broken by new line multiple arguments are additional lines all messages longer than 512 characters are deleted automatically, though omegga wouldn’t have sent them anyway
| Param | Type | Description |
|---|---|---|
target | string | OmeggaPlayer | player identifier or player object |
...messages | string[] | unescaped chat messages to send. may need to wrap messages with quotes |
middlePrint
middlePrint(target: string | OmeggaPlayer, message: string): void
prints text to the middle of a player’s screen all messages longer than 512 characters are deleted automatically
| Param | Type | Description |
|---|---|---|
target | string | OmeggaPlayer | player identifier or player object |
message | string | unescaped chat messages to send. may need to wrap messages with quotes |
saveMinigame
saveMinigame(index: number, name: string): void
Save a minigame preset based on a minigame index
| Param | Type | Description |
|---|---|---|
index | number | minigame index |
name | string | preset name |
deleteMinigame
deleteMinigame(index: number): void
Delete a minigame
| Param | Type | Description |
|---|---|---|
index | number | minigame index |
resetMinigame
resetMinigame(index: number): void
Reset a minigame
| Param | Type | Description |
|---|---|---|
index | number | minigame index |
nextRoundMinigame
nextRoundMinigame(index: number): void
Force the next round in a minigame
| Param | Type | Description |
|---|---|---|
index | number | minigame index |
loadMinigame
loadMinigame(presetName: string, owner?: string): void
Load an Minigame preset
| Param | Type | Description |
|---|---|---|
presetName | string | preset name |
owner | string | owner id/name |
getMinigamePresets
getMinigamePresets(): string[]
Get all presets in the minigame folder and child folders
resetEnvironment
resetEnvironment(): void
Reset the environment settings
saveEnvironment
saveEnvironment(presetName: string): Promise<void>
Save an environment preset
| Param | Type | Description |
|---|---|---|
presetName | string | preset name |
getEnvironmentData
getEnvironmentData(): Promise<EnvironmentPreset | null>
Save a temporary environment preset and return its contents
readEnvironmentData
readEnvironmentData(presetName: string): EnvironmentPreset | null
Read environment data as json; null when the preset is missing or invalid
| Param | Type | Description |
|---|---|---|
presetName | string | preset name |
loadEnvironment
loadEnvironment(presetName: string): void
Load an environment preset
| Param | Type | Description |
|---|---|---|
presetName | string | preset name |
loadEnvironmentData
loadEnvironmentData(preset: | EnvironmentPreset | NonNullable<EnvironmentPreset['data']>['groups']): void
Load some environment preset data
| Param | Type | Description |
|---|---|---|
preset | | EnvironmentPreset | NonNullable<EnvironmentPreset['data']>['groups'] | preset data |
getEnvironmentPresets
getEnvironmentPresets(): string[]
Get all presets in the environment folder and child folders
clearBricks
clearBricks(target: string | { id: string }, quiet?: boolean): void
Clear a user’s bricks (by uuid, name, controller, or player object)
| Param | Type | Description |
|---|---|---|
target | string | { id: string } | player or player identifier |
quiet | boolean | quietly clear bricks |
clearRegion
clearRegion(region: { center: [number, number, number]; extent: [number, number, number]; }, options?: { target?: string | OmeggaPlayer; bricks?: boolean; entities?: boolean; }): void
Clear a region of bricks. On EA3 this routes to br.World.ClearRegion
and can optionally clear entities too.
| Param | Type | Description |
|---|---|---|
region | { center: [number, number, number]; extent: [number, number, number]; } | region to clear |
options | { target?: string | OmeggaPlayer; bricks?: boolean; entities?: boolean; } | optional settings |
clearAllBricks
clearAllBricks(options?: | boolean | { quiet?: boolean; bricks?: boolean; entities?: boolean }): void
Clear all bricks on the server. On EA3 this routes to
br.World.ClearAll and can optionally clear entities too. A bare boolean
is accepted as the legacy quiet argument.
| Param | Type | Description |
|---|---|---|
options | | boolean | { quiet?: boolean; bricks?: boolean; entities?: boolean } | quiet (or { quiet, bricks, entities }) |
saveBricks
saveBricks(saveName: string, region?: { center: [number, number, number]; extent: [number, number, number]; }): void
Deprecated. removed in Brickadia EA3 (no-op on newer servers) - save a
prefab with savePrefabRegion instead
Save bricks under a filename
| Param | Type | Description |
|---|---|---|
saveName | string | save file name |
region | { center: [number, number, number]; extent: [number, number, number]; } | region of bricks to save |
saveBricksAsync
saveBricksAsync(saveName: string, region?: { center: [number, number, number]; extent: [number, number, number]; }): Promise<void>
Deprecated. removed in Brickadia EA3 (no-op on newer servers) - save a
prefab with savePrefabRegion instead
Save bricks under a filename, with a promise
| Param | Type | Description |
|---|---|---|
saveName | string | save file name |
region | { center: [number, number, number]; extent: [number, number, number]; } | region of bricks to save |
loadBricks
loadBricks(saveName: string, options?: { offX?: number; offY?: number; offZ?: number; quiet?: boolean; correctPalette?: boolean; correctCustom?: boolean; }): void
Deprecated. removed in Brickadia EA3 (no-op on newer servers) - load a
prefab with loadPrefab instead
Load bricks on the server
loadBricksOnPlayer
loadBricksOnPlayer(saveName: string, player: string | OmeggaPlayer, options?: { offX?: number; offY?: number; offZ?: number; correctPalette?: boolean; correctCustom?: boolean; }): void
Deprecated. removed in Brickadia ~EA2 (no-op on newer servers) - use
loadPrefabOnPlayer instead
Load bricks on the server into a player’s clipbaord
getSaves
getSaves(): string[]
Get all saves in the save folder and child folders
getSavePath
getSavePath(saveName: string): string | undefined
Checks if a save exists and returns an absolute path
| Param | Type | Description |
|---|---|---|
saveName | string | Save filename |
Returns Path to string, undefined if the save does not exist
getWorlds
getWorlds(): string[]
Get all worlds in the worlds folder and child folders
getWorldPath
getWorldPath(worldName: string): string | undefined
Checks if a world exists and returns an absolute path
| Param | Type | Description |
|---|---|---|
worldName | string | World name |
Returns Path to string, undefined if the world does not exist
getWorldRevisions
getWorldRevisions(worldName: string): Promise<{ index: number; date: Date; note: string }[]>
Get a list of revisions for a world
| Param | Type | Description |
|---|---|---|
worldName | string | World name |
loadWorld
loadWorld(worldName: string): Promise<boolean>
Load a world by its name
| Param | Type | Description |
|---|---|---|
worldName | string | World name |
loadWorldRevision
loadWorldRevision(worldName: string, revision: number): Promise<boolean>
Load a world at a specific revision
| Param | Type | Description |
|---|---|---|
worldName | string | World name |
revision | number |
saveWorldAs
saveWorldAs(worldName: string): Promise<boolean>
Save a world as a new name
| Param | Type | Description |
|---|---|---|
worldName | string | World name |
saveWorld
saveWorld(): Promise<boolean>
Save the current world
createEmptyWorld
createEmptyWorld(worldName: string): Promise<boolean>
Create an empty world with the given name
writeSaveData
writeSaveData(saveName: string, saveData: WriteSaveObject): void
unsafely load save data (wrap in try/catch)
| Param | Type | Description |
|---|---|---|
saveName | string | save file name |
saveData | WriteSaveObject | BRS JS Save data |
readSaveData
readSaveData(saveName: string, nobricks?: boolean): ReadSaveObject
unsafely read save data (wrap in try/catch)
| Param | Type | Description |
|---|---|---|
saveName | string | save file name |
nobricks | boolean | only read save header data |
Returns BRS JS Save Data
loadSaveData
loadSaveData(saveData: WriteSaveObject, options?: { offX?: number; offY?: number; offZ?: number; quiet?: boolean; correctPalette?: boolean; correctCustom?: boolean; }): Promise<void>
Deprecated. removed in Brickadia EA3 (no-op on newer servers) - use the
prefab API (loadPrefab) instead
load bricks from save data and resolve when game finishes loading
| Param | Type | Description |
|---|---|---|
saveData | WriteSaveObject | BRS JS Save data |
options | { offX?: number; offY?: number; offZ?: number; quiet?: boolean; correctPalette?: boolean; correctCustom?: boolean; } |
loadSaveDataOnPlayer
loadSaveDataOnPlayer(saveData: WriteSaveObject, player: string | OmeggaPlayer, options?: { offX?: number; offY?: number; offZ?: number; correctPalette?: boolean; correctCustom?: boolean; }): Promise<void>
Deprecated. removed in Brickadia ~EA2 (no-op on newer servers) - use the
prefab API (loadPrefabOnPlayer) instead
load bricks from save data and resolve when game finishes loading
| Param | Type | Description |
|---|---|---|
saveData | WriteSaveObject | BRS JS Save data |
player | string | OmeggaPlayer | Player name/id or player object |
options | { offX?: number; offY?: number; offZ?: number; correctPalette?: boolean; correctCustom?: boolean; } |
getSaveData
getSaveData(region?: { center: [number, number, number]; extent: [number, number, number]; }): Promise<ReadSaveObject | undefined>
Deprecated. removed in Brickadia EA3 (returns undefined on newer servers) - use the prefab API instead
get current bricks as save data
getPrefabs
getPrefabs(): string[]
Get all prefabs in the prefabs folder and child folders (EA3)
getPrefabPath
getPrefabPath(prefabName: string): string | undefined
Checks if a prefab exists and returns an absolute path (EA3)
| Param | Type | Description |
|---|---|---|
prefabName | string | Prefab filename |
Returns Path to string
loadPrefab
loadPrefab(path: string, options?: { offX?: number; offY?: number; offZ?: number; atOriginalPosition?: boolean; orientation?: number; rootEntityPersistentIndex?: number; mirrorAxes?: number; overrideUserId?: string; }): void
Load a prefab into the world (EA3). path is a bundle path ref such
as Prefabs/Uploads/<hash>.brz.
| Param | Type | Description |
|---|---|---|
path | string | prefab bundle path ref |
options | { offX?: number; offY?: number; offZ?: number; atOriginalPosition?: boolean; orientation?: number; rootEntityPersistentIndex?: number; mirrorAxes?: number; overrideUserId?: string; } | placement options (offset, orientation, mirror axes, etc) |
savePrefab
savePrefab(path: string, options?: { region?: { center: [number, number, number]; extent: [number, number, number]; }; entities?: boolean; rootEntityPersistentIndex?: number; userId?: string; }): void
Save the world (or a region of it) as a prefab (EA3).
| Param | Type | Description |
|---|---|---|
path | string | destination prefab bundle path ref (e.g. Prefabs/MyPrefab.brz) |
options | { region?: { center: [number, number, number]; extent: [number, number, number]; }; entities?: boolean; rootEntityPersistentIndex?: number; userId?: string; } | save options; omit region to capture the whole world |
savePrefabAsync
savePrefabAsync(path: string, options?: { region?: { center: [number, number, number]; extent: [number, number, number]; }; entities?: boolean; rootEntityPersistentIndex?: number; userId?: string; }): Promise<string | null>
Save a prefab and resolve once the prefab file has been written to disk (EA3).
| Param | Type | Description |
|---|---|---|
path | string | destination prefab bundle path ref |
options | { region?: { center: [number, number, number]; extent: [number, number, number]; }; entities?: boolean; rootEntityPersistentIndex?: number; userId?: string; } | same options as savePrefab |
Returns absolute path to the written prefab, or null on timeout
givePrefabToPlayer
givePrefabToPlayer(path: string, player: string | OmeggaPlayer, options?: { preserveOwnership?: boolean }): void
Give a prefab to a player’s inventory (EA3).
| Param | Type | Description |
|---|---|---|
path | string | prefab bundle path ref |
player | string | OmeggaPlayer | player name/id or player object |
options | { preserveOwnership?: boolean } | give options (preserve ownership) |
loadPrefabOnPlayer
loadPrefabOnPlayer(path: string, player: string | OmeggaPlayer, options?: { preserveOwnership?: boolean }): void
Load a prefab onto a player (EA3, replaces loadBricksOnPlayer).
| Param | Type | Description |
|---|---|---|
path | string | prefab bundle path ref |
player | string | OmeggaPlayer | player name/id or player object |
options | { preserveOwnership?: boolean } | give options (preserve ownership) |
changeMap
changeMap(map: string): Promise<boolean>
Change server map
| Param | Type | Description |
|---|---|---|
map | string | Map name |
getRoleSetup
getRoleSetup(): BRRoleSetup
Get up-to-date role setup from RoleSetup.json
getRoleAssignments
getRoleAssignments(): BRRoleAssignments
Get up-to-date role assignments from RoleAssignment.json
getBanList
getBanList(): BRBanList
Get up-to-date ban list from BanList.json
getNameCache
getNameCache(): BRPlayerNameCache
Get up-to-date name cache from PlayerNameCache.json
Declared in src/plugin.ts.
InjectedCommands
getServerStatus
getServerStatus(): Promise<IServerStatus | null>
Get server status
listMinigames
listMinigames(): Promise<IMinigameList>
Deprecated. minigames were replaced by a single gamemode (~CL14000); on
modern servers this returns at most one entry with an empty owner.
Prefer getGamemode.
Get a list of minigames and their indices
getAllPlayerPositions
getAllPlayerPositions(): Promise<IPlayerPositions>
Get all player positions and pawns
getMinigames
getMinigames(): Promise<ILogMinigame[]>
Get minigames and members (one entry per gamemode on modern servers)
getGamemode
getGamemode(): Promise<IGamemode | null>
Get the single gamemode and its teams/players (modern servers, >=CL14000).
Returns null on older servers (use getMinigames).
Declared in src/plugin.ts.
LogWrangling
addMatcher
addMatcher<T>(pattern: IMatcher<T>['pattern'], callback: IMatcher<T>['callback']): void
Add a passive pattern on console output that invokes callback on match
addWatcher
addWatcher<T = RegExpMatchArray>(pattern: IWatcher<T>['pattern'], options?: { timeoutDelay?: number; bundle?: boolean; debounce?: boolean; afterMatchDelay?: number; last?: IWatcher<T>['last']; exec?: () => void; }): Promise<T[]>
Run an active pattern on console output that resolves a match. T is the element type of the resolved matches - RegExpMatchArray for RegExp patterns, the pattern’s return type for function patterns.
watchLogChunk
watchLogChunk<T = RegExpMatchArray>(cmd: string, pattern: IWatcher<T>['pattern'], options?: { first?: 'index' | ((match: T) => boolean); last?: IWatcher<T>['last']; afterMatchDelay?: number; timeoutDelay?: number; }): Promise<T[]>
Run a command and capture bundled output. T is the element type of the resolved matches - RegExpMatchArray for RegExp patterns, the pattern’s return type for function patterns.
watchLogArray
watchLogArray<Item extends Record<string, string> = Record<string, string>, Member extends Record<string, string> = Record<string, string>>(cmd: string, itemPattern: RegExp, memberPattern: RegExp): Promise<{ item: Item; members: Member[] }[]>
Run a command and capture bundled output for array functions
Declared in src/plugin.ts.