Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ru.meloncode.cristalix.prison;
- import org.bukkit.enchantments.Enchantment;
- import org.bukkit.inventory.ItemStack;
- public class ItemStackUtils {
- public static boolean hasEnchantment(ItemStack itemStack, Enchantment enchantment) {
- return itemStack != null && itemStack.hasItemMeta() && itemStack.getItemMeta().hasEnchant(enchantment);
- }
- public static int getEnchantmentLevel(ItemStack itemStack, Enchantment enchantment) {
- if (itemStack != null && itemStack.hasItemMeta() && itemStack.getItemMeta().hasEnchant(enchantment))
- return itemStack.getItemMeta().getEnchantLevel(enchantment);
- return 0;
- }
- public static boolean hasName(ItemStack itemStack) {
- return itemStack != null && itemStack.hasItemMeta() && itemStack.getItemMeta().hasDisplayName();
- }
- public static boolean hasName(ItemStack itemStack, String name) {
- return itemStack != null && itemStack.hasItemMeta() && itemStack.getItemMeta().hasDisplayName() && itemStack.getItemMeta().getDisplayName().equals(name);
- }
- public static boolean nameStartsWith(ItemStack itemStack, String name) {
- return itemStack != null && itemStack.hasItemMeta() && itemStack.getItemMeta().hasDisplayName() && itemStack.getItemMeta().getDisplayName().startsWith(name);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement