!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;
public ClassItem(ConfigurationSection config) {
super(new ItemStack(Material.BARRIER), config);
super(Material.BARRIER, config);
this.name = config.getString("name");
this.lore = config.getStringList("lore");

View File

@ -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());

View File

@ -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");
}

View File

@ -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<String> 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;
}

View File

@ -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