1
0
mirror of https://github.com/SKCraft/Launcher.git synced 2024-11-30 13:13:58 +01:00

Handle the presence of non-JAR files in plugins directory

This commit is contained in:
Henry Le Grys 2021-03-29 13:55:49 +01:00
parent b7178a10b6
commit 966205d68a
2 changed files with 11 additions and 1 deletions

View File

@ -51,6 +51,7 @@ public class Creator {
}
} catch (IOException e) {
log.severe("Could not walk plugin directory, plugins have not been loaded");
e.printStackTrace();
}
this.plugins = pluginLoader.loadAll();

View File

@ -18,6 +18,7 @@ import java.util.List;
import java.util.jar.JarFile;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
@Log
public class CreatorPluginLoader extends DirectoryWalker {
@ -26,7 +27,13 @@ public class CreatorPluginLoader extends DirectoryWalker {
@Override
protected void onFile(File file, String relPath) throws IOException {
JarFile jarFile = new JarFile(file);
JarFile jarFile;
try {
jarFile = new JarFile(file);
} catch (ZipException e) {
log.warning(String.format("Found a non-JAR file %s in plugins directory", file));
return;
}
ZipEntry metaEntry = jarFile.getEntry("skcraftcreator.plugin.json");
if (metaEntry != null) {
@ -36,6 +43,8 @@ public class CreatorPluginLoader extends DirectoryWalker {
log.info("Found plugin " + pluginInfo.getId());
candidates.add(new PluginCandidate(pluginInfo, file.toURI().toURL()));
} else {
log.warning(String.format("Found a non-plugin JAR file: %s", file));
}
}