diff --git a/connector/src/main/java/org/geysermc/connector/utils/FileUtils.java b/connector/src/main/java/org/geysermc/connector/utils/FileUtils.java index fd3e9a8db..862af548d 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/FileUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/FileUtils.java @@ -36,6 +36,7 @@ import org.reflections.util.ConfigurationBuilder; import java.io.*; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.security.MessageDigest; import java.util.function.Function; @@ -62,7 +63,8 @@ public class FileUtils { } public static T loadJson(InputStream src, Class valueType) throws IOException { - return GeyserConnector.JSON_MAPPER.readValue(src, valueType); + // Read specifically with UTF-8 to allow any non-UTF-encoded JSON to read + return GeyserConnector.JSON_MAPPER.readValue(new InputStreamReader(src, StandardCharsets.UTF_8), valueType); } /** diff --git a/connector/src/main/java/org/geysermc/connector/utils/ResourcePack.java b/connector/src/main/java/org/geysermc/connector/utils/ResourcePack.java index 16a1812ee..bcb1ffd50 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/ResourcePack.java +++ b/connector/src/main/java/org/geysermc/connector/utils/ResourcePack.java @@ -63,7 +63,7 @@ public class ResourcePack { // As we just created the directory it will be empty return; } - + for (File file : directory.listFiles()) { if (file.getName().endsWith(".zip") || file.getName().endsWith(".mcpack")) { ResourcePack pack = new ResourcePack(); @@ -77,12 +77,15 @@ public class ResourcePack { if (x.getName().contains("manifest.json")) { try { ResourcePackManifest manifest = FileUtils.loadJson(zip.getInputStream(x), ResourcePackManifest.class); + // Sometimes a pack_manifest file is present and not in a valid format, + // but a manifest file is, so we null check through that one + if (manifest.getHeader().getUuid() != null) { + pack.file = file; + pack.manifest = manifest; + pack.version = ResourcePackManifest.Version.fromArray(manifest.getHeader().getVersion()); - pack.file = file; - pack.manifest = manifest; - pack.version = ResourcePackManifest.Version.fromArray(manifest.getHeader().getVersion()); - - PACKS.put(pack.getManifest().getHeader().getUuid().toString(), pack); + PACKS.put(pack.getManifest().getHeader().getUuid().toString(), pack); + } } catch (Exception e) { e.printStackTrace(); }