mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Merge branch 'tweak/java-check' into 'dev'
Forge installer and Java Detection improvements See merge request crafty-controller/crafty-4!559
This commit is contained in:
commit
6b7658b4e4
@ -16,6 +16,7 @@
|
||||
- Optimize file upload progress WS ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/546))
|
||||
- Truncate sidebar servers to a max of 10 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/552))
|
||||
- Upgrade to FA 6. Add Translations ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/549))([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/558))
|
||||
- Forge installer and Java Detection improvements ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/559))
|
||||
### Lang
|
||||
- Add additional translations to backups page strings ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/543))
|
||||
- Add additional missing translations ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/549))
|
||||
|
@ -15,6 +15,7 @@ import html
|
||||
import zipfile
|
||||
import pathlib
|
||||
import ctypes
|
||||
import shutil
|
||||
import subprocess
|
||||
import itertools
|
||||
from datetime import datetime
|
||||
@ -145,6 +146,22 @@ class Helpers:
|
||||
logger.error(f"Unable to resolve remote bedrock download url! \n{e}")
|
||||
return False
|
||||
|
||||
def detect_java(self):
|
||||
if len(self.find_java_installs()) > 0:
|
||||
return True
|
||||
|
||||
# We'll use this as a fallback for systems
|
||||
# That do not properly setup reg keys or
|
||||
# Update alternatives
|
||||
if self.is_os_windows():
|
||||
if shutil.which("java.exe"):
|
||||
return True
|
||||
else:
|
||||
if shutil.which("java"):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def find_java_installs():
|
||||
# If we're windows return oracle java versions,
|
||||
|
@ -447,7 +447,7 @@ class ServerInstance:
|
||||
)
|
||||
except Exception as ex:
|
||||
# Checks for java on initial fail
|
||||
if os.system("java -version") == 32512:
|
||||
if not self.helper.detect_java():
|
||||
if user_id:
|
||||
self.helper.websocket_helper.broadcast_user(
|
||||
user_id,
|
||||
|
@ -404,6 +404,14 @@ class ServerHandler(BaseHandler):
|
||||
jar_type, server_type, server_version = server_parts
|
||||
# TODO: add server type check here and call the correct server
|
||||
# add functions if not a jar
|
||||
if server_type == "forge" and not self.helper.detect_java():
|
||||
translation = self.helper.translation.translate(
|
||||
"error",
|
||||
"installerJava",
|
||||
self.controller.users.get_user_lang_by_id(exec_user["user_id"]),
|
||||
).format(server_name)
|
||||
self.redirect(f"/panel/error?error={translation}")
|
||||
return
|
||||
new_server_id = self.controller.create_jar_server(
|
||||
jar_type,
|
||||
server_type,
|
||||
|
@ -179,6 +179,7 @@
|
||||
"internet": "We have detected the machine running Crafty has no connection to the internet. Client connections to the server may be limited.",
|
||||
"no-file": "We can't seem to locate the requested file. Double check the path. Does Crafty have proper permissions?",
|
||||
"noJava": "Server {} failed to start with error code: We have detected Java is not installed. Please install java then start the server.",
|
||||
"installerJava": "Failed to install {} : Forge Server Installs require Java. We have detected Java is not installed. Please install java then install the server.",
|
||||
"not-downloaded": "We can't seem to find your executable file. Has it finished downloading? Are the permissions set to executable?",
|
||||
"portReminder": "We have detected this is the first time {} has been run. Make sure to forward port {} through your router/firewall to make this remotely accessible from the internet.",
|
||||
"start-error": "Server {} failed to start with error code: {}",
|
||||
|
Loading…
Reference in New Issue
Block a user