pyplanet.contrib.player

The player contrib will provide player list and information to the apps and core.

class pyplanet.contrib.player.PlayerManager(instance)[source]

Player Manager.

You can access this class in your app with:

self.instance.player_manager

With the manager you can get several useful information about the players on the server. See all the properties and methods below for more information.

Warning

Don’t initiate this class yourself.

property count_all

Get all player counts (players + spectators).

property count_players

Get number of playing players.

property count_spectators

Get number of spectating players.

async get_player(login=None, pk=None, lock=True)[source]

Get player by login or primary key.

Parameters
  • login – Login.

  • pk – Primary Key identifier.

  • lock – Lock for a sec when receiving.

Returns

Player or exception if not found

Return type

pyplanet.apps.core.maniaplanet.models.Player

async get_player_by_id(identifier)[source]

Get player object by ID.

Parameters

identifier – Identifier.

Returns

Player object or None

async handle_connect(login)[source]

Handle a connection of a player, this call is being called inside of the Glue of the callbacks.

Parameters

login – Login, received from dedicated.

Returns

Database Player instance.

Return type

pyplanet.apps.core.maniaplanet.models.Player

async handle_disconnect(login)[source]

Handle a disconnection of a player, this call is being called inside of the Glue of the callbacks.

Parameters

login – Login, received from dedicated.

Returns

Database Player instance.

Return type

pyplanet.apps.core.maniaplanet.models.Player

async load_blacklist(filename=None)[source]

Load blacklist file.

Parameters

filename – File to load or will get from settings.

Raise

pyplanet.core.exceptions.ImproperlyConfigured

Raise

pyplanet.core.storage.exceptions.StorageException

Returns

Boolean if loaded.

async load_guestlist(filename=None)[source]

Load guestlist file.

Parameters

filename – File to load or will get from settings.

Raise

pyplanet.core.exceptions.ImproperlyConfigured

Raise

pyplanet.core.storage.exceptions.StorageException

Returns

Boolean if loaded.

async map_loaded(*args, **kwargs)[source]

Reindex the current number of players and spectators.

Parameters
  • args

  • kwargs

Returns

property max_players

Get maximum number of players.

property max_spectators

Get maximum number of spectators.

async on_start()[source]

Handle startup, just before the apps will start. We will throw connects for the players so we know that the current playing players are also initiated correctly!

property online

Online player list.

property online_logins

Online player logins list.

async save_blacklist(filename=None)[source]

Save the current blacklisted players to file given or fetch from config.

Parameters

filename (str) – Give the filename of the blacklist, Leave empty to use the current loaded and configured one.

Raise

pyplanet.core.exceptions.ImproperlyConfigured

Raise

pyplanet.core.storage.exceptions.StorageException

async save_guestlist(filename=None)[source]

Save the current guestlisted players to file given or fetch from config.

Parameters

filename (str) – Give the filename of the guestlist, Leave empty to use the current loaded and configured one.

Raise

pyplanet.core.exceptions.ImproperlyConfigured

Raise

pyplanet.core.storage.exceptions.StorageException

Exceptions for Map Manager.

exception pyplanet.contrib.player.exceptions.PlayerNotFound[source]

Player not found