Vinetos

ItemsCrator

Oct 30th, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. package fr.vinetos.unikube.api;
  2.  
  3. import java.util.List;
  4. import org.bukkit.Material;
  5. import org.bukkit.inventory.ItemStack;
  6. import org.bukkit.inventory.meta.ItemMeta;
  7. import org.bukkit.inventory.meta.SkullMeta;
  8.  
  9. public class ItemsCreator {
  10. private Material m;
  11. private String name;
  12. private List<String> lores;
  13. private int amount;
  14. private byte data;
  15.  
  16. public ItemsCreator(Material m, String name, List<String> lores, int amount, byte data) {
  17. if(amount == 0) {
  18. ++amount;
  19. }
  20.  
  21. if(data == 0) {
  22. ++data;
  23. }
  24.  
  25. this.m = m;
  26. this.name = name;
  27. this.lores = lores;
  28. this.amount = amount;
  29. this.data = data;
  30. }
  31.  
  32. public ItemsCreator(Material m, String name, List<String> lores) {
  33. this.m = m;
  34. this.name = name;
  35. this.lores = lores;
  36. this.amount = 1;
  37. this.data = 0;
  38. }
  39.  
  40. public ItemStack create() {
  41. ItemStack is = new ItemStack(this.m, this.amount, (short)this.data);
  42. ItemMeta meta = is.getItemMeta();
  43. if(this.name != null) {
  44. meta.setDisplayName(this.name);
  45. }
  46.  
  47. if(this.lores != null) {
  48. meta.setLore(this.lores);
  49. }
  50.  
  51. is.setItemMeta(meta);
  52. return is;
  53. }
  54.  
  55. public ItemStack createHead(String owner) {
  56. ItemStack is = new ItemStack(Material.SKULL_ITEM, this.amount, (short)3);
  57. SkullMeta meta = (SkullMeta)is.getItemMeta();
  58. meta.setOwner(owner);
  59. meta.setDisplayName(this.name);
  60. if(this.lores != null) {
  61. meta.setLore(this.lores);
  62. }
  63.  
  64. is.setItemMeta(meta);
  65. return is;
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment