From 6a349d24ac1a31904c6be69540389e165e38029d Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Mon, 19 Apr 2021 07:54:48 -0400 Subject: [PATCH] Specify an explicit path instead of using Paths.get() to construct it --- .../main/java/com/velocitypowered/proxy/VelocityServer.java | 2 +- .../com/velocitypowered/proxy/util/FileSystemUtils.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java index bd5141ed0..6f915a953 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java @@ -250,7 +250,7 @@ public class VelocityServer implements ProxyServer, ForwardingAudience { translationRegistry.defaultLocale(Locale.US); try { FileSystemUtils.visitResources(VelocityServer.class, - Paths.get("com", "velocitypowered", "proxy", "l10n"), path -> { + "com/velocitypowered/proxy/l10n", path -> { logger.info("Loading localizations..."); try { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/util/FileSystemUtils.java b/proxy/src/main/java/com/velocitypowered/proxy/util/FileSystemUtils.java index 353e638fd..0b634b7cf 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/util/FileSystemUtils.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/util/FileSystemUtils.java @@ -42,14 +42,14 @@ public class FileSystemUtils { * @param consumer The consumer to visit the resolved path */ @SuppressFBWarnings({"RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"}) - public static boolean visitResources(Class target, Path path, Consumer consumer) + public static boolean visitResources(Class target, String path, Consumer consumer) throws IOException { final File file = new File(target .getProtectionDomain().getCodeSource().getLocation().getPath()); if (file.isFile()) { // jar try (FileSystem fileSystem = FileSystems.newFileSystem(file.toPath(), (ClassLoader) null)) { - Path toVisit = fileSystem.getPath(path.toString()); + Path toVisit = fileSystem.getPath(path); if (Files.exists(toVisit)) { consumer.accept(toVisit); return true; @@ -59,7 +59,7 @@ public class FileSystemUtils { } else { URI uri; try { - URL url = target.getClassLoader().getResource(path.toString()); + URL url = target.getClassLoader().getResource(path); if (url == null) { return false; }