Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Server

A class that represents the Server

Hierarchy

  • any
    • Server

Index

Constructors

constructor

  • Creates a new instance of the Server class

    Parameters

    • config: Config

      The configuration for the server

    Returns Server

Properties

availableUserID

availableUserID: number

The current avaiable user id

cache

cache: IORedis.Redis | CustomCache

Our redis client

collections

collections: Collections

MongoDB Collections

config

config: Config

The configuration for the server

items

items: ItemsDat

Items dat object

Methods

clearServerDat

  • clearServerDat(): void
  • Reset the values of the server.dat file

    Returns void

find

  • Finds players or worlds inside the database with a filter.

    Parameters

    • type: "player"

      The type to find

    • filter: PeerData

      The filter for that data

    Returns Promise<PeerData[]>

  • Finds players or worlds inside the database with a filter.

    Parameters

    • type: "world"

      The type to find

    • filter: WorldData

      The filter for that data

    Returns Promise<WorldData[]>

forEach

  • forEach(type: "player", callback: (peer: Peer) => void): Promise<void>
  • forEach(type: "world", callback: (world: World) => void): Promise<void>
  • Loops through each player in the cache

    Parameters

    • type: "player"

      The type to loop

    • callback: (peer: Peer) => void

      The callback to run per element

        • (peer: Peer): void
        • Parameters

          Returns void

    Returns Promise<void>

  • Loops through each world in the cache

    Parameters

    • type: "world"

      The type to loop

    • callback: (world: World) => void

      The callback to run per element

        • Parameters

          Returns void

    Returns Promise<void>

getCDN

hasCollections

  • hasCollections(): boolean
  • Whether or not mongodb collections are in place

    Returns boolean

log

  • log(...args: any[]): Promise<void>
  • Pretty much a console.log but it's asynchronous

    Parameters

    • Rest ...args: any[]

      The arguments to log, same as console.log.

    Returns Promise<void>

setHandler

  • setHandler(type: "connect" | "disconnect", callback: (peer: Peer) => void): void
  • setHandler(type: "receive", callback: (peer: Peer, packet: Buffer) => void): void
  • Set the handler for a specific event

    Parameters

    • type: "connect" | "disconnect"

      The event to handle

    • callback: (peer: Peer) => void

      The callback for that event

        • (peer: Peer): void
        • Parameters

          Returns void

    Returns void

  • Set the handler for a specific event

    Parameters

    • type: "receive"

      The event to handle

    • callback: (peer: Peer, packet: Buffer) => void

      The callback for that event

        • (peer: Peer, packet: Buffer): void
        • Parameters

          • peer: Peer
          • packet: Buffer

          Returns void

    Returns void

setItemMeta

Private setItemsDat

  • setItemsDat(file: Buffer): void
  • Set the items.dat to use, this will create the packet and the hash. Do not use if already set in server config.

    Parameters

    • file: Buffer

      The items.dat file content

    Returns void

start

  • start(): Promise<void>

stringPacketToMap

  • stringPacketToMap(packet: Buffer): Map<string, string>
  • Converts a string packet data to map, this will split the \n and |.

    Parameters

    • packet: Buffer

      The string packet

    Returns Map<string, string>

Generated using TypeDoc