MushMC-API is a Python library for developers that facilitates access to the MushMC server API, making project creation more efficient and dynamic.
Project description
MushMC-API Overview
- MushMC-API is a Python library for developers that facilitates access to the MushMC server API, making project creation more efficient and dynamic. It is unofficial, but offers an improved and independent experience for interested developers.
Table of Contents
Installation
To install the library, use the command below:
python -m pip install mushmc-api
Getting started
Importing the library into your Python project:
from mushmc import MushMC
- To use the library, you must install it via pip. Click here to see how to install it.
Creating an instance of the MushMC class:
mushmc = MushMC() # async_run=False
- The class has an optional parameter, which is
async_run
, which only accepts Boolean values. IfTrue
, the instance will be asynchronous, otherwise it will be synchronous. The default isFalse
.
Using the created instance to obtain information about the "FHDP" player:
player = mushmc.Player(nick_or_uuid='FHDP') # retries=0, timeout=5
- The class has a mandatory parameter, which is
nick_or_uuid
, which only accepts values of typestr
. The value can be the player's nick or uuid. - Furthermore, it has two optional parameters, which are
retries
andtimeout
, which only accept values of typeint
. Theretries
is the number of attempts that the program will make to obtain the player's information, if an error occurs. Thetimeout
is the maximum waiting time to obtain player information.retries
defaults to0
andtimeout
defaults to5
.
Getting general player information:
raw_response = player.raw_response
first_login = player.first_login
last_login = player.last_login
is_online = player.is_online
discord = player.discord
account = player.account
rank = player.rank
clan = player.clan
- The class has an attribute called
raw_response
, which returns a dictionary with all available player information, without any processing. - In addition, it has other attributes, which are:
first_login
: returns in unix format the date and time of the first time the player entered the server.last_login
: returns in unix format the date and time of the last time the player logged into the server.is_online
: returns a boolean value indicating whether the player is online or not.discord
: returns a dictionary with the player's Discord account information, if they have linked it.account
: returns a dictionary with the player's account information on the server.rank
: returns a dictionary with the player's rank information on the server.clan
: returns a dictionary with the player's clan information on the server.
Getting player information about game modes (example: "bedwars"):
play_time = player.play_time
game_list = player.list_games()
game_stats = player.get_game_stats(game='bedwars')
- The class has other attributes and methods, which are:
play_time
: returns a dictionary with information about the player's playing time in each game mode.list_games()
: returns a list with the names of game modes in which the player has played.get_game_stats(game)
: returns a dictionary with player information about the specified game mode. Thegame
parameter is mandatory and only accepts values of typestr
. The value must be the name of the game mode and is case-sensitive.
Disclaimer
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mushmc-api-0.0.2.tar.gz
(4.6 kB
view hashes)