diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/authlib/InstallAuthlib.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/authlib/InstallAuthlib.java index 2db343cb..a5ed38cf 100644 --- a/ServerWrapper/src/main/java/pro/gravit/launcher/server/authlib/InstallAuthlib.java +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/authlib/InstallAuthlib.java @@ -15,7 +15,7 @@ import java.util.zip.ZipOutputStream; public class InstallAuthlib { private static final Map modifierMap; - private static final String LaunchAuthLibName = "authlib.jar"; + private static final String tempLaunchAuthLibName = "authlib.jar"; static { modifierMap = new HashMap<>(); modifierMap.put("META-INF/libraries.list", new LibrariesLstModifier()); @@ -27,32 +27,30 @@ public class InstallAuthlib { boolean deleteAuthlibAfterInstall = false; InstallAuthlibContext context = new InstallAuthlibContext(); if(args[0].startsWith("http://") || args[0].startsWith("https://")) { - Path tempAuthlib = Paths.get(LaunchAuthLibName); + Path tempAuthlib = Paths.get(tempLaunchAuthLibName); LogHelper.info("Download %s to %s", args[0], tempAuthlib); try(InputStream input = IOHelper.newInput(new URL(args[0]))) { IOHelper.transfer(input, tempAuthlib); } - context.pathToAuthlib = tempAuthlib; + context.pathToAuthlib = tempAuthlib.toAbsolutePath(); deleteAuthlibAfterInstall = true; } else { - context.pathToAuthlib = Paths.get(args[0]); + context.pathToAuthlib = Paths.get(args[0]).toAbsolutePath(); } if(Files.notExists(context.pathToAuthlib)) { throw new FileNotFoundException(context.pathToAuthlib.toString()); } - context.workdir = IOHelper.WORKING_DIR; LogHelper.info("Search .jar files in %s", context.workdir.toAbsolutePath()); IOHelper.walk(context.workdir, new SimpleFileVisitor<>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { - if (file.getFileName().toString().endsWith(".jar") && !file.getFileName().toString().equals(LaunchAuthLibName)) { + if (file.getFileName().toString().endsWith(".jar") && !file.equals(context.pathToAuthlib)) { context.files.add(file); } return FileVisitResult.CONTINUE; } }, true); - context.files.sort(Comparator.comparingInt((Path path) -> - countSlashes(path.toString())) - .thenComparing(Comparator.naturalOrder())); + context.files.sort(Comparator.comparingInt((Path path) -> - path.getNameCount())); LogHelper.info("Search authlib in %d files", context.files.size()); for(Path path : context.files) { boolean foundAuthlib = false; @@ -218,10 +216,6 @@ public class InstallAuthlib { } } - private static int countSlashes(String s) { - return (int) s.chars().filter(c -> c == '/').count(); - } - public static class RepackInfo { public Path path; public String prefix;