|
5 | 5 | import com.google.gson.*; |
6 | 6 | import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; |
7 | 7 | import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; |
| 8 | +import org.apache.commons.lang3.SystemUtils; |
8 | 9 | import org.apache.logging.log4j.LogManager; |
9 | 10 | import org.apache.logging.log4j.Logger; |
10 | 11 | import org.embeddedt.modernfix.annotation.ClientOnlyMixin; |
|
21 | 22 | import java.io.*; |
22 | 23 | import java.net.URL; |
23 | 24 | import java.nio.charset.StandardCharsets; |
| 25 | +import java.nio.file.Files; |
| 26 | +import java.nio.file.Path; |
| 27 | +import java.nio.file.Paths; |
24 | 28 | import java.util.*; |
25 | 29 | import java.util.function.BooleanSupplier; |
26 | 30 | import java.util.regex.Pattern; |
@@ -313,6 +317,32 @@ private void readJVMProperties() { |
313 | 317 | } |
314 | 318 | } |
315 | 319 |
|
| 320 | + private void readGlobalProperties() { |
| 321 | + Path minecraftFolder; |
| 322 | + if (SystemUtils.IS_OS_MAC) { |
| 323 | + minecraftFolder = Paths.get(System.getProperty("user.home"), "Library", "Application Support", "minecraft"); |
| 324 | + } else if (SystemUtils.IS_OS_WINDOWS) { |
| 325 | + minecraftFolder = Paths.get(System.getenv("APPDATA"), ".minecraft"); |
| 326 | + } else { |
| 327 | + minecraftFolder = Paths.get(System.getProperty("user.home"), ".minecraft"); |
| 328 | + } |
| 329 | + Path globalPropsFile = minecraftFolder.resolve("global").resolve("modernfix-global-mixins.properties"); |
| 330 | + try { |
| 331 | + if (Files.exists(globalPropsFile)) { |
| 332 | + Properties properties = new Properties(); |
| 333 | + try (var is = Files.newInputStream(globalPropsFile)) { |
| 334 | + properties.load(is); |
| 335 | + } |
| 336 | + if (!properties.isEmpty()) { |
| 337 | + LOGGER.info("Global properties specified: [{}]", properties.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining(", "))); |
| 338 | + readProperties(properties); |
| 339 | + } |
| 340 | + } |
| 341 | + } catch (Exception e) { |
| 342 | + LOGGER.error("Error reading global properties file", e); |
| 343 | + } |
| 344 | + } |
| 345 | + |
316 | 346 | private void readProperties(Properties props) { |
317 | 347 | if(ALLOW_OVERRIDE_OVERRIDES) |
318 | 348 | LOGGER.fatal("JVM argument given to override mod overrides. Issues opened with this option present will be ignored unless they can be reproduced without."); |
@@ -402,6 +432,7 @@ public static ModernFixEarlyConfig load(File file) { |
402 | 432 | LOGGER.warn("Could not write configuration file", e); |
403 | 433 | } |
404 | 434 |
|
| 435 | + config.readGlobalProperties(); |
405 | 436 | config.readJVMProperties(); |
406 | 437 | } |
407 | 438 |
|
|
0 commit comments