How can I check if a players held item is of a specific item type - for example an axe. (can be iron axe, gold axe, wooden axe, etc.)?
Or do I have to do multiple if statements to have this done?
@EventHandler(priority= EventPriority.HIGH)
public void onInteract(PlayerInteractEvent event){
Player p = event.getPlayer();
ItemStack heldItem = p.getInventory().getItemInMainHand();
if(heldItem.getType() == Material.DIAMOND_AXE){ //I dont want to do multiple if statements for multiple type of Axes
//...
} //other if statement for Material.WOODEN_AXE etc.
}
Material m = heldItem.getType(); if(m == Material.DIAMOND_AXE || m == Material.WOODEN_AXE || m == Material.GOLD_AXE || ...){ /* It is one of the axe types */ }
I however don't know enough about Minecraft programming to know whether this is the best solution. It is merely ~a~ solution. \$\endgroup\$