Fixed: nullable patches

This commit is contained in:
Reider745
2025-03-21 06:14:27 +03:00
parent d2c38029c3
commit 6b0cc0862f
@@ -37,7 +37,13 @@ public class PatchPreLoader {
} }
public void init() { public void init() {
for(File patch : Objects.requireNonNull(patches.listFiles((dir, name) -> name.endsWith(".jar")))) { if(!patches.exists() && !patches.mkdir()) {
return;
}
final File[] files = patches.listFiles((dir, name) -> name.endsWith(".jar"));
if(files != null) {
for (File patch : files) {
try { try {
final URLClassLoader mainLoader = new URLClassLoader(new URL[]{patch.toURL()}); final URLClassLoader mainLoader = new URLClassLoader(new URL[]{patch.toURL()});
final JSONObject description = new JSONObject(new String(mainLoader.getResourceAsStream("patch.json").readAllBytes())); final JSONObject description = new JSONObject(new String(mainLoader.getResourceAsStream("patch.json").readAllBytes()));
@@ -61,3 +67,4 @@ public class PatchPreLoader {
} }
} }
} }
}