2019-09-05 18:26:13 +02:00
|
|
|
package de.steamwar.fightsystem.utils;
|
2019-02-14 18:37:38 +01:00
|
|
|
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.enchantments.Enchantment;
|
|
|
|
import org.bukkit.inventory.ItemFlag;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
import org.bukkit.inventory.meta.ItemMeta;
|
|
|
|
|
2019-06-05 22:14:27 +02:00
|
|
|
import java.util.List;
|
|
|
|
|
2019-02-14 18:37:38 +01:00
|
|
|
public class ItemBuilder {
|
|
|
|
|
2019-03-26 12:33:33 +01:00
|
|
|
private final ItemStack item;
|
|
|
|
private final ItemMeta meta;
|
2019-06-05 22:14:27 +02:00
|
|
|
|
2019-02-14 18:37:38 +01:00
|
|
|
public ItemBuilder(Material matrial) {
|
|
|
|
item = new ItemStack(matrial);
|
|
|
|
meta = item.getItemMeta();
|
|
|
|
}
|
2019-06-05 22:14:27 +02:00
|
|
|
|
|
|
|
|
2019-02-14 18:37:38 +01:00
|
|
|
public ItemBuilder(Material matrial, int amount) {
|
|
|
|
item = new ItemStack(matrial, amount);
|
|
|
|
meta = item.getItemMeta();
|
|
|
|
}
|
|
|
|
public ItemBuilder(Material matrial, short subid) {
|
|
|
|
item = new ItemStack(matrial, 1, subid);
|
|
|
|
meta = item.getItemMeta();
|
|
|
|
}
|
|
|
|
|
|
|
|
public ItemBuilder removeAllAtributs() {
|
|
|
|
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
|
|
|
meta.addItemFlags(ItemFlag.HIDE_DESTROYS);
|
|
|
|
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
|
|
|
|
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
|
|
|
meta.addItemFlags(ItemFlag.HIDE_PLACED_ON);
|
|
|
|
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ItemBuilder setDisplayName(String name) {
|
|
|
|
meta.setDisplayName(name);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2019-06-05 22:14:27 +02:00
|
|
|
public ItemBuilder addLore(List<String> lore) {
|
2019-02-14 18:37:38 +01:00
|
|
|
meta.setLore(lore);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ItemBuilder addEnchantment(Enchantment enchantment, int level) {
|
|
|
|
meta.addEnchant(enchantment, level, true);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ItemStack build() {
|
|
|
|
item.setItemMeta(meta);
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|