Class: PlayerManager

PlayerManager

Handles storage and manipulation of player data.

new PlayerManager(client)

Name Type Description
client RCONClient

Extends

Members

cacheMap.<string, Player>

clientRCONClient

Methods

_cache(data, isPartial){Player}

Resolves a player data payload into a cached Player object and returns the Player instance.

Name Type Default Description
data Object
isPartial boolean false optional
Returns:
Type Description
Player

inherited _validateParameter(value, name, conditions)

Checks if a parameter satisfies specific conditions.

Name Type Description
value any

The actual value of the parameter.

name string

The name of the parameter.

conditions Object optional

Conditions to be met.

Name Type Default Description
defined boolean true optional

Parameter must not be null or undefined.

nonEmptyString boolean true optional

Parameter must be a non-empty string.

positiveInteger boolean false optional

Parameter must be a positive integer.

integer boolean false optional

Parameter must be an integer.

boolean boolean false optional

Parameter must be a boolean.

inherited _validateResponse(response, additionalErrors){Object}

Validates RCON response by checking status code.

Name Type Description
response ResponseMessage
additionalErrors Object
Throws:
Error
Returns:
Type Description
Object

asyncaddAdmin(playerId, adminGroup, comment){Promise.<void>}

Adds a user as an admin.

Name Type Description
playerId string
adminGroup string
comment string optional
Returns:
Type Description
Promise.<void>

asyncaddVIP(playerId, comment){Promise.<void>}

Grants player VIP status.

Name Type Description
playerId string

The player's ID.

comment string optional

A comment to identify this player in the VIP list.

Returns:
Type Description
Promise.<void>

asyncdisbandPlatoon(team, platoon, reason){Promise.<void>}

Disbands a platoon.

Name Type Description
team string | number

The number of name of the team, ex: 0, or "AXIS"

platoon string | number

The name of the platoon, ex: 0 or "ABLE"

reason string optional
Throws:
  • If team or platoon is undefined.
Type
Error
Returns:
Type Description
Promise.<void>

asyncfetch(playerId){Promise.<Player>}

Fetches information for a player.

Name Type Description
playerId string

The player's ID.

Throws:

If the player is not found.

Type
Error
Returns:
Type Description
Promise.<Player>

asyncfetchAllPlayers(){Promise.<Array.<Player>>}

Fetches all players actively in the server.

Returns:
Type Description
Promise.<Array.<Player>>

asynckick(playerId, reason){Promise.<void>}

Kicks a player from the server.

Name Type Description
playerId string

The player ID or username.

reason string optional

Reason to kick the player for.

Throws:
  • If player is undefined.
Type
Error
Returns:
Type Description
Promise.<void>

asynclistAdminGroups(){Promise.<Array.<string>>}

Lists admin groups.

Returns:
Type Description
Promise.<Array.<string>>

asynclistAdminUsers(){Promise.<Array.<AdminUserRecord>>}

Lists admin users.

Returns:
Type Description
Promise.<Array.<AdminUserRecord>>

asynclistPermaBans(){Promise.<Array.<BanRecord>>}

Lists permanent bans on record.

Returns:
Type Description
Promise.<Array.<BanRecord>>

asynclistTempBans(){Promise.<Array.<BanRecord>>}

Lists temporary bans on record.

Returns:
Type Description
Promise.<Array.<BanRecord>>

asynclistVIPPlayers(){Promise.<Array.<VIPPlayer>>}

Retrieves the list of VIP players for this server.

Returns:
Type Description
Promise.<Array.<VIPPlayer>>

asyncmessage(playerId, message){Promise.<void>}

Sends a message to a player.

Name Type Description
playerId string

The player ID or username.

message string

The message to send.

Throws:
  • If player or message is undefined.
Type
Error
Returns:
Type Description
Promise.<void>

asyncpermaBan(playerId, reason, adminName){Promise.<void>}

Permanently ban a player.

Name Type Description
playerId string
reason string optional
adminName string optional
Throws:
  • If playerId is undefined.
Type
Error
Returns:
Type Description
Promise.<void>

asyncpunish(playerId, reason){Promise.<void>}

Punishes a player.

Name Type Description
playerId string
reason string optional
Throws:
  • If playerId is undefined.
Type
Error
Returns:
Type Description
Promise.<void>

asyncremoveAdmin(playerId){Promise.<void>}

Removes this player as an admin.

Name Type Description
playerId string
Returns:
Type Description
Promise.<void>

asyncremovePermaBan(playerId){Promise.<void>}

Removes a player's permanent ban.

Name Type Description
playerId string
Throws:
  • If playerId is undefined.
Type
Error
Returns:
Type Description
Promise.<void>

asyncremovePlayerFromPlatoon(playerId, reason){Promise.<void>}

Removes a player from their platoon.

Name Type Description
playerId string
reason string optional
Throws:
  • If player is commander or isn't in a platoon.
Type
Error
Returns:
Type Description
Promise.<void>

asyncremoveTempBan(playerId){Promise.<void>}

Removes a temporary ban.

Name Type Description
playerId string
Throws:
  • If playerId is undefined.
Type
Error
Returns:
Type Description
Promise.<void>

asyncremoveVIP(playerId){Promise.<void>}

Removes a player's VIP status.

Name Type Description
playerId string
Throws:
  • If playerId is undefined.
Type
Error
Returns:
Type Description
Promise.<void>

asyncswitchTeams(playerId, switchNow){Promise.<void>}

Switches a player's team.

Name Type Default Description
playerId string
switchNow boolean true optional

Whether to switch this player's team immediately, as opposed to on death.

Returns:
Type Description
Promise.<void>

asynctempBan(playerId, duration, reason, adminName){Promise.<void>}

Temporarily ban a player from the server.

Name Type Description
playerId string
duration number

The ban duration in hours.

reason string optional
adminName string optional
Throws:
    • If playerId is undefined.
    Type
    Error
    • If duration isn't a positive integer.
    Type
    Error
Returns:
Type Description
Promise.<void>