Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.bukkit.DyeColor;
- import org.bukkit.Material;
- import org.bukkit.inventory.ItemStack;
- public class XItemStack {
- public XItemStack(XMaterial type,byte data){
- this.type = type;
- this.data = data;
- }
- XMaterial type;
- byte data;
- public ItemStack build(){
- ItemStack item;
- if(XMaterial.req(type.toString()) != null){
- item = new ItemStack(XMaterial.req(type.toString()),1,data);
- return item;
- }
- Material mat = XMaterial.req(getColor(data) + "_" + type.toString());
- if(mat == null){
- mat = XMaterial.req(getLogType(data) + "_" + type.toString());
- if(mat == null){
- mat = XMaterial.req(getAnvilType(data) + "_" + type.toString());
- if(mat == null){
- return null; //set to null to incite an error
- }
- }
- }
- item = new ItemStack(mat);
- return item;
- }
- public String getAnvilType(byte data){
- switch(data){
- case 0:
- return "";
- case 1:
- return "CHIPPED";
- case 2:
- return "DAMAGED";
- default:
- return null;
- }
- }
- public String getLogType(byte data){
- switch(data){
- case 0:
- return "OAK";
- case 1:
- return "PINE";
- case 2:
- return "BIRCH";
- case 3:
- return "JUNGLE";
- case 4:
- return "ACACIA";
- case 5:
- return "DARK_OAK";
- default:
- return null;
- }
- }
- public String getColor(byte data){
- switch(data){
- case 0:
- return DyeColor.WHITE.toString();
- case 1:
- return DyeColor.ORANGE.toString();
- case 2:
- return DyeColor.MAGENTA.toString();
- case 3:
- return DyeColor.LIGHT_BLUE.toString();
- case 4:
- return DyeColor.YELLOW.toString();
- case 5:
- return DyeColor.LIME.toString();
- case 6:
- return DyeColor.PINK.toString();
- case 7:
- return DyeColor.GRAY.toString();
- case 8:
- return "LIGHT_GRAY";
- case 9:
- return DyeColor.CYAN.toString();
- case 10:
- return DyeColor.PURPLE.toString();
- case 11:
- return DyeColor.BLUE.toString();
- case 12:
- return DyeColor.BROWN.toString();
- case 13:
- return DyeColor.GREEN.toString();
- case 14:
- return DyeColor.RED.toString();
- case 15:
- return DyeColor.BLACK.toString();
- default:
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement