28 lines
951 B
Java
28 lines
951 B
Java
package org.warp.cachedplayerheads;
|
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.Method;
|
|
import net.skinsrestorer.api.SkinsRestorerAPI;
|
|
|
|
public class SkinsRestorerAPIUtils {
|
|
|
|
public static String getSkinData(SkinsRestorerAPI skinsRestorerAPI, String playerName) {
|
|
if (skinsRestorerAPI == null) return null;
|
|
// Use SkinRestorer's skin username if the player has set it
|
|
String transformedPlayerName = skinsRestorerAPI.getSkinName(playerName);
|
|
if (transformedPlayerName == null) {
|
|
transformedPlayerName = playerName;
|
|
}
|
|
Object skinData = skinsRestorerAPI.getSkinData(transformedPlayerName);
|
|
if (skinData != null) {
|
|
try {
|
|
Method getValueMethod = skinData.getClass().getMethod("getValue");
|
|
return (String) getValueMethod.invoke(skinData);
|
|
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|