Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. package ru.meloncode.cristalix.prison;
  2.  
  3. import org.bukkit.enchantments.Enchantment;
  4. import org.bukkit.inventory.ItemStack;
  5.  
  6.  
  7. public class ItemStackUtils {
  8. public static boolean hasEnchantment(ItemStack itemStack, Enchantment enchantment) {
  9. return itemStack != null && itemStack.hasItemMeta() && itemStack.getItemMeta().hasEnchant(enchantment);
  10. }
  11.  
  12. public static int getEnchantmentLevel(ItemStack itemStack, Enchantment enchantment) {
  13. if (itemStack != null && itemStack.hasItemMeta() && itemStack.getItemMeta().hasEnchant(enchantment))
  14. return itemStack.getItemMeta().getEnchantLevel(enchantment);
  15. return 0;
  16. }
  17.  
  18. public static boolean hasName(ItemStack itemStack) {
  19. return itemStack != null && itemStack.hasItemMeta() && itemStack.getItemMeta().hasDisplayName();
  20. }
  21.  
  22. public static boolean hasName(ItemStack itemStack, String name) {
  23. return itemStack != null && itemStack.hasItemMeta() && itemStack.getItemMeta().hasDisplayName() && itemStack.getItemMeta().getDisplayName().equals(name);
  24. }
  25.  
  26. public static boolean nameStartsWith(ItemStack itemStack, String name) {
  27. return itemStack != null && itemStack.hasItemMeta() && itemStack.getItemMeta().hasDisplayName() && itemStack.getItemMeta().getDisplayName().startsWith(name);
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement