Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1.  
  2. import org.bukkit.DyeColor;
  3. import org.bukkit.Material;
  4. import org.bukkit.inventory.ItemStack;
  5.  
  6. public class XItemStack {
  7.  
  8. public XItemStack(XMaterial type,byte data){
  9. this.type = type;
  10. this.data = data;
  11. }
  12.  
  13. XMaterial type;
  14.  
  15. byte data;
  16.  
  17. public ItemStack build(){
  18. ItemStack item;
  19. if(XMaterial.req(type.toString()) != null){
  20. item = new ItemStack(XMaterial.req(type.toString()),1,data);
  21. return item;
  22. }
  23. Material mat = XMaterial.req(getColor(data) + "_" + type.toString());
  24. if(mat == null){
  25. mat = XMaterial.req(getLogType(data) + "_" + type.toString());
  26. if(mat == null){
  27. mat = XMaterial.req(getAnvilType(data) + "_" + type.toString());
  28. if(mat == null){
  29. return null; //set to null to incite an error
  30. }
  31. }
  32. }
  33. item = new ItemStack(mat);
  34.  
  35.  
  36. return item;
  37. }
  38.  
  39. public String getAnvilType(byte data){
  40. switch(data){
  41. case 0:
  42. return "";
  43. case 1:
  44. return "CHIPPED";
  45. case 2:
  46. return "DAMAGED";
  47. default:
  48. return null;
  49. }
  50. }
  51.  
  52. public String getLogType(byte data){
  53. switch(data){
  54. case 0:
  55. return "OAK";
  56. case 1:
  57. return "PINE";
  58. case 2:
  59. return "BIRCH";
  60. case 3:
  61. return "JUNGLE";
  62. case 4:
  63. return "ACACIA";
  64. case 5:
  65. return "DARK_OAK";
  66. default:
  67. return null;
  68. }
  69. }
  70.  
  71. public String getColor(byte data){
  72. switch(data){
  73. case 0:
  74. return DyeColor.WHITE.toString();
  75. case 1:
  76. return DyeColor.ORANGE.toString();
  77. case 2:
  78. return DyeColor.MAGENTA.toString();
  79. case 3:
  80. return DyeColor.LIGHT_BLUE.toString();
  81. case 4:
  82. return DyeColor.YELLOW.toString();
  83. case 5:
  84. return DyeColor.LIME.toString();
  85. case 6:
  86. return DyeColor.PINK.toString();
  87. case 7:
  88. return DyeColor.GRAY.toString();
  89. case 8:
  90. return "LIGHT_GRAY";
  91. case 9:
  92. return DyeColor.CYAN.toString();
  93. case 10:
  94. return DyeColor.PURPLE.toString();
  95. case 11:
  96. return DyeColor.BLUE.toString();
  97. case 12:
  98. return DyeColor.BROWN.toString();
  99. case 13:
  100. return DyeColor.GREEN.toString();
  101. case 14:
  102. return DyeColor.RED.toString();
  103. case 15:
  104. return DyeColor.BLACK.toString();
  105. default:
  106. return null;
  107. }
  108. }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement