Options
All
  • Public
  • Public/Protected
  • All
Menu

Class World

Hierarchy

  • World

Index

Constructors

constructor

Properties

Protected _api

_api: WorldApi

Protected _chatWatcher

_chatWatcher: ChatWatcher

Protected _commands

_commands: Map<string, function> = new Map()

Protected _firstChatUpdate

_firstChatUpdate: number = Date.now()

The first time joins were updated from chat It is assumed that all joins from this point onwards have been counted.

Protected _lastLogUpdate

_lastLogUpdate: number

The last time joins were updated from the log

Protected _online

_online: string[] = []

Protected _storage

_storage: Storage

Accessors

onJoin

onLeave

onMessage

  • Fires whenever a player or the server sends a message in chat. Includes messages starting with /

    Returns SafeSimpleEvent<object>

onOther

online

  • get online(): string[]
  • Gets the currently online players

    Returns string[]

players

Methods

Protected _createWatcher

  • _createWatcher(): void
  • Internal init function

    Returns void

Protected _executeMessageQueue

  • _executeMessageQueue(): Promise<void>
  • Sends messages in the message queue one by one to prevent the api from concatting 2 messages into 1.

    Returns Promise<void>

Protected _recordJoin

  • _recordJoin(__namedParameters: object): void
  • Parameters

    • __namedParameters: object

    Returns void

Protected _updatePlayers

  • _updatePlayers(): Promise<void>

Protected _userJoin

  • _userJoin(__namedParameters: object): void
  • Parameters

    • __namedParameters: object

    Returns void

addCommand

  • addCommand(command: string, listener: function): void
  • Adds a listener for a single command, can be used when a command can be statically matched.

    Parameters

    • command: string

      the command that the listener should be called for, case insensitive

    • listener: function

      the function which should be called whenever the command is used

        • (player: Player, args: string): void
        • Parameters

          Returns void

    Returns void

getLists

  • getLists(refresh?: boolean): Promise<WorldLists>
  • Gets the server's lists

    Parameters

    • Default value refresh: boolean = false

    Returns Promise<WorldLists>

getLogs

  • getLogs(refresh?: boolean): Promise<LogEntry[]>
  • Gets the server logs

    Parameters

    • Default value refresh: boolean = false

      if true, will get the latest logs, otherwise will returned the cached version.

    Returns Promise<LogEntry[]>

getOverview

  • getOverview(refresh?: boolean): Promise<WorldOverview>
  • Gets an overview of the server info

    Parameters

    • Default value refresh: boolean = false

    Returns Promise<WorldOverview>

getPlayer

  • getPlayer(name: string): Player
  • Gets a specific player by name

    Parameters

    • name: string

    Returns Player

getStatus

  • getStatus(): Promise<"online" | "offline" | "startup" | "shutdown" | "stopping" | "storing" | "deleting" | "move" | "maintenance" | "unavailable">
  • Returns the current world status, will always make a request to the server.

    Returns Promise<"online" | "offline" | "startup" | "shutdown" | "stopping" | "storing" | "deleting" | "move" | "maintenance" | "unavailable">

removeCommand

  • removeCommand(command: string): void
  • Removes a listener for a command, if it exists.

    Parameters

    • command: string

      the command for which the listener should be removed.

    Returns void

restart

  • restart(): Promise<void>
  • Sends a restart request, if the world is offline no actions will be taken.

    Returns Promise<void>

send

  • send(message: string): Promise<void>
  • Sends the specified message, returns a promise that will reject if the send fails and resolve otherwise.

    Parameters

    • message: string

      the message to send

    Returns Promise<void>

setLists

  • setLists(lists: Partial<WorldLists>): Promise<void>
  • Sets the server's lists and reloads the world lists if required.

    Parameters

    • lists: Partial<WorldLists>

      WorldLists one or more list to update. If a list is not provided it will not be changed.

    Returns Promise<void>

    a promise which will resolve when the lists have been updated, or throw if an error occurred.

start

  • start(): Promise<void>
  • Starts the world, if it is not already started. Will not reject.

    Returns Promise<void>

startWatchingChat

  • startWatchingChat(): void
  • Starts the internal chat watcher

    Returns void

stop

  • stop(): Promise<void>
  • Stops the world if it is running. Will not throw.

    Returns Promise<void>

stopWatchingChat

  • stopWatchingChat(): void
  • Stops the internal chat watcher.

    Returns void

Object literals

Protected _lists

_lists: object

adminlist

adminlist: never[] = []

blacklist

blacklist: never[] = []

modlist

modlist: never[] = []

whitelist

whitelist: never[] = []

Generated using TypeDoc