Skip to content

Instantly share code, notes, and snippets.

@hugo4715
Created February 13, 2016 20:35
Show Gist options
  • Save hugo4715/929d1489f6898cb13483 to your computer and use it in GitHub Desktop.
Save hugo4715/929d1489f6898cb13483 to your computer and use it in GitHub Desktop.
package fr.hugo4715.paytoprotect.utils;
import java.util.Arrays;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public class ItemFactory {
private ItemStack item;
public ItemFactory(Material mat) {
item = new ItemStack(mat);
}
public ItemFactory withName(String name){
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(name);
item.setItemMeta(meta);
return this;
}
public ItemFactory withLore(String... lore){
ItemMeta meta = item.getItemMeta();
meta.setLore(Arrays.asList(lore));
item.setItemMeta(meta);
return this;
}
public ItemFactory withColor(DyeColor color){
item.setDurability(color.getData());
return this;
}
public ItemStack done(){
return item;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment