|
@@ -28,7 +28,7 @@ public class PotionConfig extends ConfigLoader {
|
|
private List<ItemStack> concoctionsIngredientsTierSeven = new ArrayList<ItemStack>();
|
|
private List<ItemStack> concoctionsIngredientsTierSeven = new ArrayList<ItemStack>();
|
|
private List<ItemStack> concoctionsIngredientsTierEight = new ArrayList<ItemStack>();
|
|
private List<ItemStack> concoctionsIngredientsTierEight = new ArrayList<ItemStack>();
|
|
|
|
|
|
- private Map<Short, AlchemyPotion> potionMap = new HashMap<Short, AlchemyPotion>();
|
|
|
|
|
|
+ private Map<String, AlchemyPotion> potionMap = new HashMap<String, AlchemyPotion>();
|
|
|
|
|
|
private PotionConfig() {
|
|
private PotionConfig() {
|
|
super("potions.yml");
|
|
super("potions.yml");
|
|
@@ -90,11 +90,11 @@ public class PotionConfig extends ConfigLoader {
|
|
int pass = 0;
|
|
int pass = 0;
|
|
int fail = 0;
|
|
int fail = 0;
|
|
|
|
|
|
- for (String dataValue : potionSection.getKeys(false)) {
|
|
|
|
- AlchemyPotion potion = loadPotion(potionSection.getConfigurationSection(dataValue));
|
|
|
|
|
|
+ for (String potionName : potionSection.getKeys(false)) {
|
|
|
|
+ AlchemyPotion potion = loadPotion(potionSection.getConfigurationSection(potionName));
|
|
|
|
|
|
if (potion != null) {
|
|
if (potion != null) {
|
|
- potionMap.put(potion.getDataValue(), potion);
|
|
|
|
|
|
+ potionMap.put(potionName, potion);
|
|
pass++;
|
|
pass++;
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
@@ -115,12 +115,20 @@ public class PotionConfig extends ConfigLoader {
|
|
*/
|
|
*/
|
|
private AlchemyPotion loadPotion(ConfigurationSection potion_section) {
|
|
private AlchemyPotion loadPotion(ConfigurationSection potion_section) {
|
|
try {
|
|
try {
|
|
- short dataValue = Short.parseShort(potion_section.getName());
|
|
|
|
|
|
+
|
|
|
|
|
|
String name = potion_section.getString("Name");
|
|
String name = potion_section.getString("Name");
|
|
if (name != null) {
|
|
if (name != null) {
|
|
name = ChatColor.translateAlternateColorCodes('&', name);
|
|
name = ChatColor.translateAlternateColorCodes('&', name);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ short dataValue = Short.parseShort(potion_section.getString("Data"));
|
|
|
|
+
|
|
|
|
+ Material material = Material.POTION;
|
|
|
|
+ String mat = potion_section.getString("Material", null);
|
|
|
|
+ if (mat != null) {
|
|
|
|
+ material = Material.valueOf(mat);
|
|
|
|
+ }
|
|
|
|
|
|
List<String> lore = new ArrayList<String>();
|
|
List<String> lore = new ArrayList<String>();
|
|
if (potion_section.contains("Lore")) {
|
|
if (potion_section.contains("Lore")) {
|
|
@@ -147,12 +155,12 @@ public class PotionConfig extends ConfigLoader {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- Map<ItemStack, Short> children = new HashMap<ItemStack, Short>();
|
|
|
|
|
|
+ Map<ItemStack, String> children = new HashMap<ItemStack, String>();
|
|
if (potion_section.contains("Children")) {
|
|
if (potion_section.contains("Children")) {
|
|
for (String child : potion_section.getConfigurationSection("Children").getKeys(false)) {
|
|
for (String child : potion_section.getConfigurationSection("Children").getKeys(false)) {
|
|
ItemStack ingredient = loadIngredient(child);
|
|
ItemStack ingredient = loadIngredient(child);
|
|
if (ingredient != null) {
|
|
if (ingredient != null) {
|
|
- children.put(ingredient, Short.parseShort(potion_section.getConfigurationSection("Children").getString(child)));
|
|
|
|
|
|
+ children.put(ingredient, potion_section.getConfigurationSection("Children").getString(child));
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
mcMMO.p.getLogger().warning("Failed to parse child for potion " + name + ": " + child);
|
|
mcMMO.p.getLogger().warning("Failed to parse child for potion " + name + ": " + child);
|
|
@@ -160,7 +168,7 @@ public class PotionConfig extends ConfigLoader {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- return new AlchemyPotion(dataValue, name, lore, effects, children);
|
|
|
|
|
|
+ return new AlchemyPotion(material, dataValue, name, lore, effects, children);
|
|
}
|
|
}
|
|
catch (Exception e) {
|
|
catch (Exception e) {
|
|
mcMMO.p.getLogger().warning("Failed to load Alchemy potion: " + potion_section.getName());
|
|
mcMMO.p.getLogger().warning("Failed to load Alchemy potion: " + potion_section.getName());
|
|
@@ -220,7 +228,16 @@ public class PotionConfig extends ConfigLoader {
|
|
return potionMap.containsKey(item.getDurability());
|
|
return potionMap.containsKey(item.getDurability());
|
|
}
|
|
}
|
|
|
|
|
|
- public AlchemyPotion getPotion(short durability) {
|
|
|
|
- return potionMap.get(durability);
|
|
|
|
|
|
+ public AlchemyPotion getPotion(String name) {
|
|
|
|
+ return potionMap.get(name);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public AlchemyPotion getPotion(ItemStack item) {
|
|
|
|
+ for (AlchemyPotion potion : potionMap.values()) {
|
|
|
|
+ if (potion.isSimilar(item)) {
|
|
|
|
+ return potion;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
}
|
|
}
|