diff --git a/app/classes/shared/import_helper.py b/app/classes/shared/import_helper.py
index 769ebc3a..b5f8d193 100644
--- a/app/classes/shared/import_helper.py
+++ b/app/classes/shared/import_helper.py
@@ -3,6 +3,7 @@ import time
import shutil
import logging
import threading
+import urllib
from app.classes.controllers.server_perms_controller import PermissionsServers
from app.classes.controllers.servers_controller import ServersController
@@ -214,3 +215,36 @@ class ImportHelpers:
os.chmod(full_jar_path, 0o2760)
# deletes temp dir
FileHelpers.del_dirs(temp_dir)
+
+ def download_bedrock_server(self, path, new_id):
+ download_thread = threading.Thread(
+ target=self.download_threaded_bedrock_server,
+ daemon=True,
+ args=(path, new_id),
+ name=f"{new_id}_download",
+ )
+ download_thread.start()
+
+ def download_threaded_bedrock_server(self, path, new_id):
+ # downloads zip from remote url
+ bedrock_url = Helpers.get_latest_bedrock_url()
+ if bedrock_url.lower().startswith("https"):
+ urllib.request.urlretrieve(
+ bedrock_url,
+ os.path.join(path, "bedrock_server.zip"),
+ )
+
+ unzip_path = os.path.join(path, "bedrock_server.zip")
+ unzip_path = self.helper.wtol_path(unzip_path)
+ # unzips archive that was downloaded.
+ FileHelpers.unzip_file(unzip_path)
+ # adjusts permissions for execution if os is not windows
+ if not self.helper.is_os_windows():
+ os.chmod(os.path.join(path, "bedrock_server"), 0o0744)
+
+ # we'll delete the zip we downloaded now
+ os.remove(os.path.join(path, "bedrock_server.zip"))
+ ServersController.finish_import(new_id)
+ server_users = PermissionsServers.get_server_user_list(new_id)
+ for user in server_users:
+ self.helper.websocket_helper.broadcast_user(user, "send_start_reload", {})
diff --git a/app/classes/shared/main_controller.py b/app/classes/shared/main_controller.py
index cfda4c8d..68645b86 100644
--- a/app/classes/shared/main_controller.py
+++ b/app/classes/shared/main_controller.py
@@ -697,6 +697,49 @@ class Controller:
)
return new_id
+ def create_bedrock_server(self, server_name, user_id):
+ server_id = Helpers.create_uuid()
+ new_server_dir = os.path.join(self.helper.servers_dir, server_id)
+ backup_path = os.path.join(self.helper.backup_path, server_id)
+ server_exe = "bedrock_server"
+ if Helpers.is_os_windows():
+ # if this is windows we will override the linux bedrock server name.
+ server_exe = "bedrock_server.exe"
+ new_server_dir = Helpers.wtol_path(new_server_dir)
+ backup_path = Helpers.wtol_path(backup_path)
+ new_server_dir.replace(" ", "^ ")
+ backup_path.replace(" ", "^ ")
+
+ Helpers.ensure_dir_exists(new_server_dir)
+ Helpers.ensure_dir_exists(backup_path)
+
+ full_jar_path = os.path.join(new_server_dir, server_exe)
+
+ if Helpers.is_os_windows():
+ server_command = f'"{full_jar_path}"'
+ else:
+ server_command = f"./{server_exe}"
+ logger.debug("command: " + server_command)
+ server_log_file = ""
+ server_stop = "stop"
+
+ new_id = self.register_server(
+ server_name,
+ server_id,
+ new_server_dir,
+ backup_path,
+ server_command,
+ server_exe,
+ server_log_file,
+ server_stop,
+ "19132",
+ user_id,
+ server_type="minecraft-bedrock",
+ )
+ ServersController.set_import(new_id)
+ self.import_helper.download_bedrock_server(new_server_dir, new_id)
+ return new_id
+
def import_bedrock_zip_server(
self,
server_name: str,
diff --git a/app/classes/shared/server.py b/app/classes/shared/server.py
index bd8d29f6..2a80965b 100644
--- a/app/classes/shared/server.py
+++ b/app/classes/shared/server.py
@@ -338,7 +338,7 @@ class ServerInstance:
"eula =true",
]
- if not e_flag:
+ if not e_flag and self.settings["type"] == "minecraft-java":
if user_id:
self.helper.websocket_helper.broadcast_user(
user_id, "send_eula_bootbox", {"id": self.server_id}
diff --git a/app/classes/web/server_handler.py b/app/classes/web/server_handler.py
index c13198ed..1c1d6fc6 100644
--- a/app/classes/web/server_handler.py
+++ b/app/classes/web/server_handler.py
@@ -97,6 +97,7 @@ class ServerHandler(BaseHandler):
"version_data": self.helper.get_version_string(),
"user_data": exec_user,
"user_role": exec_user_role,
+ "online": Helpers.check_internet(),
"roles": list_roles,
"super_user": exec_user["superuser"],
"user_crafty_permissions": exec_user_crafty_permissions,
@@ -173,7 +174,6 @@ class ServerHandler(BaseHandler):
)
return
- page_data["online"] = Helpers.check_internet()
page_data["server_types"] = self.controller.server_jars.get_serverjar_data()
page_data["js_server_types"] = json.dumps(
self.controller.server_jars.get_serverjar_data()
@@ -548,25 +548,14 @@ class ServerHandler(BaseHandler):
self.get_remote_ip(),
)
else:
- if len(server_parts) != 2:
- self.redirect("/panel/error?error=Invalid server data")
- return
- server_type, server_version = server_parts
- # TODO: add server type check here and call the correct server
- # add functions if not a jar
- new_server_id = self.controller.create_jar_server(
- server_type,
- server_version,
+
+ new_server_id = self.controller.create_bedrock_server(
server_name,
- min_mem,
- max_mem,
- port,
exec_user["user_id"],
)
self.controller.management.add_to_audit_log(
exec_user["user_id"],
- f"created a {server_version} {str(server_type).capitalize()} "
- f'server named "{server_name}"',
+ "created a Bedrock " f'server named "{server_name}"',
# Example: Admin created a 1.16.5 Bukkit server named "survival"
new_server_id,
self.get_remote_ip(),
diff --git a/app/frontend/templates/base.html b/app/frontend/templates/base.html
index 1ab50da8..bfe530b9 100755
--- a/app/frontend/templates/base.html
+++ b/app/frontend/templates/base.html
@@ -378,7 +378,7 @@
}
bootbox.confirm({
title: "{% raw translate('error', 'eulaTitle', data['lang']) %}",
- message: "{% raw translate('error', 'eulaMsg', data['lang']) %}
EULA
{% raw translate('error', 'eulaAgree', data['lang']) %}",
+ message: "{% raw translate('error', 'eulaMsg', data['lang']) %}
EULA
{% raw translate('error', 'eulaAgree', data['lang']) %}",
buttons: {
confirm: {
label: 'Yes',
diff --git a/app/frontend/templates/server/bedrock_wizard.html b/app/frontend/templates/server/bedrock_wizard.html
index 42ab590c..465a9e10 100644
--- a/app/frontend/templates/server/bedrock_wizard.html
+++ b/app/frontend/templates/server/bedrock_wizard.html
@@ -7,445 +7,575 @@
- -