Advertisement
Guest User

ssssdsds

a guest
Jul 20th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.91 KB | None | 0 0
  1. import org.bukkit.enchantments.*;
  2. import org.bukkit.inventory.*;
  3. import java.util.*;
  4. import org.bukkit.*;
  5. import org.bukkit.inventory.meta.*;
  6.  
  7. public class ItemManager
  8. {
  9. private ItemStack item;
  10. private List<String> lore;
  11. private ItemMeta meta;
  12.  
  13. public ItemManager(final Material mat, final short subid, final int amount) {
  14. this.lore = new ArrayList<String>();
  15. this.item = new ItemStack(mat, amount, subid);
  16. this.meta = this.item.getItemMeta();
  17. }
  18.  
  19. public ItemManager(final ItemStack item) {
  20. this.lore = new ArrayList<String>();
  21. this.item = item;
  22. this.meta = item.getItemMeta();
  23. }
  24.  
  25. public ItemManager(final Material mat, final short subid) {
  26. this.lore = new ArrayList<String>();
  27. this.item = new ItemStack(mat, 1, subid);
  28. this.meta = this.item.getItemMeta();
  29. }
  30.  
  31. public ItemManager(final Material mat, final int amount) {
  32. this.lore = new ArrayList<String>();
  33. this.item = new ItemStack(mat, amount, (short)0);
  34. this.meta = this.item.getItemMeta();
  35. }
  36.  
  37. public ItemManager(final Material mat, final int amount, final int data) {
  38. this.lore = new ArrayList<String>();
  39. this.item = new ItemStack(mat, amount, (short)data);
  40. this.meta = this.item.getItemMeta();
  41. }
  42.  
  43. public ItemManager(final Material mat) {
  44. this.lore = new ArrayList<String>();
  45. this.item = new ItemStack(mat, 1, (short)0);
  46. this.meta = this.item.getItemMeta();
  47. }
  48.  
  49. public ItemManager setAmount(final int value) {
  50. this.item.setAmount(value);
  51. return this;
  52. }
  53.  
  54. public ItemManager setNoName() {
  55. this.meta.setDisplayName(" ");
  56. return this;
  57. }
  58.  
  59. public ItemManager setGlow() {
  60. this.meta.addEnchant(Enchantment.DURABILITY, 1, true);
  61. this.meta.addItemFlags(new ItemFlag[] { ItemFlag.HIDE_ENCHANTS });
  62. return this;
  63. }
  64.  
  65. public ItemManager setData(final short data) {
  66. this.item.setDurability(data);
  67. return this;
  68. }
  69.  
  70. public ItemManager addLoreLine(final String line) {
  71. this.lore.add(line);
  72. return this;
  73. }
  74.  
  75. public ItemManager addLoreArray(final String[] lines) {
  76. for (int x = 0; x < lines.length; ++x) {
  77. this.lore.add(lines[x]);
  78. }
  79. return this;
  80. }
  81.  
  82. public ItemManager addLoreAll(final List<String> lines) {
  83. this.lore.addAll(lines);
  84. return this;
  85. }
  86.  
  87. public ItemManager setDisplayName(final String name) {
  88. this.meta.setDisplayName(name);
  89. return this;
  90. }
  91.  
  92. public ItemManager setSkullOwner(final String owner) {
  93. ((SkullMeta)this.meta).setOwner(owner);
  94. return this;
  95. }
  96.  
  97. public ItemManager setColor(final Color c) {
  98. ((LeatherArmorMeta)this.meta).setColor(c);
  99. return this;
  100. }
  101.  
  102. public ItemManager setBannerColor(final DyeColor c) {
  103. ((BannerMeta)this.meta).setBaseColor(c);
  104. return this;
  105. }
  106.  
  107. public ItemManager setUnbreakable(final boolean value) {
  108. this.meta.spigot().setUnbreakable(value);
  109. return this;
  110. }
  111.  
  112. public ItemManager addEnchantment(final Enchantment ench, final int lvl) {
  113. this.meta.addEnchant(ench, lvl, true);
  114. return this;
  115. }
  116.  
  117. public ItemManager addItemFlag(final ItemFlag flag) {
  118. this.meta.addItemFlags(new ItemFlag[] { flag });
  119. return this;
  120. }
  121.  
  122. public ItemManager addLeatherColor(final Color color) {
  123. ((LeatherArmorMeta)this.meta).setColor(color);
  124. return this;
  125. }
  126.  
  127. public ItemStack build() {
  128. if (!this.lore.isEmpty()) {
  129. this.meta.setLore((List)this.lore);
  130. }
  131. this.item.setItemMeta(this.meta);
  132. return this.item;
  133. }
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement