Skip to content

Commit c070b91

Browse files
committed
Use settings.get_settings() instead of deprecated Utils.get_options()
Resolves upstream ArchipelagoMW#4811
1 parent 5a89afd commit c070b91

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

MinecraftClient.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import Utils
1616
from Utils import is_windows
17+
from settings import get_settings
1718

1819
atexit.register(input, "Press enter to exit.")
1920

@@ -147,9 +148,11 @@ def find_jdk(version: str) -> str:
147148
if os.path.isfile(jdk_exe):
148149
return jdk_exe
149150
else:
150-
jdk_exe = shutil.which(options["minecraft_options"].get("java", "java"))
151+
jdk_exe = shutil.which(options.java)
151152
if not jdk_exe:
152-
raise Exception("Could not find Java. Is Java installed on the system?")
153+
jdk_exe = shutil.which("java") # try to fall back to system java
154+
if not jdk_exe:
155+
raise Exception("Could not find Java. Is Java installed on the system?")
153156
return jdk_exe
154157

155158

@@ -285,8 +288,8 @@ def is_correct_forge(forge_dir) -> bool:
285288
# Change to executable's working directory
286289
os.chdir(os.path.abspath(os.path.dirname(sys.argv[0])))
287290

288-
options = Utils.get_options()
289-
channel = args.channel or options["minecraft_options"]["release_channel"]
291+
options = get_settings().minecraft_options
292+
channel = args.channel or options.release_channel
290293
apmc_data = None
291294
data_version = args.data_version or None
292295

@@ -299,8 +302,8 @@ def is_correct_forge(forge_dir) -> bool:
299302

300303
versions = get_minecraft_versions(data_version, channel)
301304

302-
forge_dir = options["minecraft_options"]["forge_directory"]
303-
max_heap = options["minecraft_options"]["max_heap_size"]
305+
forge_dir = options.forge_directory
306+
max_heap = options.max_heap_size
304307
forge_version = args.forge or versions["forge"]
305308
java_version = args.java or versions["java"]
306309
mod_url = versions["url"]

worlds/minecraft/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,15 @@ class ReleaseChannel(str):
2727
any games played on the "beta" channel have a high likelihood of no longer working on the "release" channel.
2828
"""
2929

30-
forge_directory: ForgeDirectory = ForgeDirectory("Minecraft Forge server")
30+
class JavaExecutable(settings.OptionalUserFilePath):
31+
"""
32+
Path to Java executable. If not set, will attempt to fall back to Java system installation.
33+
"""
34+
35+
forge_directory: ForgeDirectory = ForgeDirectory("Minecraft NeoForge server")
3136
max_heap_size: str = "2G"
3237
release_channel: ReleaseChannel = ReleaseChannel("release")
38+
java: JavaExecutable = JavaExecutable("")
3339

3440

3541
class MinecraftWebWorld(WebWorld):

0 commit comments

Comments
 (0)