Skip to content

AclManager

Provides access to the server’s Access Control Manager to configure operators, bans, whitelist, and associated rule records. The acl global exposes the existing ServerObject.acl manager.

Rules are represented by AclRule, including users and IP addresses. Rules can be local or global, organized under the 'bans', 'ops', 'wl', and 'subnets' keys in acl.rules.

View the source: AclManager

Returns a dict of a player’s connection data given their username and other rules. Use acl.get_uuid('Username')['uuid'] to get their UUID

ParametersTypeDescription
username*strUsername of the player

Kicks a player or list of players, optionally with a reason

ParametersTypeDescription
rule_list*PlayerScriptObject / str / listPlayer object, username, or a list containing either
reasonstrReason for the kick displayed to the client, and in the log

acl.ban_player(rule_list, remove=False, reason=None, length="forever")

Section titled “acl.ban_player(rule_list, remove=False, reason=None, length="forever")”

Bans/pardons a player, IP, list of players, or list of IPs, optionally with a reason. A subnet range such as 192.168.0.0/24 is also acceptable. You can whitelist an IP or subnet with !w192.168.0.5

ParametersTypeDescription
rule_list*PlayerScriptObject / str / listPlayer object, username/IP, or a list containing either
removeboolRemoves rule from effect. Defaults to False
reasonstrReason shown in the ban message and log
lengthstrBan duration; defaults to 'forever'. Uses inference with formatting like '1y', '2mo', '5d', etc.

Ops/de-ops a player or list of players

ParametersTypeDescription
rule_list*PlayerScriptObject / str / listPlayer object, username, or a list containing either
removeboolRemoves rule from effect. Defaults to False

acl.whitelist_player(rule_list, remove=False)

Section titled “acl.whitelist_player(rule_list, remove=False)”

Adds/removes a player or list of players to/from the whitelist

ParametersTypeDescription
rule_list*PlayerScriptObject / str / listPlayer object, username, or a list containing either
removeboolRemoves rule from effect. Defaults to False

Enables or disables the server whitelist

ParametersTypeDescription
enabledboolDefaults to True

acl.add_global_rule(rule_list, list_type, remove=False)

Section titled “acl.add_global_rule(rule_list, list_type, remove=False)”

Adds a player or list of players to a specified list type for every server. Learn more about global rules

ParametersTypeDescription
rule_list*PlayerScriptObject / str / listPlayer object, username, or a list containing either
list_type*strCan be 'ops', 'bans', or 'wl'
removeboolRemoves rule from effect. Defaults to False

Reloads the list type from the server’s access control files, and refreshes acl.rules. If list_type is unspecified, all data is reloaded

ParametersTypeDescription
list_typestrCan be 'ops', 'bans', or 'wl'

acl.edit_list(rule_list, list_type, remove=False, overwrite=False)

Section titled “acl.edit_list(rule_list, list_type, remove=False, overwrite=False)”

Similar to the acl.*_player methods, but only edits acl.rules in memory without writing to disk

ParametersTypeDescription
rule_list*PlayerScriptObject / str / listPlayer object, username, or a list containing either
list_type*strCan be 'ops', 'bans', or 'wl'
removeboolRemoves rule from effect. Defaults to False
overwriteboolReplaces an existing matching in-memory rule when adding. Defaults to False

Writes data from acl.rules to disk in their respective format. Works pre-1.8 for .txt files, and post-1.8 for .json files

Looks up a player/IP in the specified list and returns the matching AclRule, or None if absent. This return value is also truthy in conditionals

ParametersTypeDescription
rule*strUsername, IP, or subnet
list_type*strCan be 'ops', 'bans', 'wl', or 'subnets'

Returns a dict of counts. When list_type is passed, it returns {list_type: int}. Without passing list_type, it returns {'ops': int, 'bans': int, 'wl': int, 'total': int}

ParametersTypeDescription
list_typestrCan be 'ops', 'bans', or 'wl'

Retrieves all the access control data associated with a rule. Returns a new AclRule with additional data in the AclRule.extra_data dictionary

ParametersTypeDescription
rule_name*strUsername, IP, or subnet
AttributeTypeDescription
acl.rulesdictContains lists of AclRule objects keyed by rule types. See the example below.
acl.playerdatalistContains an AclRule for every player who has joined the server in the usercache.json, or who has player data in the world
acl.list_itemsdictStructured similarly to acl.rules, but contains an organized list of disabled and enabled items for each list type; for the UI
acl.displayed_ruleAclRule / NoneContains the rule returned from the acl.get_rule() method, or None when no rule is displayed
acl.whitelist_enabledboolWhether or not the server whitelist is enforced
acl.rules = {
'ops': [AclRule, AclRule, ...],
'bans': [AclRule, AclRule, ...],
'wl': [AclRule, AclRule, ...],
'subnets': [AclRule, AclRule, ...]
}