mirror of
https://github.com/songoda/EpicHeads.git
synced 2024-11-26 04:25:16 +01:00
Fixed an issue with tokens.
This commit is contained in:
parent
e8653b0f65
commit
33efa61776
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user