2024-06-14 21:33:55 +00:00
|
|
|
from server_mc_manager import MinecraftServerManager
|
|
|
|
import file_manager
|
|
|
|
|
|
|
|
mc_manager: MinecraftServerManager = MinecraftServerManager()
|
|
|
|
|
2024-06-15 04:18:57 +00:00
|
|
|
def AccountCreate(port : str) -> bool:
|
2024-06-14 21:33:55 +00:00
|
|
|
file_manager.create_folder("users/"+port)
|
|
|
|
|
2024-06-15 04:18:57 +00:00
|
|
|
def ServerCreate(port : str, name : str, version : str) -> bool:
|
2024-06-14 21:33:55 +00:00
|
|
|
server_path: str = f"users/{port}/{name}"
|
2024-06-15 04:18:57 +00:00
|
|
|
server_template_path: str = "servers/paper/"+version
|
2024-06-14 21:33:55 +00:00
|
|
|
file_manager.create_folder(server_path)
|
|
|
|
file_manager.copy_folder_contents(server_template_path, server_path)
|
2024-06-15 04:18:57 +00:00
|
|
|
file_manager.copy_folder_contents("servers/shared", server_path)
|
2024-06-14 21:33:55 +00:00
|
|
|
file_manager.update_server_property(server_path+"/server.properties", "server-port", port)
|
|
|
|
|
2024-06-15 04:18:57 +00:00
|
|
|
def ServerDelete(port : str, name : str) -> bool:
|
2024-06-14 21:33:55 +00:00
|
|
|
server_path: str = f"users/{port}/{name}"
|
|
|
|
file_manager.delete_non_empty_folder(server_path)
|
|
|
|
|
2024-06-15 04:18:57 +00:00
|
|
|
def AccountDelete(port : str) -> bool:
|
2024-06-14 21:33:55 +00:00
|
|
|
file_manager.delete_non_empty_folder("users/"+port)
|
|
|
|
|
2024-06-15 04:18:57 +00:00
|
|
|
def ServerRun(port : str, name : str) -> bool:
|
2024-06-14 21:33:55 +00:00
|
|
|
server_id = mc_manager.start_server(f"users/{port}/{name}")
|
|
|
|
mc_manager.servers[server_id]['port'] = int(port)
|
|
|
|
|
2024-06-15 04:18:57 +00:00
|
|
|
def ServerStop(port : str, name : str) -> bool:
|
2024-06-14 21:33:55 +00:00
|
|
|
server_id = mc_manager.get_server_id_by_port(int(port))
|
|
|
|
mc_manager.stop_server(server_id)
|
|
|
|
|
2024-06-15 04:18:57 +00:00
|
|
|
def UpdateProperty(port : str, name : str, prop : str, value : str) -> bool:
|
2024-06-14 21:33:55 +00:00
|
|
|
property_file_path: str = f"users/{port}/{name}/server.properties"
|
|
|
|
file_manager.update_server_property(property_file_path, prop, value)
|
|
|
|
|
2024-06-15 04:18:57 +00:00
|
|
|
def RunCommand(port : str, command : str) -> bool:
|
2024-06-14 21:33:55 +00:00
|
|
|
server_id = mc_manager.get_server_id_by_port(int(port))
|
|
|
|
mc_manager.execute_server_command(server_id, command)
|