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.

count_all

Get all player counts (players + spectators).

count_players

Get number of playing players.

count_spectators

Get number of spectating players.

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

get_player_by_id(identifier)[source]

Get player object by ID.

Parameters:identifier – Identifier.
Returns:Player object or None
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
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
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.
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.
map_loaded(*args, **kwargs)[source]

Reindex the current number of players and spectators.

Parameters:
  • args
  • kwargs
Returns:

max_players

Get maximum number of players.

max_spectators

Get maximum number of spectators.

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!

online

Online player list.

online_logins

Online player logins list.

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
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