mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-17 21:40:31 +00:00
[+] Modded patch pre-0.7
This commit is contained in:
parent
07696572aa
commit
8ae3760b0b
@ -180,7 +180,7 @@ def account_delete(user: UserRecord) -> tuple[HTTPStatus, Union[str, None]]:
|
|||||||
return HTTPStatus.INTERNAL_SERVER_ERROR, f"Error deleting user '{user_id}' on the server."
|
return HTTPStatus.INTERNAL_SERVER_ERROR, f"Error deleting user '{user_id}' on the server."
|
||||||
|
|
||||||
|
|
||||||
allowed_frameworks: list[str] = ["paper", "spigot", "bukkit"]
|
allowed_frameworks: list[str] = ["bukkit", "fabric", "forge", "spigot", "paper"]
|
||||||
|
|
||||||
def server_create(user: UserRecord, name: str, version: str, framework: str = "paper") -> (
|
def server_create(user: UserRecord, name: str, version: str, framework: str = "paper") -> (
|
||||||
tuple)[HTTPStatus, Union[str, None]]:
|
tuple)[HTTPStatus, Union[str, None]]:
|
||||||
@ -237,11 +237,16 @@ def server_run(user: UserRecord, name: str) -> tuple[HTTPStatus, Union[str, None
|
|||||||
try:
|
try:
|
||||||
port: int = firebase_manager.get_server_port(user_id)
|
port: int = firebase_manager.get_server_port(user_id)
|
||||||
version: str = firebase_manager.get_server_field(user_id, name, "version")
|
version: str = firebase_manager.get_server_field(user_id, name, "version")
|
||||||
if version is None:
|
framework: str = firebase_manager.get_server_field(user_id, name, "framework")
|
||||||
|
if version is None or framework is None:
|
||||||
return HTTPStatus.NOT_FOUND, f"Server {name} not found."
|
return HTTPStatus.NOT_FOUND, f"Server {name} not found."
|
||||||
server_id = mc_manager.start_server(f"users/{user_id}/{name}", port, user_id, name, version)
|
if (framework == "forge") or (framework == "fabric"):
|
||||||
|
server_id = mc_manager.start_server(f"users/{user_id}/{name}", port, user_id,
|
||||||
|
name, version, modded=True)
|
||||||
|
else:
|
||||||
|
server_id = mc_manager.start_server(f"users/{user_id}/{name}", port, user_id, name, version)
|
||||||
if server_id is None:
|
if server_id is None:
|
||||||
return HTTPStatus.OK, f"You cannot run multiples instances at this time."
|
return HTTPStatus.OK, f"You cannot run multiples instances at this time."
|
||||||
try:
|
try:
|
||||||
firebase_manager.update_server_running_state(user_id, name, True)
|
firebase_manager.update_server_running_state(user_id, name, True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -21,7 +21,7 @@ class MinecraftServerManager:
|
|||||||
self.offline_ports: list[int] = []
|
self.offline_ports: list[int] = []
|
||||||
|
|
||||||
def start_server(self, server_directory: str, port: int, user_id: str, server_name: str,
|
def start_server(self, server_directory: str, port: int, user_id: str, server_name: str,
|
||||||
version: str, jar_file='server.jar', memory_size='4G') -> Union[int, None]:
|
version: str, jar_file: str = 'server.jar', memory_size: str ='4G', modded: bool = False) -> Union[int, None]:
|
||||||
|
|
||||||
if port in self.servers:
|
if port in self.servers:
|
||||||
return None
|
return None
|
||||||
@ -38,6 +38,8 @@ class MinecraftServerManager:
|
|||||||
java: str = f"/usr/lib/jvm/java-{get_sdk_version(version)}-openjdk/bin/java"
|
java: str = f"/usr/lib/jvm/java-{get_sdk_version(version)}-openjdk/bin/java"
|
||||||
|
|
||||||
command = f"{java} -Xmx{memory_size} {reg_flags} -jar {jar_file} --nogui"
|
command = f"{java} -Xmx{memory_size} {reg_flags} -jar {jar_file} --nogui"
|
||||||
|
if modded:
|
||||||
|
command = "./start.sh"
|
||||||
process = subprocess.Popen(shlex.split(command), cwd=server_directory, stdin=subprocess.PIPE)
|
process = subprocess.Popen(shlex.split(command), cwd=server_directory, stdin=subprocess.PIPE)
|
||||||
#TODO: Track process behavior and stderr, while excepting Advanced Terminal features not to be avail.
|
#TODO: Track process behavior and stderr, while excepting Advanced Terminal features not to be avail.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user