Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
- fixed error reporting
  • Loading branch information
Skullians committed Feb 14, 2024
1 parent aa63ffc commit 6b7413e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void initialize(URL location, ResourceBundle resources) {

jtype = extractor.getType(SidebarController.jarDir, SidebarController.tempDir);
if (jtype == null) {
ErrorHandler.error = "Jar Type returned Null";
ErrorHandler.setErrorMessage(borderPane);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void initialize(URL location, ResourceBundle resources) {
extractingField.setText(Extractor.processing);
dependenciesField.setText(Arrays.toString(Extractor.dependencies));
if (Extractor.completed) { executorService.shutdown(); }
}, 0, 750, TimeUnit.MILLISECONDS);
}, 0, 1, TimeUnit.SECONDS);
}

private void setRotate(Circle c, boolean reverse, int angle, int duration) {
Expand All @@ -67,7 +67,7 @@ private void beginExtraction() {
switch (ConfirmationHandler.jtype) {

case "Forge":

Extractor.extractForgeMods(ConfirmationHandler.input, ConfirmationHandler.output);
break;
case "Plugin":
Extractor.extractPlugins(ConfirmationHandler.input, ConfirmationHandler.output);
Expand Down
18 changes: 15 additions & 3 deletions src/main/java/skullian/binarysearchinator/util/jar/Extractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,20 @@ public String getType(String input, String output) {
Path jarFilePath = getRandomJarFile(input);
List<String> toCheck = Arrays.asList("plugin.yml", "fabric.mod.json", "mods.toml", "quilt.mod.json");
ZipFile jarFile = new ZipFile(jarFilePath.toFile());

for (String fileName: toCheck) {
Enumeration<? extends ZipEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
if (entry.getName().contains("mods.toml")) {
return "Forge / NeoForged Mod";
} else if (entry.getName().contains("plugin.yml")) {
return "Plugin";
} else if (entry.getName().contains("fabric.mod.json")) {
return "Fabric Mod";
} else if (entry.getName().contains("quilt.mod.json")) {
return "Quilt Mod";
}
}
/*for (String fileName: toCheck) {
ZipEntry entry = jarFile.getEntry(fileName);
if (entry != null) {
if (fileName.equals("plugin.yml")) {
Expand All @@ -58,7 +70,7 @@ public String getType(String input, String output) {
return "Quilt Mod";
}
}
}
}*/
} catch (Exception error) {
ErrorHandler.error = "Failed to get jar type: \n" + error;
ErrorHandler.setErrorMessage(pane);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package skullian.binarysearchinator.util.jar.parsing;

public class ParseJSON {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package skullian.binarysearchinator.util.jar.parsing;

public class ParseTOML {
}

0 comments on commit 6b7413e

Please sign in to comment.