use of org.spongepowered.api.data.type.ToolType in project SpongeCommon by SpongePowered.
the class ToolTypePropertyStore method getFor.
@Override
protected Optional<ToolTypeProperty> getFor(ItemStack itemStack) {
if (itemStack.getItem() instanceof ItemTool) {
final ItemTool tool = (ItemTool) itemStack.getItem();
final Item.ToolMaterial toolMaterial = tool.toolMaterial;
return Optional.of(new ToolTypeProperty((ToolType) (Object) toolMaterial));
} else if (itemStack.getItem() instanceof ItemSword) {
final ItemSword itemSword = (ItemSword) itemStack.getItem();
final Item.ToolMaterial swordMaterial = itemSword.material;
return Optional.of(new ToolTypeProperty((ToolType) (Object) swordMaterial));
} else if (itemStack.getItem() instanceof ItemHoe) {
final ItemHoe itemHoe = (ItemHoe) itemStack.getItem();
final Item.ToolMaterial hoeMaterial = itemHoe.toolMaterial;
return Optional.of(new ToolTypeProperty((ToolType) (Object) hoeMaterial));
}
return Optional.empty();
}