@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Path relativePath = rootPath.relativize(file); String downloadURL = urlBase + "/" + relativePath.toString().replace("\\", "/").replace(" ", "%20"); InputStream is = Files.newInputStream(file); byte[] hash = DigestUtils.md5(is); String md5 = new String(Hex.encodeHex(hash)); String name = file.getFileName().toString(); String id; name = name.substring(0, name.length() - 4); id = name.replace(" ", ""); String depends = ""; Boolean required = true; Boolean inJar = false; Boolean extract = false; Boolean inRoot = false; Boolean isDefault = true; Boolean coreMod = false; System.out.println(relativePath.toString()); if (relativePath.toString().contains(".DS_Store")) { return FileVisitResult.CONTINUE; } if (relativePath.toString().indexOf(sep) >= 0) { switch (relativePath.toString().substring(0, relativePath.toString().indexOf(sep))) { // Ignore these folders case "bin": case "lib": case "resources": case "saves": case "screenshots": case "stats": case "texturepacks": case "texturepacks-mp-cache": return FileVisitResult.CONTINUE; // case "instMods": case "jar": { inJar = true; break; } case "coremods": { coreMod = true; break; } case "config": { String newPath = relativePath.toString(); if (sep.equals("\\")) { newPath = newPath.replace("\\", "/"); } ConfigFile newConfig = new ConfigFile(downloadURL, newPath, false, md5); parent.AddConfig(new ConfigFileWrapper("", newConfig)); return FileVisitResult.CONTINUE; } default: } } try { ZipFile zf = new ZipFile(file.toFile()); System.out.println(zf.size() + " entries in file."); JdomParser parser = new JdomParser(); JsonRootNode modInfo = parser.parse(new InputStreamReader(zf.getInputStream(zf.getEntry("mcmod.info")))); JsonNode subnode; if (modInfo.hasElements()) { subnode = modInfo.getElements().get(0); } else { subnode = modInfo.getNode("modlist").getElements().get(0); } id = subnode.getStringValue("modid"); name = subnode.getStringValue("name"); zf.close(); } catch (NullPointerException e) { } catch (ZipException e) { System.out.println("Not an archive."); } catch (IOException e) { e.printStackTrace(); } catch (InvalidSyntaxException e) { e.printStackTrace(); } finally { Module newMod = new Module( name, id, downloadURL, depends, required, inJar, 0, true, extract, inRoot, isDefault, coreMod, md5, null, "both", null); parent.AddModule(newMod); } return FileVisitResult.CONTINUE; }