Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-09-29 14:40:21 +02:00
Specify an explicit path instead of using Paths.get() to construct it
Dieser Commit ist enthalten in:
Ursprung
efa9f6f303
Commit
6a349d24ac
@ -250,7 +250,7 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
|
|||||||
translationRegistry.defaultLocale(Locale.US);
|
translationRegistry.defaultLocale(Locale.US);
|
||||||
try {
|
try {
|
||||||
FileSystemUtils.visitResources(VelocityServer.class,
|
FileSystemUtils.visitResources(VelocityServer.class,
|
||||||
Paths.get("com", "velocitypowered", "proxy", "l10n"), path -> {
|
"com/velocitypowered/proxy/l10n", path -> {
|
||||||
logger.info("Loading localizations...");
|
logger.info("Loading localizations...");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -42,14 +42,14 @@ public class FileSystemUtils {
|
|||||||
* @param consumer The consumer to visit the resolved path
|
* @param consumer The consumer to visit the resolved path
|
||||||
*/
|
*/
|
||||||
@SuppressFBWarnings({"RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"})
|
@SuppressFBWarnings({"RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"})
|
||||||
public static boolean visitResources(Class<?> target, Path path, Consumer<Path> consumer)
|
public static boolean visitResources(Class<?> target, String path, Consumer<Path> consumer)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final File file = new File(target
|
final File file = new File(target
|
||||||
.getProtectionDomain().getCodeSource().getLocation().getPath());
|
.getProtectionDomain().getCodeSource().getLocation().getPath());
|
||||||
|
|
||||||
if (file.isFile()) { // jar
|
if (file.isFile()) { // jar
|
||||||
try (FileSystem fileSystem = FileSystems.newFileSystem(file.toPath(), (ClassLoader) null)) {
|
try (FileSystem fileSystem = FileSystems.newFileSystem(file.toPath(), (ClassLoader) null)) {
|
||||||
Path toVisit = fileSystem.getPath(path.toString());
|
Path toVisit = fileSystem.getPath(path);
|
||||||
if (Files.exists(toVisit)) {
|
if (Files.exists(toVisit)) {
|
||||||
consumer.accept(toVisit);
|
consumer.accept(toVisit);
|
||||||
return true;
|
return true;
|
||||||
@ -59,7 +59,7 @@ public class FileSystemUtils {
|
|||||||
} else {
|
} else {
|
||||||
URI uri;
|
URI uri;
|
||||||
try {
|
try {
|
||||||
URL url = target.getClassLoader().getResource(path.toString());
|
URL url = target.getClassLoader().getResource(path);
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren