Skip to content

Ban

endstone.ban

Classes relevant to bans.

Classes:

Name Description
BanEntry

A single entry from a ban list.

IpBanEntry

Represents an entry for a banned IP address.

IpBanList

Represents a ban list, containing banned IP addresses.

PlayerBanEntry

Represents an entry for a banned player.

PlayerBanList

Represents a ban list, containing banned players.

BanEntry

A single entry from a ban list.

Attributes:

Name Type Description
created datetime

The date this ban entry was created.

expiration datetime | None

The date this ban expires on, or None for no defined end date.

reason str

The reason for this ban.

source str

The source of this ban.

created property writable

created: datetime

The date this ban entry was created.

expiration property writable

expiration: datetime | None

The date this ban expires on, or None for no defined end date.

reason property writable

reason: str

The reason for this ban.

source property writable

source: str

The source of this ban.

IpBanEntry

IpBanEntry(address: str)

Bases: BanEntry

Represents an entry for a banned IP address.

Attributes:

Name Type Description
address str

The banned IP address.

address property

address: str

The banned IP address.

IpBanList

Represents a ban list, containing banned IP addresses.

Methods:

Name Description
add_ban

Adds a ban to this list. If a previous ban exists, this will update the previous entry.

get_ban_entry

Gets a BanEntry by IP address.

is_banned

Checks if a BanEntry exists for the target, indicating an active ban status.

remove_ban

Removes the specified IP address from this list, therefore indicating a "not banned" status.

Attributes:

Name Type Description
entries list[IpBanEntry]

A vector containing pointers to every entry tracked by this list.

entries property

entries: list[IpBanEntry]

A vector containing pointers to every entry tracked by this list.

add_ban

add_ban(
    address: str,
    reason: str | None = None,
    expires: datetime | None = None,
    source: str | None = None,
) -> IpBanEntry

Adds a ban to this list. If a previous ban exists, this will update the previous entry.

Parameters:

Name Type Description Default
address str

The IP address of the target.

required
reason str | None

The reason for the ban, None indicates implementation default.

None
expires datetime | None

The date for the ban's expiration (unban), or None to imply forever.

None
source str | None

The source of the ban, None indicates implementation default.

None

Returns:

Type Description
IpBanEntry

The entry for the newly created ban, or the entry for the (updated) previous ban.

get_ban_entry

get_ban_entry(address: str) -> IpBanEntry | None

Gets a BanEntry by IP address.

Parameters:

Name Type Description Default
address str

The IP address to search for.

required

Returns:

Type Description
IpBanEntry | None

The corresponding entry, or None if none found.

is_banned

is_banned(address: str) -> bool

Checks if a BanEntry exists for the target, indicating an active ban status.

Parameters:

Name Type Description Default
address str

The IP address to find.

required

Returns:

Type Description
bool

True if a BanEntry exists for the target, indicating an active ban status, False otherwise.

remove_ban

remove_ban(address: str) -> None

Removes the specified IP address from this list, therefore indicating a "not banned" status.

Parameters:

Name Type Description Default
address str

The IP address to remove from this list.

required

PlayerBanEntry

PlayerBanEntry(
    name: str,
    uuid: UUID | None = None,
    xuid: str | None = None,
)

Bases: BanEntry

Represents an entry for a banned player.

Attributes:

Name Type Description
name str

The banned player's name.

unique_id UUID | None

The banned player's unique id, or None if not available.

xuid str | None

The banned player's xbox user id (xuid), or None if not available.

name property

name: str

The banned player's name.

unique_id property

unique_id: UUID | None

The banned player's unique id, or None if not available.

xuid property

xuid: str | None

The banned player's xbox user id (xuid), or None if not available.

PlayerBanList

Represents a ban list, containing banned players.

Methods:

Name Description
add_ban

Adds a ban to this list. If a previous ban exists, this will update the previous entry.

get_ban_entry

Gets a BanEntry by player name, UUID, or XUID.

is_banned

Checks if a BanEntry exists for the target, indicating an active ban status.

remove_ban

Removes the specified player from this list, therefore indicating a "not banned" status.

Attributes:

Name Type Description
entries list[PlayerBanEntry]

A vector containing pointers to every entry tracked by this list.

entries property

entries: list[PlayerBanEntry]

A vector containing pointers to every entry tracked by this list.

add_ban

add_ban(
    name: str,
    uuid: UUID | None = None,
    xuid: str | None = None,
    reason: str | None = None,
    expires: datetime | None = None,
    source: str | None = None,
) -> PlayerBanEntry

Adds a ban to this list. If a previous ban exists, this will update the previous entry.

Parameters:

Name Type Description Default
name str

The name of the target.

required
uuid UUID | None

The UUID of the target, None if not used.

None
xuid str | None

The XUID of the target, None if not used.

None
reason str | None

The reason for the ban, None indicates implementation default.

None
expires datetime | None

The date for the ban's expiration (unban), or None to imply forever.

None
source str | None

The source of the ban, None indicates implementation default.

None

Returns:

Type Description
PlayerBanEntry

The entry for the newly created ban, or the entry for the (updated) previous ban.

get_ban_entry

get_ban_entry(
    name: str,
    uuid: UUID | None = None,
    xuid: str | None = None,
) -> PlayerBanEntry | None

Gets a BanEntry by player name, UUID, or XUID.

Parameters:

Name Type Description Default
name str

The player name to search for.

required
uuid UUID | None

The UUID of the player to search for, None if not used.

None
xuid str | None

The XUID of the player to search for, None if not used.

None

Returns:

Type Description
PlayerBanEntry | None

The corresponding entry, or None if none found.

is_banned

is_banned(
    name: str,
    uuid: UUID | None = None,
    xuid: str | None = None,
) -> bool

Checks if a BanEntry exists for the target, indicating an active ban status.

Parameters:

Name Type Description Default
name str

The player name to find.

required
uuid UUID | None

The UUID of the target, None if not used.

None
xuid str | None

The XUID of the target, None if not used.

None

Returns:

Type Description
bool

True if a BanEntry exists for the target, indicating an active ban status, False otherwise.

remove_ban

remove_ban(
    name: str,
    uuid: UUID | None = None,
    xuid: str | None = None,
) -> None

Removes the specified player from this list, therefore indicating a "not banned" status.

Parameters:

Name Type Description Default
name str

The player name to remove from this list.

required
uuid UUID | None

The unique id of the player, None if not used.

None
xuid str | None

The xbox user id (xuid) of the player, None if not used.

None