Skip to content

Commit

Permalink
fixed strings
Browse files Browse the repository at this point in the history
  • Loading branch information
hitblast committed Dec 5, 2023
1 parent acb5928 commit 40eeea0
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions mcsrvstat/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, address: str, platform: ServerPlatform = ServerPlatform.java)

# The primary static method for performing API requests.
@staticmethod
async def perform_get_request(endpoint: str) -> Union[Any, bytes]:
async def _perform_req(endpoint: str) -> Union[Any, bytes]:
try:
async with aiohttp.ClientSession() as session:
async with session.get(endpoint) as request:
Expand All @@ -55,12 +55,12 @@ async def fetch(self) -> Any:
raise InvalidServerTypeError

url = self.endpoints['server'] + self.platform.value + self.address
return await self.perform_get_request(url)
return await self._perform_req(url)

# Basically fetch() but modified for getting a server's icon.
async def fetch_icon(self) -> Any:
async def fetch_icon(self) -> bytes:
url = self.endpoints['icon'] + self.address
return await self.perform_get_request(url)
return await self._perform_req(url)


# The Server class, which is the recommended class to use while interacting with the API.
Expand Down Expand Up @@ -117,55 +117,55 @@ async def fetch(self) -> None:
@_precheck
def is_online(self) -> bool:
"""
Returns a boolean indicating whether the server is online or not.
Returns a boolean indicating whether the Minecraft server is online or not.
"""
return self.data['online']

@property
@_precheck
def ip(self) -> str:
"""
The IP address of the server.
The IP address of the Minecraft server.
"""
return self.data['ip']

@property
@_precheck
def port(self) -> int:
"""
The port used to enter the server.
The port used to enter the Minecraft server.
"""
return self.data['port']

@property
@_precheck
def hostname(self) -> str:
"""
The hostname of the server.
The hostname of the Minecraft server.
"""
return self.data['hostname']

@property
@_precheck
def id(self) -> Optional[str]:
"""
The ID of the server. (`None` if Java Edition)
The ID of the Minecraft server. (`None` if Java Edition)
"""
return self._get_basic_key('serverid')

@property
@_precheck
def gamemode(self) -> Optional[str]:
"""
The default gamemode of the server. (`None` if Java Edition)
The default gamemode of the Minecraft server. (`None` if Java Edition)
"""
return self._get_basic_key('gamemode')

@property
@_precheck
def is_eula_blocked(self) -> Optional[bool]:
"""
Returns a boolean indicating if EULA policy is blocked on the server. (`None` if Bedrock edition)
Returns a boolean indicating if EULA policy is blocked on the Minecraft server. (`None` if Bedrock edition)
"""
return self._get_basic_key('eula_blocked')

Expand All @@ -181,14 +181,14 @@ def version(self) -> Optional[str]:
@_precheck
def software(self) -> Optional[str]:
"""
The software used as the backend of the server. (`None` if not detected)
The software used as the backend of the Minecraft server. (`None` if not detected)
"""
return self._get_basic_key('software')

@_precheck
def get_debug_values(self) -> ServerDebugInfo:
"""
Gives out a `ServerDebugValue` object containing all the accessible debug values of the given server.
Returns a `ServerDebugInfo` object containing the debug values of the Minecraft server.
"""

debug_values = self.data['debug']
Expand All @@ -209,10 +209,11 @@ def get_debug_values(self) -> ServerDebugInfo:
@_precheck
def get_motd(self) -> ServerMOTD:
"""
Gives out a `ServerMOTD` object containing the server's MOTD in different string types (clean, raw, HTML).
Returns a `ServerMOTD` object.
It contains the server's "Message Of The Day" in three string types.
Exceptions:
`DataNotFoundError` - If the MOTD of the server is not found.
`DataNotFoundError` - If an MOTD is not found.
"""

try:
Expand All @@ -225,7 +226,7 @@ def get_motd(self) -> ServerMOTD:
@_precheck
def get_player(self, name: str) -> Player:
"""
Gives out a `Player` object representing a player currently playing on the Minecraft server.
Returns a `Player` object representing a player currently playing on the Minecraft server.
Parameters:
`player_name: str` - The name of the player you wish to fetch.
Expand Down Expand Up @@ -256,7 +257,7 @@ def get_players(self) -> Optional[List[Player]]:
@_precheck
def get_player_count(self) -> PlayerCount:
"""
Gives out a `PlayerCount` object, representing the active player count of the Minecraft server.
Returns a `PlayerCount` object, representing the active player count of the Minecraft server.
Exceptions:
`DataNotFoundError` - If the player count data is not found.
Expand Down Expand Up @@ -294,7 +295,7 @@ def get_mods(self) -> Optional[List[ServerMod]]:
@_precheck
def get_info(self) -> ServerInfo:
"""
Gives out a `ServerInfo` object containing the server's base information (if any).
Returns a `ServerInfo` object containing the server's base information (if any).
Exceptions:
`DataNotFoundError` - If the server information data is not found.
Expand Down

0 comments on commit 40eeea0

Please sign in to comment.