|
34 | 34 | import java.util.Map; |
35 | 35 | import java.util.Set; |
36 | 36 |
|
| 37 | +import mjson.Json; |
| 38 | + |
37 | 39 | import net.fabricmc.api.EnvType; |
38 | 40 | import net.fabricmc.loader.api.ObjectShare; |
39 | 41 | import net.fabricmc.loader.api.VersionParsingException; |
@@ -338,7 +340,7 @@ public void initialize(FabricLauncher launcher) { |
338 | 340 |
|
339 | 341 | Log.debug(LogCategory.GAME_PROVIDER, "namespace detection result: game=%s runtime=%s mod-default=%s", gameNs, runtimeNs, config.getDefaultModDistributionNamespace()); |
340 | 342 |
|
341 | | - if (!gameNs.equals(runtimeNs)) { // game is obfuscated / in another namespace -> remap |
| 343 | + if (isObfuscated()) { // game is obfuscated / in another namespace -> remap |
342 | 344 | Map<String, Path> obfJars = new HashMap<>(3); |
343 | 345 | String[] names = new String[gameJars.size()]; |
344 | 346 |
|
@@ -460,6 +462,10 @@ public GameTransformer getEntrypointTransformer() { |
460 | 462 | return transformer; |
461 | 463 | } |
462 | 464 |
|
| 465 | + public boolean isObfuscated() { |
| 466 | + return false; // generally no... |
| 467 | + } |
| 468 | + |
463 | 469 | @Override |
464 | 470 | public boolean canOpenErrorGui() { |
465 | 471 | if (arguments == null || envType == EnvType.CLIENT) { |
@@ -491,6 +497,32 @@ public void unlockClassPath(FabricLauncher launcher) { |
491 | 497 | for (Path lib : miscGameLibraries) { |
492 | 498 | launcher.addToClassPath(lib); |
493 | 499 | } |
| 500 | + Set<Path> loadedPaths = new HashSet<>(); |
| 501 | + Json.read(System.getProperty("banner.libraries")).asJsonList().stream() |
| 502 | + .map(Json::asString) |
| 503 | + .map(Paths::get) |
| 504 | + .filter(path -> { |
| 505 | + String fileName = path.getFileName().toString().toLowerCase(); |
| 506 | + return !fileName.contains("asm") |
| 507 | + && !fileName.matches("asm-\\d+\\.jar"); |
| 508 | + }) |
| 509 | + .filter(path -> { |
| 510 | + try { |
| 511 | + Path absPath = path.toAbsolutePath(); |
| 512 | + return !loadedPaths.contains(absPath); |
| 513 | + } catch (Exception e) { |
| 514 | + throw new RuntimeException(e); |
| 515 | + } |
| 516 | + }) |
| 517 | + .forEach(path -> { |
| 518 | + try { |
| 519 | + Path absPath = path.toAbsolutePath(); |
| 520 | + launcher.addToClassPath(path); |
| 521 | + loadedPaths.add(absPath); |
| 522 | + } catch (Exception e) { |
| 523 | + throw new RuntimeException(e); |
| 524 | + } |
| 525 | + }); |
494 | 526 | } |
495 | 527 |
|
496 | 528 | @Override |
|
0 commit comments