Skip to content

Instantly share code, notes, and snippets.

@Crypnotic
Created September 10, 2018 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Crypnotic/787e1abd191a96c36d822a2a551eb239 to your computer and use it in GitHub Desktop.
Save Crypnotic/787e1abd191a96c36d822a2a551eb239 to your computer and use it in GitHub Desktop.
@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