[+] get_online_players function.

[+] mcipc implementation
This commit is contained in:
Charles Le Maux 2024-07-14 22:05:32 +02:00
parent 49a5e04a1c
commit 37dc160a12

View File

@ -1,6 +1,8 @@
import subprocess
import shlex
import time
import mcipc.query
import mcipc.query.client
class MinecraftServerManager:
@ -62,6 +64,12 @@ class MinecraftServerManager:
return server_id
return None
def get_online_players(self, port)->int:
with mcipc.query.Client('127.0.0.1', port) as client:
stats: mcipc.query.proto.FullStats = client.stats(full=True)
stats: int = stats.num_players
return stats
def set_cooldown(self, user_id):
expiry_timestamp = time.time() + 30
self.cooldowns[user_id] = expiry_timestamp