Fixed 1.20+ skull texture application

This commit is contained in:
Jules 2023-11-06 02:56:07 +01:00
parent 3c043babd5
commit 22744b181b
3 changed files with 5 additions and 8 deletions

View File

@ -40,6 +40,7 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -89,7 +90,7 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
if (config.contains("display.texture") && icon.getType() == VersionMaterial.PLAYER_HEAD.toMaterial()) {
ItemMeta meta = icon.getItemMeta();
UtilityMethods.setTextureValue(meta, config.getString("display.texture"));
UtilityMethods.setTextureValue((SkullMeta) meta, config.getString("display.texture"));
icon.setItemMeta(meta);
}

View File

@ -147,7 +147,7 @@ public abstract class InventoryItem<T extends GeneratedInventory> {
final ItemMeta meta = item.getItemMeta();
meta.setCustomModelData(modelData);
if (texture != null && meta instanceof SkullMeta)
UtilityMethods.setTextureValue(meta, texture);
UtilityMethods.setTextureValue((SkullMeta) meta, texture);
if (hasName()) meta.setDisplayName(placeholders.apply(effectivePlayer, getName()));

View File

@ -10,10 +10,10 @@ import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.jetbrains.annotations.NotNull;
import java.util.*;
import java.util.logging.Level;
public abstract class AbstractItemBuilder {
private final ConfigItem configItem;
@ -42,11 +42,7 @@ public abstract class AbstractItemBuilder {
ItemMeta meta = item.getItemMeta();
if (item.getType() == VersionMaterial.PLAYER_HEAD.toMaterial() && configItem.getTexture() != null)
try {
UtilityMethods.setTextureValue(meta, configItem.getTexture());
} catch (IllegalArgumentException exception) {
MMOCore.log(Level.WARNING, "Could not load texture of config item called '" + configItem.getId() + "'");
}
UtilityMethods.setTextureValue((SkullMeta) meta, configItem.getTexture());
meta.addItemFlags(ItemFlag.values());
meta.setDisplayName(applyPlaceholders(configItem.getName()));