From ec0d66dd158afc0aacc169b4899da5a2b2217301 Mon Sep 17 00:00:00 2001 From: Indyuce Date: Sun, 27 Sep 2020 00:14:30 +0200 Subject: [PATCH] !Fixed GUI item custom model data --- .../net/Indyuce/mmocore/gui/ClassSelect.java | 2 +- .../net/Indyuce/mmocore/gui/QuestViewer.java | 2 +- .../net/Indyuce/mmocore/gui/SkillList.java | 4 ++-- .../api/item/InventoryPlaceholderItem.java | 20 +++++++++---------- .../gui/api/item/NoPlaceholderItem.java | 6 +++--- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java b/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java index 38be11e2..645a4429 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java +++ b/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java @@ -46,7 +46,7 @@ public class ClassSelect extends EditableInventory { private final List lore; public ClassItem(ConfigurationSection config) { - super(new ItemStack(Material.BARRIER), config); + super(Material.BARRIER, config); this.name = config.getString("name"); this.lore = config.getStringList("lore"); diff --git a/src/main/java/net/Indyuce/mmocore/gui/QuestViewer.java b/src/main/java/net/Indyuce/mmocore/gui/QuestViewer.java index 2613d439..5eb9342b 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/QuestViewer.java +++ b/src/main/java/net/Indyuce/mmocore/gui/QuestViewer.java @@ -166,7 +166,7 @@ public class QuestViewer extends EditableInventory { /* * generate item */ - ItemStack item = cloneItem(); + ItemStack item = new ItemStack(getMaterial()); ItemMeta meta = item.getItemMeta(); meta.setDisplayName(holders.apply(inv.getPlayer(), getName())); meta.addItemFlags(ItemFlag.values()); diff --git a/src/main/java/net/Indyuce/mmocore/gui/SkillList.java b/src/main/java/net/Indyuce/mmocore/gui/SkillList.java index 9e3e383b..0a04dbf4 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/SkillList.java +++ b/src/main/java/net/Indyuce/mmocore/gui/SkillList.java @@ -172,7 +172,7 @@ public class SkillList extends EditableInventory { for (int j = 0; j < lore.size(); j++) lore.set(j, ChatColor.GRAY + MMOLib.plugin.parseColors(lore.get(j))); - ItemStack item = cloneItem(); + ItemStack item = new ItemStack(getMaterial()); ItemMeta meta = item.getItemMeta(); meta.setDisplayName(MMOLib.plugin.parseColors(getName().replace("{skill}", skill.getSkill().getName()) .replace("{roman}", MMOCoreUtils.intToRoman(skillLevel)).replace("{level}", "" + skillLevel))); @@ -198,7 +198,7 @@ public class SkillList extends EditableInventory { private final int selectedSkillSlot; public SkillItem(ConfigurationSection config) { - super(new ItemStack(Material.BARRIER), config); + super(Material.BARRIER, config); selectedSkillSlot = config.getInt("selected-slot"); } diff --git a/src/main/java/net/Indyuce/mmocore/gui/api/item/InventoryPlaceholderItem.java b/src/main/java/net/Indyuce/mmocore/gui/api/item/InventoryPlaceholderItem.java index 9a038a87..fdbe560d 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/api/item/InventoryPlaceholderItem.java +++ b/src/main/java/net/Indyuce/mmocore/gui/api/item/InventoryPlaceholderItem.java @@ -7,6 +7,7 @@ import java.util.UUID; import java.util.logging.Level; import org.bukkit.ChatColor; +import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; @@ -17,26 +18,25 @@ import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; import net.Indyuce.mmocore.MMOCore; -import net.Indyuce.mmocore.api.util.MMOCoreUtils; import net.Indyuce.mmocore.gui.api.GeneratedInventory; import net.Indyuce.mmocore.gui.api.PluginInventory; import net.mmogroup.mmolib.MMOLib; public abstract class InventoryPlaceholderItem extends InventoryItem { - private final ItemStack stack; + private final Material material; private final String name, texture; private final List lore; private final int modelData; private final boolean placeholders, hideFlags; public InventoryPlaceholderItem(ConfigurationSection config) { - this(MMOCoreUtils.readIcon(config.getString("item")), config); + this(Material.valueOf(config.getString("item", "").toUpperCase().replace(" ", "_").replace("-", "_")), config); } - public InventoryPlaceholderItem(ItemStack stack, ConfigurationSection config) { + public InventoryPlaceholderItem(Material material, ConfigurationSection config) { super(config); - this.stack = stack; + this.material = material; this.name = config.getString("name"); this.lore = config.getStringList("lore"); this.hideFlags = config.getBoolean("hide-flags"); @@ -45,8 +45,8 @@ public abstract class InventoryPlaceholderItem extends InventoryItem { this.modelData = config.getInt("custom-model-data"); } - public ItemStack cloneItem() { - return stack.clone(); + public Material getMaterial() { + return material; } public boolean hideFlags() { @@ -72,7 +72,7 @@ public abstract class InventoryPlaceholderItem extends InventoryItem { public int getModelData() { return modelData; } - + public boolean supportPlaceholders() { return placeholders; } @@ -92,7 +92,7 @@ public abstract class InventoryPlaceholderItem extends InventoryItem { public ItemStack display(GeneratedInventory inv, int n) { Placeholders placeholders = getPlaceholders(inv, n); - ItemStack item = cloneItem(); + ItemStack item = new ItemStack(material); ItemMeta meta = item.getItemMeta(); if (texture != null && meta instanceof SkullMeta) @@ -112,7 +112,7 @@ public abstract class InventoryPlaceholderItem extends InventoryItem { if (MMOLib.plugin.getVersion().isStrictlyHigher(1, 13)) meta.setCustomModelData(getModelData()); - + item.setItemMeta(meta); return item; } diff --git a/src/main/java/net/Indyuce/mmocore/gui/api/item/NoPlaceholderItem.java b/src/main/java/net/Indyuce/mmocore/gui/api/item/NoPlaceholderItem.java index 1c3d9aef..4e31fe95 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/api/item/NoPlaceholderItem.java +++ b/src/main/java/net/Indyuce/mmocore/gui/api/item/NoPlaceholderItem.java @@ -1,7 +1,7 @@ package net.Indyuce.mmocore.gui.api.item; +import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.inventory.ItemStack; import net.Indyuce.mmocore.gui.api.PluginInventory; @@ -10,8 +10,8 @@ public class NoPlaceholderItem extends InventoryPlaceholderItem { super(config); } - public NoPlaceholderItem(ItemStack stack, ConfigurationSection config) { - super(stack, config); + public NoPlaceholderItem(Material material, ConfigurationSection config) { + super(material, config); } @Override