Skip to content
Dario Crosa edited this page Dec 22, 2017 · 2 revisions

node-minecraft-proxy documentation

Table of contents

CreateProxy(options, serverList)
Proxy(serverSettings, serverList)

CreateProxy(options, serverList)

Returns a Proxy object and starts listening.

Arguments

  • options

    An object containing options for the Server class.
    All the options are listed in the node-minecraft-protocol documentation on this.
    NOTE: The keepAlive options will not work beacause the real client and server are supposed to send an respond to keep-alive packets

  • serverList

    An object formatted like this:

    {
      'serverName': {
        host: 'example.com'
        port: '25565',
        isDefault: true, // this indicates if a player should be redirected to this server on their first connection, there should be only one default server
        isFallback: true // this indicates if a player should be redirected to this server in the event of a disconnection from other servers
      },
      'serverName2': {
        host: 'localhost',
        port: 25566
      }
    }

    Example

    {
      hub: {
        host: 'localhost',
        port: 25565,
        isDefault: true,
        isFallback: true
      },
      minigames: {
        host: 'localhost',
        port: 25566
      }
    }

Proxy(serverSettings, serverList)

The Proxy class. This class extends the Server class from node-minecraft-protocol. More information about the Server class can be found here.

Arguments

  • serverSettings

    An object with the arguments for the Server class. The options for this class are explained in the node-minecraft-protocol documentation.

  • serverList

    A serverList object. See above for more info.

Variables

  • ServerList
    This is the server list that has been passed as an argument on the creation of the proxy. The server list can be modified here.
  • All the variables eredited from the node-minecraft-protocol Server class

Methods

  • setRemoteServer(remoteClientId, newServerName)

    Move the client with the specified ClientId to the server with the specified newServerName

    Arguments

    • remoteClientId
      The id of the client. The client object is eredited from the Server class.

    • newServerName
      The name of the new server to wich the client will be connected. This name should be present in the serverList.

  • fallback(remoteClientId)

    Move the client with the specified ClientId to the fallback server (obtained using getFallBackServer())

    Arguments

    • remoteClientId
      The id of the client. The client object is eredited from the Server class.
  • getFallbackServerName()

    Returns the serverName of the fallback server

  • getDefaultServerName()

    Returns the serverName of the default server

  • All the methods eredited from the node-minecraft-protocol Server class

Events

  • error

    Called when an error occurs. Parameters:

    • error: the error object
  • playerMoving

    Called when a player is moving from a server to another (whether the player is being moved normally or is falling back to another server). Parameters

    • playerId: the id of the client that is being moved
    • oldServerName: the id of the server from wich the player is being moved
    • newServerName: the id of the server to wich the player is being moved
  • playerMoved

    Called when a player has been moved from a server to another (whether the player was moved normally or was falling back to another server). Parameters

    • playerId: the id of the client that was moved
    • oldServerName: the id of the server from wich the player was moved
    • newServerName: the id of the server to wich the player was moved
  • moveFailed

    Called when a player has failed to move from a server to another (whether the player was moved normally or was falling back to another server, normally called together with the error event). Parameters

    • error: the error that prevented the move of the player
    • playerId: the id of the client that was being moved
    • oldServerName: the id of the server from wich the player was being moved
    • newServerName: the id of the server to wich the player was being moved
  • playerFallback

    Called when a player is falling back from a server to another (normally called together with the playerMoving event). Parameters

    • playerId: the id of the client that is being moved
    • oldServerName: the id of the server from wich the player is being moved
    • newServerName: the id of the server to wich the player is being moved
  • All the evets eredited from the node-minecraft-protocol Server class

Documentation


Clone this wiki locally