mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-18 05:50: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 subprocess
|
||||||
import shlex
|
import shlex
|
||||||
import time
|
import time
|
||||||
|
import mcipc.query
|
||||||
|
import mcipc.query.client
|
||||||
|
|
||||||
|
|
||||||
class MinecraftServerManager:
|
class MinecraftServerManager:
|
||||||
@ -62,6 +64,12 @@ class MinecraftServerManager:
|
|||||||
return server_id
|
return server_id
|
||||||
return None
|
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):
|
def set_cooldown(self, user_id):
|
||||||
expiry_timestamp = time.time() + 30
|
expiry_timestamp = time.time() + 30
|
||||||
self.cooldowns[user_id] = expiry_timestamp
|
self.cooldowns[user_id] = expiry_timestamp
|
||||||
|
Loading…
Reference in New Issue
Block a user