From 755787f9ee9d4c0b6a7e620992255a642addba85 Mon Sep 17 00:00:00 2001 From: t00thpick1 Date: Sat, 10 Jun 2017 14:30:06 -0400 Subject: [PATCH] Add sapling types --- .../nossr50/config/treasure/TreasureConfig.java | 6 +++++- .../java/com/gmail/nossr50/util/StringUtils.java | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java b/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java index 64e786259..7f1ecea26 100755 --- a/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java @@ -7,6 +7,7 @@ import java.util.List; import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; +import org.bukkit.TreeSpecies; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EntityType; @@ -314,7 +315,10 @@ public class TreasureConfig extends ConfigLoader { if (dropper.equals("Bushes")) { AddHylianTreasure("Small_Fern", hylianTreasure); AddHylianTreasure("Small_Grass", hylianTreasure); - AddHylianTreasure(StringUtils.getPrettyItemString(Material.SAPLING), hylianTreasure); + for (TreeSpecies species : TreeSpecies.values()) { + AddHylianTreasure(StringUtils.getPrettyTreeSpeciesString(species) + "_Sapling", hylianTreasure); + } + AddHylianTreasure(StringUtils.getPrettyItemString(Material.DEAD_BUSH), hylianTreasure); continue; } diff --git a/src/main/java/com/gmail/nossr50/util/StringUtils.java b/src/main/java/com/gmail/nossr50/util/StringUtils.java index 44b0fbed4..280915e2f 100644 --- a/src/main/java/com/gmail/nossr50/util/StringUtils.java +++ b/src/main/java/com/gmail/nossr50/util/StringUtils.java @@ -11,6 +11,7 @@ import org.bukkit.material.Crops; import org.bukkit.material.LongGrass; import org.bukkit.material.MaterialData; import org.bukkit.material.NetherWarts; +import org.bukkit.material.Sapling; import org.bukkit.material.Tree; import org.bukkit.material.CocoaPlant.CocoaPlantSize; @@ -292,19 +293,28 @@ public class StringUtils { if (((Crops) data).getState() == CropState.RIPE) { return getPrettyItemString(data.getItemType()).replace(" ", "_"); } - return getPrettyItemString(data.getItemType()).replace(" ", "_") + "_UNGROWN"; + return getPrettyItemString(data.getItemType()).replace(" ", "_") + "_Ungrown"; } case NETHER_WARTS : { if (((NetherWarts) data).getState() == NetherWartsState.RIPE) { return getPrettyItemString(data.getItemType()).replace(" ", "_"); } - return getPrettyItemString(data.getItemType()).replace(" ", "_") + "_UNGROWN"; + return getPrettyItemString(data.getItemType()).replace(" ", "_") + "_Ungrown"; } case COCOA : { if (((CocoaPlant) data).getSize() == CocoaPlantSize.LARGE) { return getPrettyItemString(data.getItemType()).replace(" ", "_"); } - return getPrettyItemString(data.getItemType()).replace(" ", "_") + "_UNGROWN"; + return getPrettyItemString(data.getItemType()).replace(" ", "_") + "_Ungrown"; + } + case SAPLING: + { + TreeSpecies species = TreeSpecies.GENERIC; + if (data instanceof Sapling) { + Sapling sapling = (Sapling) data; + species = sapling.getSpecies(); + } + return createPrettyEnumString(species.name()).replace(" ", "_") + "_Sapling"; } case SMOOTH_BRICK : case WOOL :