Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.vinetos.unikube.api;
- import java.util.List;
- import org.bukkit.Material;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.meta.ItemMeta;
- import org.bukkit.inventory.meta.SkullMeta;
- public class ItemsCreator {
- private Material m;
- private String name;
- private List<String> lores;
- private int amount;
- private byte data;
- public ItemsCreator(Material m, String name, List<String> lores, int amount, byte data) {
- if(amount == 0) {
- ++amount;
- }
- if(data == 0) {
- ++data;
- }
- this.m = m;
- this.name = name;
- this.lores = lores;
- this.amount = amount;
- this.data = data;
- }
- public ItemsCreator(Material m, String name, List<String> lores) {
- this.m = m;
- this.name = name;
- this.lores = lores;
- this.amount = 1;
- this.data = 0;
- }
- public ItemStack create() {
- ItemStack is = new ItemStack(this.m, this.amount, (short)this.data);
- ItemMeta meta = is.getItemMeta();
- if(this.name != null) {
- meta.setDisplayName(this.name);
- }
- if(this.lores != null) {
- meta.setLore(this.lores);
- }
- is.setItemMeta(meta);
- return is;
- }
- public ItemStack createHead(String owner) {
- ItemStack is = new ItemStack(Material.SKULL_ITEM, this.amount, (short)3);
- SkullMeta meta = (SkullMeta)is.getItemMeta();
- meta.setOwner(owner);
- meta.setDisplayName(this.name);
- if(this.lores != null) {
- meta.setLore(this.lores);
- }
- is.setItemMeta(meta);
- return is;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment