ItemChecks.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. package com.gmail.nossr50;
  2. import org.bukkit.inventory.ItemStack;
  3. public class ItemChecks {
  4. /**
  5. * Checks if the item is a sword.
  6. *
  7. * @param is Item to check
  8. * @return true if the item is a sword, false otherwise
  9. */
  10. public static boolean isSword(ItemStack is) {
  11. switch (is.getType()) {
  12. case DIAMOND_SWORD:
  13. case GOLD_SWORD:
  14. case IRON_SWORD:
  15. case STONE_SWORD:
  16. case WOOD_SWORD:
  17. return true;
  18. default:
  19. return false;
  20. }
  21. }
  22. /**
  23. * Checks if the item is a hoe.
  24. *
  25. * @param is Item to check
  26. * @return true if the item is a hoe, false otherwise
  27. */
  28. public static boolean isHoe(ItemStack is) {
  29. switch (is.getType()) {
  30. case DIAMOND_HOE:
  31. case GOLD_HOE:
  32. case IRON_HOE:
  33. case STONE_HOE:
  34. case WOOD_HOE:
  35. return true;
  36. default:
  37. return false;
  38. }
  39. }
  40. /**
  41. * Checks if the item is a shovel.
  42. *
  43. * @param is Item to check
  44. * @return true if the item is a shovel, false otherwise
  45. */
  46. public static boolean isShovel(ItemStack is) {
  47. switch (is.getType()) {
  48. case DIAMOND_SPADE:
  49. case GOLD_SPADE:
  50. case IRON_SPADE:
  51. case STONE_SPADE:
  52. case WOOD_SPADE:
  53. return true;
  54. default:
  55. return false;
  56. }
  57. }
  58. /**
  59. * Checks if the item is an axe.
  60. *
  61. * @param is Item to check
  62. * @return true if the item is an axe, false otherwise
  63. */
  64. public static boolean isAxe(ItemStack is) {
  65. switch (is.getType()) {
  66. case DIAMOND_AXE:
  67. case GOLD_AXE:
  68. case IRON_AXE:
  69. case STONE_AXE:
  70. case WOOD_AXE:
  71. return true;
  72. default:
  73. return false;
  74. }
  75. }
  76. /**
  77. * Checks if the item is a pickaxe.
  78. *
  79. * @param is Item to check
  80. * @return true if the item is a pickaxe, false otherwise
  81. */
  82. public static boolean isMiningPick(ItemStack is) {
  83. switch (is.getType()) {
  84. case DIAMOND_PICKAXE:
  85. case GOLD_PICKAXE:
  86. case IRON_PICKAXE:
  87. case STONE_PICKAXE:
  88. case WOOD_PICKAXE:
  89. return true;
  90. default:
  91. return false;
  92. }
  93. }
  94. /**
  95. * Checks if the item is a helmet.
  96. *
  97. * @param is Item to check
  98. * @return true if the item is a helmet, false otherwise
  99. */
  100. public static boolean isHelmet(ItemStack is) {
  101. switch (is.getType()) {
  102. case DIAMOND_HELMET:
  103. case GOLD_HELMET:
  104. case IRON_HELMET:
  105. case LEATHER_HELMET:
  106. return true;
  107. default:
  108. return false;
  109. }
  110. }
  111. /**
  112. * Checks if the item is a chestplate.
  113. *
  114. * @param is Item to check
  115. * @return true if the item is a chestplate, false otherwise
  116. */
  117. public static boolean isChestplate(ItemStack is) {
  118. switch (is.getType()) {
  119. case DIAMOND_CHESTPLATE:
  120. case GOLD_CHESTPLATE:
  121. case IRON_CHESTPLATE:
  122. case LEATHER_CHESTPLATE:
  123. return true;
  124. default:
  125. return false;
  126. }
  127. }
  128. /**
  129. * Checks if the item is a pair of pants.
  130. *
  131. * @param is Item to check
  132. * @return true if the item is a pair of pants, false otherwise
  133. */
  134. public static boolean isPants(ItemStack is) {
  135. switch (is.getType()) {
  136. case DIAMOND_LEGGINGS:
  137. case GOLD_LEGGINGS:
  138. case IRON_LEGGINGS:
  139. case LEATHER_LEGGINGS:
  140. return true;
  141. default:
  142. return false;
  143. }
  144. }
  145. /**
  146. * Checks if the item is a pair of boots.
  147. *
  148. * @param is Item to check
  149. * @return true if the item is a pair of boots, false otherwise
  150. */
  151. public static boolean isBoots(ItemStack is) {
  152. switch (is.getType()) {
  153. case DIAMOND_BOOTS:
  154. case GOLD_BOOTS:
  155. case IRON_BOOTS:
  156. case LEATHER_BOOTS:
  157. return true;
  158. default:
  159. return false;
  160. }
  161. }
  162. }