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