Advertisement
Guest User

ItemStack Builder

a guest
Dec 8th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.79 KB | None | 0 0
  1. package net.yourPackage;
  2.  
  3. import java.util.ArrayList;
  4. import org.bukkit.Color;
  5. import org.bukkit.Material;
  6. import org.bukkit.inventory.ItemStack;
  7. import org.bukkit.inventory.meta.ItemMeta;
  8. import org.bukkit.inventory.meta.LeatherArmorMeta;
  9.  
  10. public class ItBuilder {
  11.    
  12.     public static ItemStack get(Material material) {
  13.         ItemStack it = new ItemStack(material);
  14.         return it;
  15.     }
  16.    
  17.     public static ItemStack createVerySimple(Material material, String nome, short data) {
  18.         ItemStack it = new ItemStack(material, 1, (short) data);
  19.         ItemMeta itM = it.getItemMeta();
  20.         itM.setDisplayName(nome);
  21.         it.setItemMeta(itM);
  22.         return it;
  23.     }
  24.    
  25.     public static ItemStack createVerySimple(Material material, String nome) {
  26.         ItemStack it = new ItemStack(material);
  27.         ItemMeta itM = it.getItemMeta();
  28.         itM.setDisplayName(nome);
  29.         it.setItemMeta(itM);
  30.         return it;
  31.     }
  32.    
  33.     public static ItemStack createVerySimple(Material material, String nome, int amount) {
  34.         ItemStack it = new ItemStack(material, amount);
  35.         ItemMeta itM = it.getItemMeta();
  36.         itM.setDisplayName(nome);
  37.         it.setItemMeta(itM);
  38.         return it;
  39.     }
  40.    
  41.     public static ItemStack createVerySimple(Material material, String nome, short data, int amount) {
  42.         ItemStack it = new ItemStack(material, amount, (short) data);
  43.         ItemMeta itM = it.getItemMeta();
  44.         itM.setDisplayName(nome);
  45.         it.setItemMeta(itM);
  46.         return it;
  47.     }
  48.    
  49.     public static ItemStack createSimple(Material material, String nome, ArrayList<String> lore) {
  50.         ItemStack it = new ItemStack(material);
  51.         ItemMeta itM = it.getItemMeta();
  52.         itM.setDisplayName(nome);
  53.         itM.setLore(lore);
  54.         it.setItemMeta(itM);
  55.         return it;
  56.     }
  57.    
  58.     public static ItemStack createAdvanced(Material material, String nome, ArrayList<String> lore, int amount, short data) {
  59.         ItemStack it = new ItemStack(material, amount, (short) data);
  60.         ItemMeta itM = it.getItemMeta();
  61.         itM.setDisplayName(nome);
  62.         itM.setLore(lore);
  63.         it.setItemMeta(itM);
  64.         return it;
  65.     }
  66.    
  67.     public static ItemStack createLeatherArmor(Material material, short damage, String nome, ArrayList<String> lore, int amount, Color cor) {
  68.         ItemStack it = new ItemStack(material, (int) amount, (short) damage);
  69.         LeatherArmorMeta itM = (LeatherArmorMeta) it.getItemMeta();
  70.         itM.setDisplayName(nome);
  71.         itM.setLore(lore);
  72.         itM.setColor(cor);
  73.         it.setItemMeta(itM);
  74.         return it;
  75.     }
  76.    
  77.     @SuppressWarnings("deprecation")
  78.     public static boolean areEquals(ItemStack item, ItemStack item2) {
  79.         boolean equals;
  80.         if (item.getTypeId() == item2.getTypeId() && item.getItemMeta().getDisplayName().equals(item.getItemMeta().getDisplayName()) && item.getItemMeta().getLore().equals(item2.getItemMeta().getLore()) && item.getEnchantments().equals(item2.getEnchantments())) {
  81.             equals = true;
  82.         } else {
  83.             equals = false;
  84.         }
  85.         return equals;
  86.     }
  87.  
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement