mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-17 21:40:31 +00:00
[+] get_online_players function.
[+] mcipc implementation
This commit is contained in:
parent
49a5e04a1c
commit
37dc160a12
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user