Merge pull request #3910 from JOO200/fix/skinsrestorercompile

Don't use reflections to access SkinsRestorer API
This commit is contained in:
mikeprimm 2023-01-25 09:09:25 -06:00 committed by GitHub
commit 6fd70b65fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,7 +5,7 @@ import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException; import org.json.simple.parser.ParseException;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import net.skinsrestorer.api.SkinsRestorerAPI; import net.skinsrestorer.api.SkinsRestorerAPI;
import net.skinsrestorer.api.reflection.ReflectionUtil; import net.skinsrestorer.api.property.IProperty;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
@ -25,19 +25,12 @@ public class SkinsRestorerSkinUrlProvider implements SkinUrlProvider {
public URL getSkinUrl(String playerName) { public URL getSkinUrl(String playerName) {
String skinName = mSkinsRestorerApi.getSkinName(playerName); String skinName = mSkinsRestorerApi.getSkinName(playerName);
Object skinDataProperty = mSkinsRestorerApi.getSkinData(skinName == null ? playerName : skinName); IProperty skinDataProperty = mSkinsRestorerApi.getSkinData(skinName == null ? playerName : skinName);
if (skinDataProperty == null) if (skinDataProperty == null)
return null; return null;
String skinDataPropertyValue; String skinDataPropertyValue = skinDataProperty.getValue();
try {
skinDataPropertyValue = (String) ReflectionUtil.invokeMethod(skinDataProperty, "getValue");
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
byte[] skinDataBytes = Base64.getDecoder().decode(skinDataPropertyValue); byte[] skinDataBytes = Base64.getDecoder().decode(skinDataPropertyValue);