Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 16:12:46 +01:00
Various resource pack fixes (#1769)
- Fixes an instance where an invalid pack_manifest file could be present - Fixes instances where JSON files were not read as UTF-8
Dieser Commit ist enthalten in:
Ursprung
1a08e1104d
Commit
1c7567d79d
@ -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> T loadJson(InputStream src, Class<T> 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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());
|
||||
|
||||
PACKS.put(pack.getManifest().getHeader().getUuid().toString(), pack);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren