Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. private ItemStack item;
  2.  
  3. public ItemBuilder(Material material) {
  4. this(material, 1);
  5. }
  6.  
  7. public ItemBuilder(Material material, int amount) {
  8. this(material, amount, (short) 0);
  9. }
  10.  
  11. public ItemBuilder(Material material, short subId) {
  12. this(material, 1, subId);
  13. }
  14.  
  15. public ItemBuilder(Material material, int amount, short subId) {
  16. this(new ItemStack(material, amount, subId));
  17. }
  18.  
  19. public ItemBuilder(ItemStack item) {
  20. this.item = item;
  21. }
  22.  
  23. public static ItemBuilder getSkullBuilder() {
  24. return new ItemBuilder(Material.SKULL_ITEM, 1, (short) 3);
  25. }
  26.  
  27. public ItemBuilder setAmount(int amount) {
  28. this.item.setAmount(amount);
  29. return this;
  30. }
  31.  
  32. public ItemBuilder giveName(String name) {
  33. ItemMeta meta = this.item.getItemMeta();
  34. meta.setDisplayName(name);
  35. this.item.setItemMeta(meta);
  36. return this;
  37. }
  38.  
  39. public ItemBuilder setLore(List<String> lore) {
  40. ItemMeta meta = this.item.getItemMeta();
  41. meta.setLore((List) lore);
  42. this.item.setItemMeta(meta);
  43. return this;
  44. }
  45.  
  46. public ItemBuilder setBreakable() {
  47. this.item.getItemMeta().spigot().setUnbreakable(false);
  48. return this;
  49. }
  50.  
  51. public ItemBuilder setUnbreakable() {
  52. this.item.getItemMeta().spigot().setUnbreakable(true);
  53. return this;
  54. }
  55.  
  56. public ItemBuilder enchant(Enchantment enchantment, int strength) {
  57. this.item.addEnchantment(enchantment, strength);
  58. return this;
  59. }
  60.  
  61. public ItemBuilder enchantUnsafe(Enchantment enchantment, int strength) {
  62. this.item.addUnsafeEnchantment(enchantment, strength);
  63. return this;
  64. }
  65.  
  66. public ItemBuilder skullData(String value) {
  67. Bukkit.getUnsafe().modifyItemStack(this.item, "{SkullOwner:{Id:\"" + new UUID(value.hashCode(), value.hashCode()) + "\",Properties:{textures:[{Value:\"" + value + "\"}]}}}");
  68. return this;
  69. }
  70.  
  71. public ItemBuilder skullOwner(String owner) {
  72. SkullMeta meta = (SkullMeta) this.item.getItemMeta();
  73. meta.setOwner(owner);
  74. this.item.setItemMeta((ItemMeta) meta);
  75. return this;
  76. }
  77.  
  78. public ItemBuilder addItemFlag(ItemFlag... itemFlag) {
  79. this.item.getItemMeta().addItemFlags(itemFlag);
  80. return this;
  81. }
  82.  
  83. public ItemStack build() {
  84. return this.item;
  85. }
  86.  
  87. public ItemBuilder clone() {
  88. return new ItemBuilder(this.item.clone());
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement