diff --git a/src/main/java/com/gmail/nossr50/config/treasure/TreasureFactory.java b/src/main/java/com/gmail/nossr50/config/treasure/TreasureFactory.java index 9fb983392..1382aa8f6 100644 --- a/src/main/java/com/gmail/nossr50/config/treasure/TreasureFactory.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/TreasureFactory.java @@ -9,6 +9,9 @@ import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.PotionMeta; +import org.bukkit.potion.PotionData; +import org.bukkit.potion.PotionType; import java.util.ArrayList; import java.util.List; @@ -48,6 +51,11 @@ public class TreasureFactory { private static ItemStack makeItemStack(Material material, int dropAmount, String customName, ConfigurationNode customLore) { ItemStack treasure = new ItemStack(material, dropAmount); + /* IF FOR SOME REASON ITS A POTION */ + + /*if(isPotion(material)) + treasure = makePotionItemStack(material, dropAmount, customName, customLore);*/ + /* ADD CUSTOM NAME */ if(customName != null) { @@ -75,10 +83,57 @@ public class TreasureFactory { } } - /* IF FOR SOME REASON ITS A POTION */ + //TODO: Do this later return treasure; } + + private static boolean isPotion(Material material) + { + switch(material) + { + case POTION: + case SPLASH_POTION: + case LINGERING_POTION: + return true; + default: + return false; + } + } + + /*private static ItemStack makePotionItemStack(ItemStack itemStack, Material material, int dropAmount, String customName, ConfigurationNode customLore) + { + //TODO: Rewrite this... + Material mat = Material.matchMaterial(materialName); + + itemStack = new ItemStack(mat, amount, data); + PotionMeta itemMeta = (PotionMeta) itemStack.getItemMeta(); + + PotionType potionType = null; + try { + potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER")); + } catch (IllegalArgumentException ex) { + reason.add("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER")); + } + boolean extended = config.getBoolean(type + "." + treasureName + ".PotionData.Extended", false); + boolean upgraded = config.getBoolean(type + "." + treasureName + ".PotionData.Upgraded", false); + itemMeta.setBasePotionData(new PotionData(potionType, extended, upgraded)); + + if (config.contains(type + "." + treasureName + ".Custom_Name")) { + itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name"))); + } + + if (config.contains(type + "." + treasureName + ".Lore")) { + List lore = new ArrayList(); + for (String s : config.getStringList(type + "." + treasureName + ".Lore")) { + lore.add(ChatColor.translateAlternateColorCodes('&', s)); + } + itemMeta.setLore(lore); + } + itemStack.setItemMeta(itemMeta); + + return itemStack; + }*/ }