Only use DatatypeConverter as a fallback

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad
2022-11-12 14:48:42 +00:00
parent 8a81aaaa0a
commit 7534eaf006
6 changed files with 67 additions and 24 deletions

View File

@ -43,8 +43,7 @@ import java.net.URLConnection;
import java.net.URLStreamHandler;
import java.util.Map;
import javax.xml.bind.DatatypeConverter;
import org.prismlauncher.utils.Base64;
import org.prismlauncher.utils.JsonParser;
import org.prismlauncher.utils.UrlUtils;
@ -115,7 +114,7 @@ final class Handler extends URLStreamHandler {
for (Map<String, Object> property : (Iterable<Map<String, Object>>) profile.get("properties")) {
if (property.get("name").equals("textures")) {
Map<String, Object> result = (Map<String, Object>) JsonParser
.parse(new String(DatatypeConverter.parseBase64Binary((String) property.get("value"))));
.parse(new String(Base64.decode((String) property.get("value"))));
result = (Map<String, Object>) result.get("textures");
return result;
}

View File

@ -59,27 +59,10 @@ public final class SkinFix implements Fix, URLStreamHandlerFactory {
@Override
public boolean isApplicable(Parameters params) {
if (!isSupported()) {
Log.warning("Using Java 8 will probably fix this");
Log.warning("Alternatively, turning off legacy skin fix in Settings > Miscellaneous will silence the warnings");
return false;
}
return true;
}
private boolean isSupported() {
// check for DatatypeConverter first
// most users will just be annoyed by the big stacktrace
try {
Class.forName("javax.xml.bind.DatatypeConverter");
} catch (ClassNotFoundException e) {
Log.warning("Cannot find DatatypeConverter - required for skin fix");
return false;
}
if (!UrlUtils.isSupported()) {
Log.warning("Cannot access the necessary Java internals for skin fix");
Log.warning("Using an older Java version will probably fix this");
Log.warning("Alternatively, turning off legacy skin fix in Settings > Miscellaneous will silence the warnings");
return false;
}