PlayerManager

PlayerManager

Handles storage and manipulation of player data.

Constructor

new PlayerManager(client)

Parameters:
Name Type Description
client RCONClient

Extends

Members

cache :Map.<string, Player>

Type:

client :RCONClient

Type:

Methods

_cache(data, isPartialopt) → {Player}

Resolves a player data payload into a cached Player object and returns the Player instance.
Parameters:
Name Type Attributes Default Description
data Object
isPartial boolean <optional>
false
Returns:
Type:
Player

_validateParameter(value, name, conditionsopt)

Checks if a parameter satisfies specific conditions.
Overrides:
Parameters:
Name Type Attributes 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 Attributes Default Description
defined boolean <optional>
true Parameter must not be null or undefined.
nonEmptyString boolean <optional>
true Parameter must be a non-empty string.
positiveInteger boolean <optional>
false Parameter must be a positive integer.
boolean boolean <optional>
false Parameter must be a boolean.

_validateResponse(response, additionalErrors) → {Object}

Validates RCON response by checking status code.
Overrides:
Parameters:
Name Type Description
response ResponseMessage
additionalErrors Object
Throws:
Error
Returns:
Type:
Object

(async) addAdmin(playerId, adminGroup, commentopt) → {Promise.<void>}

Adds a user as an admin.
Parameters:
Name Type Attributes Description
playerId string
adminGroup string
comment string <optional>
Returns:
Type:
Promise.<void>

(async) addVIP(playerId, commentopt) → {Promise.<void>}

Grants player VIP status.
Parameters:
Name Type Attributes Description
playerId string The player's ID.
comment string <optional>
A comment to identify this player in the VIP list.
Returns:
Type:
Promise.<void>

(async) disbandPlatoon(team, platoon, reasonopt) → {Promise.<void>}

Disbands a platoon.
Parameters:
Name Type Attributes 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:
Promise.<void>

(async) fetch(playerId) → {Promise.<Player>}

Fetches information for a player.
Parameters:
Name Type Description
playerId string The player's ID.
Throws:
If the player is not found.
Type
Error
Returns:
Type:
Promise.<Player>

(async) fetchAllPlayers() → {Promise.<Array.<Player>>}

Fetches all players actively in the server.
Returns:
Type:
Promise.<Array.<Player>>

(async) kick(playerId, reasonopt) → {Promise.<void>}

Kicks a player from the server.
Parameters:
Name Type Attributes 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:
Promise.<void>

(async) listAdminGroups() → {Promise.<Array.<string>>}

Lists admin groups.
Returns:
Type:
Promise.<Array.<string>>

(async) listAdminUsers() → {Promise.<Array.<AdminUserRecord>>}

Lists admin users.
Returns:
Type:
Promise.<Array.<AdminUserRecord>>

(async) listPermaBans() → {Promise.<Array.<BanRecord>>}

Lists permanent bans on record.
Returns:
Type:
Promise.<Array.<BanRecord>>

(async) listTempBans() → {Promise.<Array.<BanRecord>>}

Lists temporary bans on record.
Returns:
Type:
Promise.<Array.<BanRecord>>

(async) listVIPPlayers() → {Promise.<Array.<VIPPlayer>>}

Retrieves the list of VIP players for this server.
Returns:
Type:
Promise.<Array.<VIPPlayer>>

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

Sends a message to a player.
Parameters:
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:
Promise.<void>

(async) permaBan(playerId, reasonopt, adminNameopt) → {Promise.<void>}

Permanently ban a player.
Parameters:
Name Type Attributes Description
playerId string
reason string <optional>
adminName string <optional>
Throws:
- If playerId is undefined.
Type
Error
Returns:
Type:
Promise.<void>

(async) punish(playerId, reasonopt) → {Promise.<void>}

Punishes a player.
Parameters:
Name Type Attributes Description
playerId string
reason string <optional>
Throws:
- If playerId is undefined.
Type
Error
Returns:
Type:
Promise.<void>

(async) removeAdmin(playerId) → {Promise.<void>}

Removes this player as an admin.
Parameters:
Name Type Description
playerId string
Returns:
Type:
Promise.<void>

(async) removePermaBan(playerId) → {Promise.<void>}

Removes a player's permanent ban.
Parameters:
Name Type Description
playerId string
Throws:
- If playerId is undefined.
Type
Error
Returns:
Type:
Promise.<void>

(async) removePlayerFromPlatoon(playerId, reasonopt) → {Promise.<void>}

Removes a player from their platoon.
Parameters:
Name Type Attributes Description
playerId string
reason string <optional>
Throws:
- If player is commander or isn't in a platoon.
Type
Error
Returns:
Type:
Promise.<void>

(async) removeTempBan(playerId) → {Promise.<void>}

Removes a temporary ban.
Parameters:
Name Type Description
playerId string
Throws:
- If playerId is undefined.
Type
Error
Returns:
Type:
Promise.<void>

(async) removeVIP(playerId) → {Promise.<void>}

Removes a player's VIP status.
Parameters:
Name Type Description
playerId string
Throws:
- If playerId is undefined.
Type
Error
Returns:
Type:
Promise.<void>

(async) switchTeams(playerId, switchNowopt) → {Promise.<void>}

Switches a player's team.
Parameters:
Name Type Attributes Default Description
playerId string
switchNow boolean <optional>
true Whether to switch this player's team immediately, as opposed to on death.
Returns:
Type:
Promise.<void>

(async) tempBan(playerId, duration, reasonopt, adminNameopt) → {Promise.<void>}

Temporarily ban a player from the server.
Parameters:
Name Type Attributes 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:
Promise.<void>