From 29350096344be12b22cbcc01cdac8cacddf0be36 Mon Sep 17 00:00:00 2001 From: Christian Koop Date: Sun, 25 Jun 2023 15:58:13 +0200 Subject: [PATCH] Implement `getYieldForCrop` and `getSeedForCrop` in CompatibleMaterial Similar methods with different names existed before and are used in EpicFarming. I decided on keeping them in here instead of moving them to the plugin. --- .../compatibility/CompatibleMaterial.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/Compatibility/src/main/java/com/craftaro/core/compatibility/CompatibleMaterial.java b/Compatibility/src/main/java/com/craftaro/core/compatibility/CompatibleMaterial.java index 3ae296a8..9dace49d 100644 --- a/Compatibility/src/main/java/com/craftaro/core/compatibility/CompatibleMaterial.java +++ b/Compatibility/src/main/java/com/craftaro/core/compatibility/CompatibleMaterial.java @@ -42,6 +42,66 @@ public class CompatibleMaterial { return getMaterial(type.name() + "_SPAWN_EGG"); } + public static @Nullable XMaterial getYieldForCrop(XMaterial material) { + switch (material) { + case BEETROOTS: + return XMaterial.BEETROOT; + case CACTUS: + return XMaterial.CACTUS; + case CARROTS: + return XMaterial.CARROT; + case CHORUS_FLOWER: + return XMaterial.CHORUS_PLANT; + case KELP: + return XMaterial.KELP; + case MELON_STEM: + return XMaterial.MELON; + case NETHER_WART: + return XMaterial.NETHER_WART; + case POTATOES: + return XMaterial.POTATO; + case PUMPKIN_STEM: + return XMaterial.PUMPKIN; + case SUGAR_CANE: + return XMaterial.SUGAR_CANE; + case WHEAT: + return XMaterial.WHEAT; + + default: + return null; + } + } + + public static @Nullable XMaterial getSeedForCrop(XMaterial material) { + switch (material) { + case BEETROOTS: + return XMaterial.BEETROOT_SEEDS; + case CACTUS: + return XMaterial.CACTUS; + case CARROTS: + return XMaterial.CARROT; + case CHORUS_PLANT: + return XMaterial.CHORUS_FLOWER; + case KELP: + return XMaterial.KELP; + case MELON_STEM: + return XMaterial.MELON_SEEDS; + case NETHER_WART: + return XMaterial.NETHER_WART; + case POTATOES: + return XMaterial.POTATO; + case PUMPKIN_STEM: + return XMaterial.PUMPKIN_SEEDS; + case SUGAR_CANE: + return XMaterial.SUGAR_CANE; + case WHEAT: + return XMaterial.WHEAT_SEEDS; + + default: + return null; + } + } + /** * TODO: Check if used by ItemUtils when ready for Core v3 and if yes maybe re-implement to not need manual updating */