Created
February 13, 2016 20:35
-
-
Save hugo4715/929d1489f6898cb13483 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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