Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.80 KB | None | 0 0
  1. import java.util.List;
  2.  
  3. import org.bukkit.Material;
  4. import org.bukkit.enchantments.Enchantment;
  5. import org.bukkit.entity.Player;
  6. import org.bukkit.inventory.ItemStack;
  7. import org.bukkit.inventory.meta.ItemMeta;
  8. import org.bukkit.inventory.meta.SkullMeta;
  9. import org.bukkit.potion.Potion;
  10. import org.bukkit.potion.PotionType;
  11.  
  12. @SuppressWarnings("deprecation")
  13. public class ItemUtils {
  14.  
  15.     /* Creation d'items */
  16.  
  17.     public ItemStack getItem(Material material, int amount) {
  18.         return new ItemStack(material, amount);
  19.     }
  20.    
  21.     public ItemStack getItem(Material material, int amount, String name) {
  22.         ItemStack itemstack = new ItemStack(material, amount);
  23.         ItemMeta itemmeta = itemstack.getItemMeta();
  24.         itemmeta.setDisplayName(name);
  25.         itemstack.setItemMeta(itemmeta);
  26.         return itemstack;
  27.     }
  28.  
  29.     public ItemStack getItem(Material material, int amount, String name, List<String> lore) {
  30.         ItemStack itemstack = new ItemStack(material, amount);
  31.         ItemMeta itemmeta = itemstack.getItemMeta();
  32.         itemmeta.setDisplayName(name);
  33.         itemmeta.setLore(lore);
  34.         itemstack.setItemMeta(itemmeta);
  35.         return itemstack;
  36.     }
  37.  
  38.     public ItemStack getItem(Material material, int amount, String name, List<String> lore, Enchantment echant, int puissance, boolean voala) {
  39.         ItemStack itemstack = new ItemStack(material, amount);
  40.         ItemMeta itemmeta = itemstack.getItemMeta();
  41.         itemmeta.setDisplayName(name);
  42.         itemmeta.setLore(lore);
  43.         itemmeta.addEnchant(echant, puissance, voala);
  44.         itemstack.setItemMeta(itemmeta);
  45.         return itemstack;
  46.     }
  47.     /* Creation de GLASS PANE */
  48.  
  49.     public ItemStack getGlassPane(int color) {
  50.         ItemStack glass = new ItemStack(Material.STAINED_GLASS_PANE, 1, (byte) color);
  51.         ItemMeta glassM = glass.getItemMeta();
  52.         glassM.setDisplayName(" ");
  53.         glass.setItemMeta(glassM);
  54.         return glass;
  55.     }
  56.  
  57.     public ItemStack getGlassPane(int color, String name) {
  58.         ItemStack glass = new ItemStack(Material.STAINED_GLASS_PANE, 1, (byte) color);
  59.         ItemMeta glassM = glass.getItemMeta();
  60.         glassM.setDisplayName(name);
  61.         glass.setItemMeta(glassM);
  62.         return glass;
  63.     }
  64.  
  65.     /* Creation de POTIONS */
  66.  
  67.     public ItemStack getPotion(PotionType effet) {
  68.         Potion potion = new Potion(effet);
  69.         return potion.toItemStack(1);
  70.     }
  71.  
  72.     public ItemStack getPotion(PotionType effet, int amount) {
  73.         Potion potion = new Potion(effet);
  74.         return potion.toItemStack(amount);
  75.     }
  76.  
  77.     /* Creation de SKULLS */
  78.  
  79.     public ItemStack getSkull(Player player) {
  80.         ItemStack customSkull = new ItemStack(Material.SKULL, 1, (byte) 3);
  81.         ItemMeta customSkullMeta = customSkull.getItemMeta();
  82.         customSkullMeta.setDisplayName(player.getCustomName());
  83.         customSkull.setItemMeta(customSkullMeta);
  84.         SkullMeta customSkullMeta2 = (SkullMeta) customSkull.getItemMeta();
  85.         customSkullMeta2.setOwner(player.getName());
  86.         customSkull.setItemMeta(customSkullMeta2);
  87.         return customSkull;
  88.     }
  89.  
  90.     public ItemStack getSkull(Player player, String nom) {
  91.         ItemStack customSkull = new ItemStack(Material.SKULL, 1, (byte) 3);
  92.         ItemMeta customSkullMeta = customSkull.getItemMeta();
  93.         customSkullMeta.setDisplayName(nom);
  94.         customSkull.setItemMeta(customSkullMeta);
  95.         SkullMeta customSkullMeta2 = (SkullMeta) customSkull.getItemMeta();
  96.         customSkullMeta2.setOwner(player.getName());
  97.         customSkull.setItemMeta(customSkullMeta2);
  98.         return customSkull;
  99.     }
  100.  
  101.     public ItemStack getSkull(Player player, String nom, List<String> lore) {
  102.         ItemStack customSkull = new ItemStack(Material.SKULL, 1, (byte) 3);
  103.         ItemMeta customSkullMeta = customSkull.getItemMeta();
  104.         customSkullMeta.setDisplayName(nom);
  105.         customSkullMeta.setLore(lore);
  106.         customSkull.setItemMeta(customSkullMeta);
  107.         SkullMeta customSkullMeta2 = (SkullMeta) customSkull.getItemMeta();
  108.         customSkullMeta2.setOwner(player.getName());
  109.         customSkull.setItemMeta(customSkullMeta2);
  110.         return customSkull;
  111.     }
  112.  
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement