Skip to content

Commit 59035ce

Browse files
committed
Update SkullCacheHandler to support legacy skull materials
1 parent 65ee2cb commit 59035ce

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

SimpleAPI/src/main/java/com/bencodez/simpleapi/skull/SkullCacheHandler.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public abstract class SkullCacheHandler {
2020
Queue<String> skullsToLoad = new ConcurrentLinkedQueue<>();
2121

2222
private boolean pause = false;
23-
23+
2424
@Getter
2525
@Setter
2626
private String bedrockPrefix = ".";
@@ -70,15 +70,27 @@ public void flushCache() {
7070
SkullCache.flushWeek();
7171
}
7272

73+
@SuppressWarnings("deprecation")
7374
public ItemStack getSkull(UUID uuid, String playerName) {
75+
Material skullMaterial;
76+
ItemStack skullItem;
77+
// Check for legacy versions
78+
try {
79+
skullMaterial = Material.valueOf("PLAYER_HEAD");
80+
skullItem = new ItemStack(skullMaterial);
81+
} catch (IllegalArgumentException e) {
82+
// Fallback
83+
skullMaterial = Material.valueOf("SKULL_ITEM");
84+
skullItem = new ItemStack(skullMaterial, 1, (short) 3);
85+
}
7486
if (playerName.length() > 16 || (pause && !SkullCache.isLoaded(uuid)) || uuid.toString().charAt(14) == '3') {
75-
return new ItemStack(Material.PLAYER_HEAD);
87+
return skullItem;
7688
}
7789
try {
7890
return SkullCache.getSkull(uuid, playerName);
7991
} catch (Exception e) {
8092
pauseCaching();
81-
return new ItemStack(Material.PLAYER_HEAD);
93+
return skullItem;
8294
}
8395
}
8496

0 commit comments

Comments
 (0)