mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-28 03:34:43 +02:00
Update Alchemy for 1.9 Configuration style has changed, but theoretically old version should still work I think.
This commit is contained in:
@ -28,7 +28,7 @@ public class PotionConfig extends ConfigLoader {
|
||||
private List<ItemStack> concoctionsIngredientsTierSeven = 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() {
|
||||
super("potions.yml");
|
||||
@ -90,11 +90,11 @@ public class PotionConfig extends ConfigLoader {
|
||||
int pass = 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) {
|
||||
potionMap.put(potion.getDataValue(), potion);
|
||||
potionMap.put(potionName, potion);
|
||||
pass++;
|
||||
}
|
||||
else {
|
||||
@ -115,12 +115,20 @@ public class PotionConfig extends ConfigLoader {
|
||||
*/
|
||||
private AlchemyPotion loadPotion(ConfigurationSection potion_section) {
|
||||
try {
|
||||
short dataValue = Short.parseShort(potion_section.getName());
|
||||
|
||||
|
||||
String name = potion_section.getString("Name");
|
||||
if (name != null) {
|
||||
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>();
|
||||
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")) {
|
||||
for (String child : potion_section.getConfigurationSection("Children").getKeys(false)) {
|
||||
ItemStack ingredient = loadIngredient(child);
|
||||
if (ingredient != null) {
|
||||
children.put(ingredient, Short.parseShort(potion_section.getConfigurationSection("Children").getString(child)));
|
||||
children.put(ingredient, potion_section.getConfigurationSection("Children").getString(child));
|
||||
}
|
||||
else {
|
||||
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) {
|
||||
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());
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user