!Fixed GUI item custom model data

This commit is contained in:
Indyuce 2020-09-27 00:14:30 +02:00
parent 5cae155273
commit ec0d66dd15
5 changed files with 17 additions and 17 deletions

View File

@ -46,7 +46,7 @@ public class ClassSelect extends EditableInventory {
private final List<String> lore; private final List<String> lore;
public ClassItem(ConfigurationSection config) { public ClassItem(ConfigurationSection config) {
super(new ItemStack(Material.BARRIER), config); super(Material.BARRIER, config);
this.name = config.getString("name"); this.name = config.getString("name");
this.lore = config.getStringList("lore"); this.lore = config.getStringList("lore");

View File

@ -166,7 +166,7 @@ public class QuestViewer extends EditableInventory {
/* /*
* generate item * generate item
*/ */
ItemStack item = cloneItem(); ItemStack item = new ItemStack(getMaterial());
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setDisplayName(holders.apply(inv.getPlayer(), getName())); meta.setDisplayName(holders.apply(inv.getPlayer(), getName()));
meta.addItemFlags(ItemFlag.values()); meta.addItemFlags(ItemFlag.values());

View File

@ -172,7 +172,7 @@ public class SkillList extends EditableInventory {
for (int j = 0; j < lore.size(); j++) for (int j = 0; j < lore.size(); j++)
lore.set(j, ChatColor.GRAY + MMOLib.plugin.parseColors(lore.get(j))); lore.set(j, ChatColor.GRAY + MMOLib.plugin.parseColors(lore.get(j)));
ItemStack item = cloneItem(); ItemStack item = new ItemStack(getMaterial());
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setDisplayName(MMOLib.plugin.parseColors(getName().replace("{skill}", skill.getSkill().getName()) meta.setDisplayName(MMOLib.plugin.parseColors(getName().replace("{skill}", skill.getSkill().getName())
.replace("{roman}", MMOCoreUtils.intToRoman(skillLevel)).replace("{level}", "" + skillLevel))); .replace("{roman}", MMOCoreUtils.intToRoman(skillLevel)).replace("{level}", "" + skillLevel)));
@ -198,7 +198,7 @@ public class SkillList extends EditableInventory {
private final int selectedSkillSlot; private final int selectedSkillSlot;
public SkillItem(ConfigurationSection config) { public SkillItem(ConfigurationSection config) {
super(new ItemStack(Material.BARRIER), config); super(Material.BARRIER, config);
selectedSkillSlot = config.getInt("selected-slot"); selectedSkillSlot = config.getInt("selected-slot");
} }

View File

@ -7,6 +7,7 @@ import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -17,26 +18,25 @@ import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.Property;
import net.Indyuce.mmocore.MMOCore; 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.GeneratedInventory;
import net.Indyuce.mmocore.gui.api.PluginInventory; import net.Indyuce.mmocore.gui.api.PluginInventory;
import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.MMOLib;
public abstract class InventoryPlaceholderItem extends InventoryItem { public abstract class InventoryPlaceholderItem extends InventoryItem {
private final ItemStack stack; private final Material material;
private final String name, texture; private final String name, texture;
private final List<String> lore; private final List<String> lore;
private final int modelData; private final int modelData;
private final boolean placeholders, hideFlags; private final boolean placeholders, hideFlags;
public InventoryPlaceholderItem(ConfigurationSection config) { 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); super(config);
this.stack = stack; this.material = material;
this.name = config.getString("name"); this.name = config.getString("name");
this.lore = config.getStringList("lore"); this.lore = config.getStringList("lore");
this.hideFlags = config.getBoolean("hide-flags"); this.hideFlags = config.getBoolean("hide-flags");
@ -45,8 +45,8 @@ public abstract class InventoryPlaceholderItem extends InventoryItem {
this.modelData = config.getInt("custom-model-data"); this.modelData = config.getInt("custom-model-data");
} }
public ItemStack cloneItem() { public Material getMaterial() {
return stack.clone(); return material;
} }
public boolean hideFlags() { public boolean hideFlags() {
@ -92,7 +92,7 @@ public abstract class InventoryPlaceholderItem extends InventoryItem {
public ItemStack display(GeneratedInventory inv, int n) { public ItemStack display(GeneratedInventory inv, int n) {
Placeholders placeholders = getPlaceholders(inv, n); Placeholders placeholders = getPlaceholders(inv, n);
ItemStack item = cloneItem(); ItemStack item = new ItemStack(material);
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
if (texture != null && meta instanceof SkullMeta) if (texture != null && meta instanceof SkullMeta)

View File

@ -1,7 +1,7 @@
package net.Indyuce.mmocore.gui.api.item; package net.Indyuce.mmocore.gui.api.item;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.gui.api.PluginInventory; import net.Indyuce.mmocore.gui.api.PluginInventory;
@ -10,8 +10,8 @@ public class NoPlaceholderItem extends InventoryPlaceholderItem {
super(config); super(config);
} }
public NoPlaceholderItem(ItemStack stack, ConfigurationSection config) { public NoPlaceholderItem(Material material, ConfigurationSection config) {
super(stack, config); super(material, config);
} }
@Override @Override