Skip to content

Instantly share code, notes, and snippets.

@Crypnotic
Created Sep 10, 2018
Embed
What would you like to do?
@RequiredArgsConstructor
public static enum CropSpec {
BEETROOT(Material.BEETROOT_BLOCK, Material.BEETROOT, Material.BEETROOT_SEEDS),
CARROT(Material.CARROT, Material.CARROT_ITEM, Material.CARROT_ITEM),
NETHER_WARTS(Material.NETHER_WART_BLOCK, Material.NETHER_WARTS, Material.NETHER_WARTS),
POTATO(Material.POTATO, Material.POTATO_ITEM, Material.POTATO_ITEM),
WHEAT(Material.CROPS, Material.WHEAT, Material.SEEDS);
@Getter
private final Material block;
@Getter
private final Material product;
@Getter
private final Material seed;
public static boolean isCrop(Material material) {
for (CropSpec type : values()) {
if (type.getBlock() == material) {
return true;
}
}
return false;
}
public static CropSpec getCropSpec(Material material) {
for (CropSpec type : values()) {
if (type.getBlock() == material) {
return type;
}
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment