[+] Minor fixes

This commit is contained in:
Charles Le Maux 2024-08-11 11:02:10 +02:00
parent 34aa9217cd
commit ef2aa65173
2 changed files with 13 additions and 4 deletions

View File

@ -64,8 +64,8 @@ class MinecraftServerManager:
if server_info['port'] == port: if server_info['port'] == port:
return server_id return server_id
return None return None
def get_online_players(self, port)->int: def get_online_players(self, port) -> int:
with mcipc.query.Client('127.0.0.1', port) as client: with mcipc.query.Client('127.0.0.1', port) as client:
stats: mcipc.query.proto.FullStats = client.stats(full=True) stats: mcipc.query.proto.FullStats = client.stats(full=True)
stats: int = stats.num_players stats: int = stats.num_players
@ -85,7 +85,7 @@ class MinecraftServerManager:
else: else:
del self.cooldowns[user_id] del self.cooldowns[user_id]
return False return False
if __name__ == "__main__": if __name__ == "__main__":
pass pass

View File

@ -1,4 +1,5 @@
import firebase_manager import firebase_manager
from mcipc.query import Client
def ban_user(user_id: str): def ban_user(user_id: str):
@ -9,5 +10,13 @@ def ban_user(user_id: str):
print("Error banning user "+user_id, "|", str(e), type(e).__name__) print("Error banning user "+user_id, "|", str(e), type(e).__name__)
def get_online_players(port) -> int:
with Client('127.0.0.1', port) as client:
stats: mcipc.query.proto.FullStats = client.stats(full=True)
stats: int = stats.num_players
return stats
if __name__ == '__main__': if __name__ == '__main__':
ban_user("MpkbDMOO8PQddQgB5VgBQdTMWF53") #ban_user("MpkbDMOO8PQddQgB5VgBQdTMWF53")
get_online_players(25565)