Merge branch 'development' of gitlab.com:Songoda/songodaupdater into development

This commit is contained in:
jascotty2 2019-10-18 21:17:58 -05:00
commit ebb0434250
2 changed files with 17 additions and 23 deletions

View File

@ -4,7 +4,7 @@ stages:
variables:
name: "SongodaCore"
path: "/builds/$CI_PROJECT_PATH"
version: "2.2.3"
version: "2.2.4"
build:
stage: build

View File

@ -328,30 +328,24 @@ public class ItemUtils {
}
}
static Field cb_SkullMeta_profile;
public static String getSkullTexture(ItemStack item) {
if (!CompatibleMaterial.PLAYER_HEAD.matches(item) || ServerVersion.isServerVersionBelow(ServerVersion.V1_8)) {
return null;
}
try {
SkullMeta localSkullMeta = (SkullMeta) item.getItemMeta();
Field cb_SkullMeta_profile = localSkullMeta.getClass().getDeclaredField("profile");
if (cb_SkullMeta_profile == null) return null;
cb_SkullMeta_profile.setAccessible(true);
static {
try {
cb_SkullMeta_profile = SkullMeta.class.getDeclaredField("profile");
cb_SkullMeta_profile.setAccessible(true);
} catch (Exception ex) {
}
}
GameProfile profile = (GameProfile) cb_SkullMeta_profile.get(localSkullMeta);
Iterator<Property> iterator = profile.getProperties().get("textures").iterator();
public static String getSkullTexture(ItemStack item) {
if (cb_SkullMeta_profile == null || !CompatibleMaterial.PLAYER_HEAD.matches(item) || ServerVersion.isServerVersionBelow(ServerVersion.V1_8)) {
return null;
}
try {
SkullMeta localSkullMeta = (SkullMeta) item.getItemMeta();
GameProfile profile = (GameProfile) cb_SkullMeta_profile.get(localSkullMeta);
Iterator<Property> iterator = profile.getProperties().get("textures").iterator();
return iterator.hasNext() ? iterator.next().getValue() : null;
} catch (IllegalArgumentException | IllegalAccessException ex) {
}
return null;
}
return iterator.hasNext() ? iterator.next().getValue() : null;
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException ex) {
}
return null;
}
public static String getDecodedTexture(String encoded) {
return encoded != null ? StringUtils.substringBetween(new String(Base64.getDecoder().decode(encoded)), "texture/", "\"") : null;