Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private ItemStack item;
- public ItemBuilder(Material material) {
- this(material, 1);
- }
- public ItemBuilder(Material material, int amount) {
- this(material, amount, (short) 0);
- }
- public ItemBuilder(Material material, short subId) {
- this(material, 1, subId);
- }
- public ItemBuilder(Material material, int amount, short subId) {
- this(new ItemStack(material, amount, subId));
- }
- public ItemBuilder(ItemStack item) {
- this.item = item;
- }
- public static ItemBuilder getSkullBuilder() {
- return new ItemBuilder(Material.SKULL_ITEM, 1, (short) 3);
- }
- public ItemBuilder setAmount(int amount) {
- this.item.setAmount(amount);
- return this;
- }
- public ItemBuilder giveName(String name) {
- ItemMeta meta = this.item.getItemMeta();
- meta.setDisplayName(name);
- this.item.setItemMeta(meta);
- return this;
- }
- public ItemBuilder setLore(List<String> lore) {
- ItemMeta meta = this.item.getItemMeta();
- meta.setLore((List) lore);
- this.item.setItemMeta(meta);
- return this;
- }
- public ItemBuilder setBreakable() {
- this.item.getItemMeta().spigot().setUnbreakable(false);
- return this;
- }
- public ItemBuilder setUnbreakable() {
- this.item.getItemMeta().spigot().setUnbreakable(true);
- return this;
- }
- public ItemBuilder enchant(Enchantment enchantment, int strength) {
- this.item.addEnchantment(enchantment, strength);
- return this;
- }
- public ItemBuilder enchantUnsafe(Enchantment enchantment, int strength) {
- this.item.addUnsafeEnchantment(enchantment, strength);
- return this;
- }
- public ItemBuilder skullData(String value) {
- Bukkit.getUnsafe().modifyItemStack(this.item, "{SkullOwner:{Id:\"" + new UUID(value.hashCode(), value.hashCode()) + "\",Properties:{textures:[{Value:\"" + value + "\"}]}}}");
- return this;
- }
- public ItemBuilder skullOwner(String owner) {
- SkullMeta meta = (SkullMeta) this.item.getItemMeta();
- meta.setOwner(owner);
- this.item.setItemMeta((ItemMeta) meta);
- return this;
- }
- public ItemBuilder addItemFlag(ItemFlag... itemFlag) {
- this.item.getItemMeta().addItemFlags(itemFlag);
- return this;
- }
- public ItemStack build() {
- return this.item;
- }
- public ItemBuilder clone() {
- return new ItemBuilder(this.item.clone());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement