diff --git a/src/main/java/com/songoda/epicheads/utils/ItemEconomy.java b/src/main/java/com/songoda/epicheads/utils/ItemEconomy.java index 73d93d9..ff57a3a 100644 --- a/src/main/java/com/songoda/epicheads/utils/ItemEconomy.java +++ b/src/main/java/com/songoda/epicheads/utils/ItemEconomy.java @@ -1,14 +1,19 @@ package com.songoda.epicheads.utils; +import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.hooks.economies.Economy; +import com.songoda.core.utils.ItemUtils; +import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.inventory.ItemStack; public class ItemEconomy extends Economy { public boolean isItem(ItemStack itemStack) { - if (itemStack == null) + if (itemStack == null || itemStack.getType() == Material.AIR) return false; + if (CompatibleMaterial.getMaterial(itemStack) == CompatibleMaterial.PLAYER_HEAD) + return ItemUtils.getSkullTexture(itemStack).equals(ItemUtils.getSkullTexture(Methods.createToken(1))); return itemStack.isSimilar(Methods.createToken(1)); } @@ -16,6 +21,17 @@ public class ItemEconomy extends Economy { return (int) Math.ceil(amount); } + @Override + public double getBalance(OfflinePlayer player) { + int amount = 0; + for (ItemStack item : player.getPlayer().getInventory().getContents()) { + if (!isItem(item)) + continue; + amount += item.getAmount(); + } + return amount; + } + @Override public boolean hasBalance(OfflinePlayer player, double cost) { int amount = convertAmount(cost); diff --git a/src/main/java/com/songoda/epicheads/utils/Methods.java b/src/main/java/com/songoda/epicheads/utils/Methods.java index a189566..85938ce 100644 --- a/src/main/java/com/songoda/epicheads/utils/Methods.java +++ b/src/main/java/com/songoda/epicheads/utils/Methods.java @@ -30,7 +30,7 @@ public class Methods { for (String line : Settings.ITEM_TOKEN_LORE.getStringList()) if (!line.equals("")) lore.add(formatText(line)); - if (lore != null) meta.setLore(lore); + meta.setLore(lore); itemStack.setItemMeta(meta); return itemStack; }