Yes there is the Material Enum in the Spigot API, you can just use .getType() on the ItemStack to get the Material of it. But this does not include the meta data.
You could create your own enum like this:
public enum SpecialItems(){
ITEM1(new ItemStack(Material.ACACIA_BOAT));
private ItemStack itemStack;
public SpecialItems(ItemStack itemStack){
this.itemStack = itemStack;
}
public ItemStack getItemStack(){
return itemStack;
}
}
You would get the ItemStack like this:
SpecialItems.ITEM1.getItemStack();
In the construtor you can add other values if you want to. But i think this peace of code should demonstrate probably how the concept works, otherwise take a look at the explanation of an enum by java: Java Explanation.
Further, the get method should not be static beauce every enumarted thing in your enum is an object (/ an instance of the enum) and without static your method operates on the object. But the variable you want to return with the get method is only accable by the object, thus you don not want to use static in this method.
But be careful with compairing the ItemStacks of the enum and of the player hand because the ItemStack includes the amount of Items.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…