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"
version = "0.0.1-alpha.23"
version = "0.0.1-alpha.24"
repositories {
maven {

View file

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

View file

@ -66,13 +66,11 @@ public class ModUtil {
private static Map<ModProperties, Collection<String>> getParentMods(Collection<ModProperties> mods) {
Map<ModProperties, Collection<String>> children = new HashMap<>();
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) {
for (var jars : entries) {
for (var jar : jars) {
String id = jar.get("id");
children.computeIfAbsent(mod, m -> new HashSet<>()).add(id);
}
for (var jar : entries) {
String id = jar.get("id");
children.computeIfAbsent(mod, m -> new HashSet<>()).add(id);
}
} else {
children.putIfAbsent(mod, Collections.emptySet());

View file

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