diff --git a/src/main/java/net/raphimc/viaproxy/ViaProxy.java b/src/main/java/net/raphimc/viaproxy/ViaProxy.java index e16f9a8..29d1c02 100644 --- a/src/main/java/net/raphimc/viaproxy/ViaProxy.java +++ b/src/main/java/net/raphimc/viaproxy/ViaProxy.java @@ -150,7 +150,6 @@ public class ViaProxy { } } - ConsoleHandler.hookConsole(); ViaProxy.loadNetty(); ClassLoaderPriorityUtil.loadOverridingJars(); diff --git a/src/main/java/net/raphimc/viaproxy/ui/I18n.java b/src/main/java/net/raphimc/viaproxy/ui/I18n.java index f9be050..19979e5 100644 --- a/src/main/java/net/raphimc/viaproxy/ui/I18n.java +++ b/src/main/java/net/raphimc/viaproxy/ui/I18n.java @@ -17,8 +17,8 @@ */ package net.raphimc.viaproxy.ui; +import net.raphimc.viabedrock.api.util.FileSystemUtil; import net.raphimc.viaproxy.ViaProxy; -import net.raphimc.viaproxy.util.FileSystemUtil; import java.io.ByteArrayInputStream; import java.io.InputStreamReader; diff --git a/src/main/java/net/raphimc/viaproxy/util/FileSystemUtil.java b/src/main/java/net/raphimc/viaproxy/util/FileSystemUtil.java deleted file mode 100644 index d0390ce..0000000 --- a/src/main/java/net/raphimc/viaproxy/util/FileSystemUtil.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This file is part of ViaProxy - https://github.com/RaphiMC/ViaProxy - * Copyright (C) 2021-2024 RK_01/RaphiMC and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package net.raphimc.viaproxy.util; - -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.nio.file.*; -import java.util.Collections; -import java.util.Comparator; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class FileSystemUtil { - - public static Map getFilesInDirectory(final String assetPath) throws IOException, URISyntaxException { - final URI uri = FileSystemUtil.class.getClassLoader().getResource(assetPath).toURI(); - if (uri.getScheme().equals("file")) { - return getFilesInPath(Paths.get(uri)); - } else if (uri.getScheme().equals("jar")) { - try (FileSystem fileSystem = getOrCreateFileSystem(uri)) { - return getFilesInPath(fileSystem.getPath(assetPath)); - } - } else { - throw new IllegalArgumentException("Unsupported URI scheme: " + uri.getScheme()); - } - } - - private static Map getFilesInPath(final Path path) throws IOException { - try (Stream stream = Files.walk(path)) { - return stream - .filter(Files::isRegularFile) - .sorted(Comparator.comparing(Path::toString)) - .collect(Collectors.toMap(f -> f, f -> { - try { - return Files.readAllBytes(f); - } catch (IOException e) { - throw new RuntimeException(e); - } - }, (u, v) -> { - throw new IllegalStateException("Duplicate key"); - }, LinkedHashMap::new)); - } - } - - private static FileSystem getOrCreateFileSystem(final URI uri) throws IOException { - FileSystem fileSystem; - try { - fileSystem = FileSystems.getFileSystem(uri); - } catch (FileSystemNotFoundException e) { - fileSystem = FileSystems.newFileSystem(uri, Collections.emptyMap()); - } - return fileSystem; - } - -}