fix jij loading
All checks were successful
Publish to snapshot maven / build (push) Successful in 22s

This commit is contained in:
moehreag 2024-08-27 20:28:20 +02:00
parent 400b892014
commit f32d237a2d
4 changed files with 16 additions and 20 deletions

View file

@ -7,7 +7,7 @@ plugins {
} }
group = "dev.frogmc" group = "dev.frogmc"
version = "0.0.1-alpha.23" version = "0.0.1-alpha.24"
repositories { repositories {
maven { maven {

View file

@ -1,6 +1,6 @@
plugins { plugins {
java java
id("dev.frogmc.phytotelma") version "0.0.1-alpha.18" id("dev.frogmc.phytotelma") version "0.0.1-alpha.19"
} }
dependencies { dependencies {

View file

@ -66,13 +66,11 @@ public class ModUtil {
private static Map<ModProperties, Collection<String>> getParentMods(Collection<ModProperties> mods) { private static Map<ModProperties, Collection<String>> getParentMods(Collection<ModProperties> mods) {
Map<ModProperties, Collection<String>> children = new HashMap<>(); Map<ModProperties, Collection<String>> children = new HashMap<>();
for (ModProperties mod : mods) { for (ModProperties mod : mods) {
List<List<UnmodifiableConfig>> entries = mod.extensions().get(BuiltinExtensions.INCLUDED_JARS); List<UnmodifiableConfig> entries = mod.extensions().get(BuiltinExtensions.INCLUDED_JARS);
if (entries != null) { if (entries != null) {
for (var jars : entries) { for (var jar : entries) {
for (var jar : jars) { String id = jar.get("id");
String id = jar.get("id"); children.computeIfAbsent(mod, m -> new HashSet<>()).add(id);
children.computeIfAbsent(mod, m -> new HashSet<>()).add(id);
}
} }
} else { } else {
children.putIfAbsent(mod, Collections.emptySet()); children.putIfAbsent(mod, Collections.emptySet());

View file

@ -82,7 +82,7 @@ public class FrogModProvider implements ModProvider {
return loadedMods; return loadedMods;
} }
private Path getJijCacheDir(){ private Path getJijCacheDir() {
Path dir = FrogLoader.getInstance().getGameDir().resolve(".frogmc").resolve("jijcache"); Path dir = FrogLoader.getInstance().getGameDir().resolve(".frogmc").resolve("jijcache");
Runtime.getRuntime().addShutdownHook(new Thread(() -> { Runtime.getRuntime().addShutdownHook(new Thread(() -> {
@ -115,22 +115,20 @@ public class FrogModProvider implements ModProvider {
if (opt.isPresent()) { if (opt.isPresent()) {
ModProperties p = opt.get(); ModProperties p = opt.get();
modPaths.put(mod, p); modPaths.put(mod, p);
List<List<UnmodifiableConfig>> entries = p.extensions().getOrDefault(BuiltinExtensions.INCLUDED_JARS, Collections.emptyList()); List<UnmodifiableConfig> entries = p.extensions().getOrDefault(BuiltinExtensions.INCLUDED_JARS, Collections.emptyList());
if (entries.isEmpty()) { if (entries.isEmpty()) {
return; return;
} }
try (FileSystem fs = FileSystems.newFileSystem(mod)) { try (FileSystem fs = FileSystems.newFileSystem(mod)) {
for (List<UnmodifiableConfig> jars : entries) { for (UnmodifiableConfig jar : entries) {
for (UnmodifiableConfig jar : jars) { Path path = fs.getPath(jar.get("path")).toAbsolutePath();
Path path = fs.getPath(jar.get("path")).toAbsolutePath(); Path extracted = jijCache.resolve((String) jar.get("id"));
Path extracted = jijCache.resolve((String) jar.get("id")); if (!Files.exists(extracted)) {
if (!Files.exists(extracted)){ Files.createDirectories(jijCache);
Files.createDirectories(jijCache); Files.copy(path, extracted);
Files.copy(path, extracted);
}
mods.add(extracted);
findJiJMods(extracted, mods, modPaths, jijCache);
} }
mods.add(extracted);
findJiJMods(extracted, mods, modPaths, jijCache);
} }
} }
} }