Only grab List<String> if it's a proper list

This commit is contained in:
nossr50 2019-02-26 16:15:40 -08:00
parent 4ab5e5e925
commit 049b76f651
9 changed files with 304 additions and 320 deletions

View File

@ -4,8 +4,6 @@ import com.gmail.nossr50.mcMMO;
import com.google.common.io.Files; import com.google.common.io.Files;
import com.google.common.reflect.TypeToken; import com.google.common.reflect.TypeToken;
import ninja.leaping.configurate.ConfigurationNode; import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
import ninja.leaping.configurate.loader.ConfigurationLoader;
import ninja.leaping.configurate.objectmapping.ObjectMappingException; import ninja.leaping.configurate.objectmapping.ObjectMappingException;
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader; import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.DumperOptions;
@ -415,12 +413,16 @@ public abstract class Config implements VersionedConfig, Unload {
} }
/** /**
* Gets a a List of type String from the Configuration file * Returns the children of a specific node
* @param path path to the node * @param path the path to the parent node
* @return a list of strings at the node, if null it will most likely zero initialize (empty list) * @return the list of children for the target parent node
* @throws ObjectMappingException
*/ */
public List<String> getStringValueList(String... path) throws ObjectMappingException { public List<? extends ConfigurationNode> getChildren(String... path) {
return userRootNode.getList(TypeToken.of(String.class)); return userRootNode.getNode(path).getChildrenList();
}
public List<String> getListFromNode(String... path) throws ObjectMappingException
{
return userRootNode.getNode(path).getList(TypeToken.of(String.class));
} }
} }

View File

@ -8,7 +8,7 @@ import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory; import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
import ninja.leaping.configurate.objectmapping.ObjectMappingException; import ninja.leaping.configurate.ConfigurationNode;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -48,171 +48,168 @@ public class RepairConfig extends ConfigCollection {
@Override @Override
public void register() { public void register() {
try { //Grab the "keys" under the Repairables node
//Grab the "keys" under the Repairables node ArrayList<ConfigurationNode> repairChildrenNodes = new ArrayList<>(getChildren(REPAIRABLES));
ArrayList<String> keys = new ArrayList<>(getStringValueList(REPAIRABLES));
//TODO: Remove Debug //TODO: Remove Debug
if(keys.size() <= 0) { if(repairChildrenNodes.size() <= 0) {
mcMMO.p.getLogger().severe("DEBUG: Repair MultiConfigContainer key list is empty"); mcMMO.p.getLogger().severe("DEBUG: Repair MultiConfigContainer key list is empty");
return; return;
}
for (ConfigurationNode repairNode : repairChildrenNodes) {
// Validate all the things!
List<String> errorMessages = new ArrayList<String>();
/*
* Match the name of the key to a Material constant definition
*/
String repairChildNodeName = repairNode.getString();
Material itemMaterial = Material.matchMaterial(repairChildNodeName);
if (itemMaterial == null) {
mcMMO.p.getLogger().severe("Repair Invalid material: " + repairChildNodeName);
continue;
} }
for (String key : keys) { /*
// Validate all the things! * Determine Repair Material Type
List<String> errorMessages = new ArrayList<String>(); */
MaterialType repairMaterialType = MaterialType.OTHER;
String repairMaterialTypeString = getRepairMaterialTypeString(repairChildNodeName);
/* if (hasNode(REPAIRABLES, repairChildNodeName, MATERIAL_TYPE)) {
* Match the name of the key to a Material constant definition ItemStack repairItem = new ItemStack(itemMaterial);
*/
Material itemMaterial = Material.matchMaterial(key);
if (itemMaterial == null) { if (ItemUtils.isWoodTool(repairItem)) {
mcMMO.p.getLogger().severe("Repair Invalid material: " + key); repairMaterialType = MaterialType.WOOD;
}
else if (ItemUtils.isStoneTool(repairItem)) {
repairMaterialType = MaterialType.STONE;
}
else if (ItemUtils.isStringTool(repairItem)) {
repairMaterialType = MaterialType.STRING;
}
else if (ItemUtils.isLeatherArmor(repairItem)) {
repairMaterialType = MaterialType.LEATHER;
}
else if (ItemUtils.isIronArmor(repairItem) || ItemUtils.isIronTool(repairItem)) {
repairMaterialType = MaterialType.IRON;
}
else if (ItemUtils.isGoldArmor(repairItem) || ItemUtils.isGoldTool(repairItem)) {
repairMaterialType = MaterialType.GOLD;
}
else if (ItemUtils.isDiamondArmor(repairItem) || ItemUtils.isDiamondTool(repairItem)) {
repairMaterialType = MaterialType.DIAMOND;
}
}
else {
//If a material cannot be matched, try matching the material to its repair material type string from the config
try {
repairMaterialType = MaterialType.valueOf(repairMaterialTypeString.toUpperCase());
}
catch (IllegalArgumentException ex) {
errorMessages.add("Repair Config: " + repairChildNodeName + " has an invalid " + MATERIAL_TYPE + " of " + repairMaterialTypeString);
continue; continue;
} }
}
/* // Repair Material
* Determine Repair Material Type String repairMaterialName = getRepairMaterialStringName(repairChildNodeName);
*/ Material repairMaterial = (repairMaterialName == null ? repairMaterialType.getDefaultMaterial() : Material.matchMaterial(repairMaterialName));
MaterialType repairMaterialType = MaterialType.OTHER;
String repairMaterialTypeString = getRepairMaterialTypeString(key);
if (hasNode(REPAIRABLES, key, MATERIAL_TYPE)) { if (repairMaterial == null) {
ItemStack repairItem = new ItemStack(itemMaterial); errorMessages.add(repairChildNodeName + " has an invalid repair material: " + repairMaterialName);
}
if (ItemUtils.isWoodTool(repairItem)) { // Maximum Durability
repairMaterialType = MaterialType.WOOD; short maximumDurability = (itemMaterial != null ? itemMaterial.getMaxDurability() : getRepairableMaximumDurability(repairChildNodeName));
}
else if (ItemUtils.isStoneTool(repairItem)) { if (maximumDurability <= 0) {
repairMaterialType = MaterialType.STONE; maximumDurability = getRepairableMaximumDurability(repairChildNodeName);
} }
else if (ItemUtils.isStringTool(repairItem)) {
repairMaterialType = MaterialType.STRING; if (maximumDurability <= 0) {
} errorMessages.add("Maximum durability of " + repairChildNodeName + " must be greater than 0!");
else if (ItemUtils.isLeatherArmor(repairItem)) { }
repairMaterialType = MaterialType.LEATHER;
} // Item Type
else if (ItemUtils.isIronArmor(repairItem) || ItemUtils.isIronTool(repairItem)) { ItemType repairItemType = ItemType.OTHER;
repairMaterialType = MaterialType.IRON; String repairItemTypeString = "";
}
else if (ItemUtils.isGoldArmor(repairItem) || ItemUtils.isGoldTool(repairItem)) { if(hasNode(REPAIRABLES, repairChildNodeName, ITEM_TYPE))
repairMaterialType = MaterialType.GOLD; repairItemTypeString = getStringValue(REPAIRABLES, repairChildNodeName, ITEM_TYPE);
} else
else if (ItemUtils.isDiamondArmor(repairItem) || ItemUtils.isDiamondTool(repairItem)) { repairItemTypeString = "OTHER";
repairMaterialType = MaterialType.DIAMOND;
} if (!hasNode(REPAIRABLES, repairChildNodeName, ITEM_TYPE) && itemMaterial != null) {
ItemStack repairItem = new ItemStack(itemMaterial);
if (ItemUtils.isMinecraftTool(repairItem)) {
repairItemType = ItemType.TOOL;
} }
else { else if (ItemUtils.isArmor(repairItem)) {
//If a material cannot be matched, try matching the material to its repair material type string from the config repairItemType = ItemType.ARMOR;
try {
repairMaterialType = MaterialType.valueOf(repairMaterialTypeString.toUpperCase());
}
catch (IllegalArgumentException ex) {
errorMessages.add("Repair Config: " + key + " has an invalid " + MATERIAL_TYPE + " of " + repairMaterialTypeString);
continue;
}
}
// Repair Material
String repairMaterialName = getRepairMaterialStringName(key);
Material repairMaterial = (repairMaterialName == null ? repairMaterialType.getDefaultMaterial() : Material.matchMaterial(repairMaterialName));
if (repairMaterial == null) {
errorMessages.add(key + " has an invalid repair material: " + repairMaterialName);
}
// Maximum Durability
short maximumDurability = (itemMaterial != null ? itemMaterial.getMaxDurability() : getRepairableMaximumDurability(key));
if (maximumDurability <= 0) {
maximumDurability = getRepairableMaximumDurability(key);
}
if (maximumDurability <= 0) {
errorMessages.add("Maximum durability of " + key + " must be greater than 0!");
}
// Item Type
ItemType repairItemType = ItemType.OTHER;
String repairItemTypeString = "";
if(hasNode(REPAIRABLES, key, ITEM_TYPE))
repairItemTypeString = getStringValue(REPAIRABLES, key, ITEM_TYPE);
else
repairItemTypeString = "OTHER";
if (!hasNode(REPAIRABLES, key, ITEM_TYPE) && itemMaterial != null) {
ItemStack repairItem = new ItemStack(itemMaterial);
if (ItemUtils.isMinecraftTool(repairItem)) {
repairItemType = ItemType.TOOL;
}
else if (ItemUtils.isArmor(repairItem)) {
repairItemType = ItemType.ARMOR;
}
}
else {
try {
repairItemType = ItemType.valueOf(repairItemTypeString);
}
catch (IllegalArgumentException ex) {
errorMessages.add(key + " has an invalid ItemType of " + repairItemTypeString);
}
}
byte repairMetadata = -1;
//Set the metadata byte
if(hasNode(REPAIRABLES, key, REPAIR_MATERIAL, METADATA))
repairMetadata = (byte) getIntValue(REPAIRABLES, key, REPAIR_MATERIAL, METADATA);
int minimumLevel = getIntValue(REPAIRABLES, key, MINIMUM_LEVEL);
double xpMultiplier = 1;
if(hasNode(REPAIRABLES, key, XP_MULTIPLIER))
xpMultiplier = getDoubleValue(REPAIRABLES, key, XP_MULTIPLIER);
// Minimum Quantity
int minimumQuantity = SkillUtils.getRepairAndSalvageQuantities(new ItemStack(itemMaterial), repairMaterial, repairMetadata);
if (minimumQuantity <= 0) {
minimumQuantity = getIntValue(REPAIRABLES, key, MINIMUM_QUANTITY);
}
/*
* VALIDATE
* Just make sure the values we may have just grabbed from the config aren't below 0
*/
//Validate min level
if(minimumLevel < 0)
minimumLevel = 0;
//Validate XP Mult
if(xpMultiplier < 0)
xpMultiplier = 0;
//Validate Minimum Quantity
if (minimumQuantity <= 0) {
minimumQuantity = 2;
errorMessages.add("Minimum quantity for "+key+" in repair config should be above 0");
}
Repairable repairable = RepairableFactory.getRepairable(itemMaterial, repairMaterial, repairMetadata, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
genericCollection.add(repairable);
for (String error : errorMessages) {
//McmmoCore.getLogger().warning(issue);
mcMMO.p.getLogger().warning(error);
} }
} }
} catch (ObjectMappingException e) { else {
e.printStackTrace(); try {
repairItemType = ItemType.valueOf(repairItemTypeString);
}
catch (IllegalArgumentException ex) {
errorMessages.add(repairChildNodeName + " has an invalid ItemType of " + repairItemTypeString);
}
}
byte repairMetadata = -1;
//Set the metadata byte
if(hasNode(REPAIRABLES, repairChildNodeName, REPAIR_MATERIAL, METADATA))
repairMetadata = (byte) getIntValue(REPAIRABLES, repairChildNodeName, REPAIR_MATERIAL, METADATA);
int minimumLevel = getIntValue(REPAIRABLES, repairChildNodeName, MINIMUM_LEVEL);
double xpMultiplier = 1;
if(hasNode(REPAIRABLES, repairChildNodeName, XP_MULTIPLIER))
xpMultiplier = getDoubleValue(REPAIRABLES, repairChildNodeName, XP_MULTIPLIER);
// Minimum Quantity
int minimumQuantity = SkillUtils.getRepairAndSalvageQuantities(new ItemStack(itemMaterial), repairMaterial, repairMetadata);
if (minimumQuantity <= 0) {
minimumQuantity = getIntValue(REPAIRABLES, repairChildNodeName, MINIMUM_QUANTITY);
}
/*
* VALIDATE
* Just make sure the values we may have just grabbed from the config aren't below 0
*/
//Validate min level
if(minimumLevel < 0)
minimumLevel = 0;
//Validate XP Mult
if(xpMultiplier < 0)
xpMultiplier = 0;
//Validate Minimum Quantity
if (minimumQuantity <= 0) {
minimumQuantity = 2;
errorMessages.add("Minimum quantity for "+repairChildNodeName+" in repair config should be above 0");
}
Repairable repairable = RepairableFactory.getRepairable(itemMaterial, repairMaterial, repairMetadata, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
genericCollection.add(repairable);
for (String error : errorMessages) {
//McmmoCore.getLogger().warning(issue);
mcMMO.p.getLogger().warning(error);
}
} }
} }

View File

@ -8,7 +8,7 @@ import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
import com.gmail.nossr50.skills.salvage.salvageables.SalvageableFactory; import com.gmail.nossr50.skills.salvage.salvageables.SalvageableFactory;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
import ninja.leaping.configurate.objectmapping.ObjectMappingException; import ninja.leaping.configurate.ConfigurationNode;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -44,138 +44,133 @@ public class SalvageConfig extends ConfigCollection {
@Override @Override
public void register() { public void register() {
//Grab the "keys" under the Repairables node
ArrayList<ConfigurationNode> salvageChildrenNodes = new ArrayList<>(getChildren(SALVAGEABLES));
try { for (ConfigurationNode salvageChildNode : salvageChildrenNodes) {
//Grab the "keys" under the Repairables node // Validate all the things!
ArrayList<String> keys = new ArrayList<>(getStringValueList(SALVAGEABLES)); List<String> errorMessages = new ArrayList<String>();
for (String key : keys) { // ItemStack Material
// Validate all the things! String salvageChildNodeName = salvageChildNode.getString();
List<String> errorMessages = new ArrayList<String>(); Material itemMaterial = Material.matchMaterial(salvageChildNodeName);
// ItemStack Material if (itemMaterial == null) {
Material itemMaterial = Material.matchMaterial(key); errorMessages.add("Salvage Config: Invalid material - " + salvageChildNodeName);
continue;
}
if (itemMaterial == null) { // Salvage Material Type
errorMessages.add("Salvage Config: Invalid material - " + key); MaterialType salvageMaterialType = MaterialType.OTHER;
continue;
String salvageMaterialTypeString;
if(hasNode(SALVAGEABLES, salvageChildNodeName, MATERIAL_TYPE))
salvageMaterialTypeString = getStringValue(SALVAGEABLES, salvageChildNodeName, MATERIAL_TYPE);
else
salvageMaterialTypeString = "OTHER";
if (!hasNode(SALVAGEABLES, salvageChildNodeName, MATERIAL_TYPE)) {
ItemStack salvageItem = new ItemStack(itemMaterial);
if (ItemUtils.isWoodTool(salvageItem)) {
salvageMaterialType = MaterialType.WOOD;
} else if (ItemUtils.isStoneTool(salvageItem)) {
salvageMaterialType = MaterialType.STONE;
} else if (ItemUtils.isStringTool(salvageItem)) {
salvageMaterialType = MaterialType.STRING;
} else if (ItemUtils.isLeatherArmor(salvageItem)) {
salvageMaterialType = MaterialType.LEATHER;
} else if (ItemUtils.isIronArmor(salvageItem) || ItemUtils.isIronTool(salvageItem)) {
salvageMaterialType = MaterialType.IRON;
} else if (ItemUtils.isGoldArmor(salvageItem) || ItemUtils.isGoldTool(salvageItem)) {
salvageMaterialType = MaterialType.GOLD;
} else if (ItemUtils.isDiamondArmor(salvageItem) || ItemUtils.isDiamondTool(salvageItem)) {
salvageMaterialType = MaterialType.DIAMOND;
} }
} else {
// Salvage Material Type try {
MaterialType salvageMaterialType = MaterialType.OTHER; salvageMaterialType = MaterialType.valueOf(salvageMaterialTypeString.replace(" ", "_").toUpperCase());
} catch (IllegalArgumentException ex) {
String salvageMaterialTypeString; errorMessages.add("Salvage Config: " + salvageChildNodeName + " has an invalid MaterialType of " + salvageMaterialTypeString);
if(hasNode(SALVAGEABLES, key, MATERIAL_TYPE))
salvageMaterialTypeString = getStringValue(SALVAGEABLES, key, MATERIAL_TYPE);
else
salvageMaterialTypeString = "OTHER";
if (!hasNode(SALVAGEABLES, key, MATERIAL_TYPE)) {
ItemStack salvageItem = new ItemStack(itemMaterial);
if (ItemUtils.isWoodTool(salvageItem)) {
salvageMaterialType = MaterialType.WOOD;
} else if (ItemUtils.isStoneTool(salvageItem)) {
salvageMaterialType = MaterialType.STONE;
} else if (ItemUtils.isStringTool(salvageItem)) {
salvageMaterialType = MaterialType.STRING;
} else if (ItemUtils.isLeatherArmor(salvageItem)) {
salvageMaterialType = MaterialType.LEATHER;
} else if (ItemUtils.isIronArmor(salvageItem) || ItemUtils.isIronTool(salvageItem)) {
salvageMaterialType = MaterialType.IRON;
} else if (ItemUtils.isGoldArmor(salvageItem) || ItemUtils.isGoldTool(salvageItem)) {
salvageMaterialType = MaterialType.GOLD;
} else if (ItemUtils.isDiamondArmor(salvageItem) || ItemUtils.isDiamondTool(salvageItem)) {
salvageMaterialType = MaterialType.DIAMOND;
}
} else {
try {
salvageMaterialType = MaterialType.valueOf(salvageMaterialTypeString.replace(" ", "_").toUpperCase());
} catch (IllegalArgumentException ex) {
errorMessages.add("Salvage Config: " + key + " has an invalid MaterialType of " + salvageMaterialTypeString);
}
}
// Salvage Material
String salvageMaterialName = getStringValue(SALVAGEABLES, key, SALVAGE_MATERIAL);
Material salvageMaterial = (salvageMaterialName == null ? salvageMaterialType.getDefaultMaterial() : Material.matchMaterial(salvageMaterialName));
if (salvageMaterial == null) {
errorMessages.add(key + " has an invalid salvage material: " + salvageMaterialName);
continue;
}
// Maximum Durability
short maximumDurability = itemMaterial.getMaxDurability();
// ItemStack Type
ItemType salvageItemType = ItemType.OTHER;
String salvageItemTypeString;
if(hasNode(SALVAGEABLES, key, ITEM_TYPE))
salvageItemTypeString = getStringValue(SALVAGEABLES, key, ITEM_TYPE);
else
salvageItemTypeString = "OTHER";
if (!hasNode(SALVAGEABLES, key, ITEM_TYPE)) {
ItemStack salvageItem = new ItemStack(itemMaterial);
if (ItemUtils.isMinecraftTool(salvageItem)) {
salvageItemType = ItemType.TOOL;
} else if (ItemUtils.isArmor(salvageItem)) {
salvageItemType = ItemType.ARMOR;
}
} else {
try {
salvageItemType = ItemType.valueOf(salvageItemTypeString.replace(" ", "_").toUpperCase());
} catch (IllegalArgumentException ex) {
errorMessages.add("Salvage Config: " + key + " has an invalid " + ITEM_TYPE + " of " + salvageItemTypeString);
}
}
byte salvageMetadata = -1;
if(hasNode(SALVAGEABLES, key, SALVAGE_MATERIAL, METADATA))
salvageMetadata = (byte) getIntValue(SALVAGEABLES, key, SALVAGE_MATERIAL, METADATA);
int minimumLevel = getIntValue(SALVAGEABLES, key, MINIMUM_LEVEL);
double xpMultiplier = 1;
if(hasNode(SALVAGEABLES, key, XP_MULTIPLIER))
xpMultiplier = getDoubleValue(SALVAGEABLES, key, XP_MULTIPLIER);
// Maximum Quantity
int maximumQuantity = SkillUtils.getRepairAndSalvageQuantities(new ItemStack(itemMaterial), salvageMaterial, salvageMetadata);
if(hasNode(SALVAGEABLES, key, MAXIMUM_QUANTITY))
maximumQuantity = getIntValue(SALVAGEABLES, key, MAXIMUM_QUANTITY);
/*
* VALIDATE
*/
if(minimumLevel < 0)
minimumLevel = 0;
if(maximumQuantity < 0)
maximumQuantity = 1;
if(xpMultiplier < 0)
xpMultiplier = 0;
Salvageable salvageable = SalvageableFactory.getSalvageable(itemMaterial, salvageMaterial, salvageMetadata, minimumLevel, maximumQuantity, maximumDurability, salvageItemType, salvageMaterialType, xpMultiplier);
genericCollection.add(salvageable);
for (String issue : errorMessages) {
mcMMO.p.getLogger().warning(issue);
} }
} }
} catch (ObjectMappingException e) { // Salvage Material
e.printStackTrace(); String salvageMaterialName = getStringValue(SALVAGEABLES, salvageChildNodeName, SALVAGE_MATERIAL);
Material salvageMaterial = (salvageMaterialName == null ? salvageMaterialType.getDefaultMaterial() : Material.matchMaterial(salvageMaterialName));
if (salvageMaterial == null) {
errorMessages.add(salvageChildNodeName + " has an invalid salvage material: " + salvageMaterialName);
continue;
}
// Maximum Durability
short maximumDurability = itemMaterial.getMaxDurability();
// ItemStack Type
ItemType salvageItemType = ItemType.OTHER;
String salvageItemTypeString;
if(hasNode(SALVAGEABLES, salvageChildNodeName, ITEM_TYPE))
salvageItemTypeString = getStringValue(SALVAGEABLES, salvageChildNodeName, ITEM_TYPE);
else
salvageItemTypeString = "OTHER";
if (!hasNode(SALVAGEABLES, salvageChildNodeName, ITEM_TYPE)) {
ItemStack salvageItem = new ItemStack(itemMaterial);
if (ItemUtils.isMinecraftTool(salvageItem)) {
salvageItemType = ItemType.TOOL;
} else if (ItemUtils.isArmor(salvageItem)) {
salvageItemType = ItemType.ARMOR;
}
} else {
try {
salvageItemType = ItemType.valueOf(salvageItemTypeString.replace(" ", "_").toUpperCase());
} catch (IllegalArgumentException ex) {
errorMessages.add("Salvage Config: " + salvageChildNodeName + " has an invalid " + ITEM_TYPE + " of " + salvageItemTypeString);
}
}
byte salvageMetadata = -1;
if(hasNode(SALVAGEABLES, salvageChildNodeName, SALVAGE_MATERIAL, METADATA))
salvageMetadata = (byte) getIntValue(SALVAGEABLES, salvageChildNodeName, SALVAGE_MATERIAL, METADATA);
int minimumLevel = getIntValue(SALVAGEABLES, salvageChildNodeName, MINIMUM_LEVEL);
double xpMultiplier = 1;
if(hasNode(SALVAGEABLES, salvageChildNodeName, XP_MULTIPLIER))
xpMultiplier = getDoubleValue(SALVAGEABLES, salvageChildNodeName, XP_MULTIPLIER);
// Maximum Quantity
int maximumQuantity = SkillUtils.getRepairAndSalvageQuantities(new ItemStack(itemMaterial), salvageMaterial, salvageMetadata);
if(hasNode(SALVAGEABLES, salvageChildNodeName, MAXIMUM_QUANTITY))
maximumQuantity = getIntValue(SALVAGEABLES, salvageChildNodeName, MAXIMUM_QUANTITY);
/*
* VALIDATE
*/
if(minimumLevel < 0)
minimumLevel = 0;
if(maximumQuantity < 0)
maximumQuantity = 1;
if(xpMultiplier < 0)
xpMultiplier = 0;
Salvageable salvageable = SalvageableFactory.getSalvageable(itemMaterial, salvageMaterial, salvageMetadata, minimumLevel, maximumQuantity, maximumDurability, salvageItemType, salvageMaterialType, xpMultiplier);
genericCollection.add(salvageable);
for (String issue : errorMessages) {
mcMMO.p.getLogger().warning(issue);
}
} }
} }

View File

@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage; import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import ninja.leaping.configurate.objectmapping.Setting;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.boss.BarColor; import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle; import org.bukkit.boss.BarStyle;

View File

@ -66,7 +66,7 @@ public class ItemWeightConfig extends Config {
HashSet<Material> miscItems = new HashSet<Material>(); HashSet<Material> miscItems = new HashSet<Material>();
try { try {
for (String item : getStringValueList(PARTY_SHAREABLES, MISC_ITEMS)) { for (String item : getListFromNode(PARTY_SHAREABLES, MISC_ITEMS)) {
Material material = Material.getMaterial(item.toUpperCase()); Material material = Material.getMaterial(item.toUpperCase());
if (material != null) { if (material != null) {

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.config.skills.alchemy; package com.gmail.nossr50.config.skills.alchemy;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.ConfigCollection; import com.gmail.nossr50.config.ConfigCollection;
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion; import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
@ -98,14 +97,14 @@ public class PotionConfig extends ConfigCollection {
private void loadConcoctions() { private void loadConcoctions() {
try { try {
loadConcoctionsTier(concoctionsIngredientsTierOne, getStringValueList(CONCOCTIONS, TIER_ONE_INGREDIENTS)); loadConcoctionsTier(concoctionsIngredientsTierOne, getListFromNode(CONCOCTIONS, TIER_ONE_INGREDIENTS));
loadConcoctionsTier(concoctionsIngredientsTierTwo, getStringValueList(CONCOCTIONS, TIER_TWO_INGREDIENTS)); loadConcoctionsTier(concoctionsIngredientsTierTwo, getListFromNode(CONCOCTIONS, TIER_TWO_INGREDIENTS));
loadConcoctionsTier(concoctionsIngredientsTierThree, getStringValueList(CONCOCTIONS, TIER_THREE_INGREDIENTS)); loadConcoctionsTier(concoctionsIngredientsTierThree, getListFromNode(CONCOCTIONS, TIER_THREE_INGREDIENTS));
loadConcoctionsTier(concoctionsIngredientsTierFour, getStringValueList(CONCOCTIONS, TIER_FOUR_INGREDIENTS)); loadConcoctionsTier(concoctionsIngredientsTierFour, getListFromNode(CONCOCTIONS, TIER_FOUR_INGREDIENTS));
loadConcoctionsTier(concoctionsIngredientsTierFive, getStringValueList(CONCOCTIONS, TIER_FIVE_INGREDIENTS)); loadConcoctionsTier(concoctionsIngredientsTierFive, getListFromNode(CONCOCTIONS, TIER_FIVE_INGREDIENTS));
loadConcoctionsTier(concoctionsIngredientsTierSix, getStringValueList(CONCOCTIONS, TIER_SIX_INGREDIENTS)); loadConcoctionsTier(concoctionsIngredientsTierSix, getListFromNode(CONCOCTIONS, TIER_SIX_INGREDIENTS));
loadConcoctionsTier(concoctionsIngredientsTierSeven, getStringValueList(CONCOCTIONS, TIER_SEVEN_INGREDIENTS)); loadConcoctionsTier(concoctionsIngredientsTierSeven, getListFromNode(CONCOCTIONS, TIER_SEVEN_INGREDIENTS));
loadConcoctionsTier(concoctionsIngredientsTierEight, getStringValueList(CONCOCTIONS, TIER_EIGHT_INGREDIENTS)); loadConcoctionsTier(concoctionsIngredientsTierEight, getListFromNode(CONCOCTIONS, TIER_EIGHT_INGREDIENTS));
concoctionsIngredientsTierTwo.addAll(concoctionsIngredientsTierOne); concoctionsIngredientsTierTwo.addAll(concoctionsIngredientsTierOne);
concoctionsIngredientsTierThree.addAll(concoctionsIngredientsTierTwo); concoctionsIngredientsTierThree.addAll(concoctionsIngredientsTierTwo);
@ -114,15 +113,14 @@ public class PotionConfig extends ConfigCollection {
concoctionsIngredientsTierSix.addAll(concoctionsIngredientsTierFive); concoctionsIngredientsTierSix.addAll(concoctionsIngredientsTierFive);
concoctionsIngredientsTierSeven.addAll(concoctionsIngredientsTierSix); concoctionsIngredientsTierSeven.addAll(concoctionsIngredientsTierSix);
concoctionsIngredientsTierEight.addAll(concoctionsIngredientsTierSeven); concoctionsIngredientsTierEight.addAll(concoctionsIngredientsTierSeven);
} catch (ObjectMappingException e) { } catch (ObjectMappingException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
private void loadConcoctionsTier(List<ItemStack> ingredientList, List<String> ingredientStrings) { private void loadConcoctionsTier(List<ItemStack> ingredientList, List<String> ingredients) {
if (ingredientStrings != null && ingredientStrings.size() > 0) { if (ingredients != null && ingredients.size() > 0) {
for (String ingredientString : ingredientStrings) { for (String ingredientString : ingredients) {
ItemStack ingredient = loadIngredient(ingredientString); ItemStack ingredient = loadIngredient(ingredientString);
if (ingredient != null) { if (ingredient != null) {
@ -140,23 +138,20 @@ public class PotionConfig extends ConfigCollection {
int pass = 0; int pass = 0;
int fail = 0; int fail = 0;
try { for (ConfigurationNode potionNode : getChildren(POTIONS)) {
for (String potionName : getStringValueList(POTIONS)) { //Grab the child node corresponding to this potion
//Grab the child node corresponding to this potion String potionName = potionNode.getString();
AlchemyPotion potion = loadPotion(getUserRootNode().getNode(POTIONS, potionName)); AlchemyPotion potion = loadPotion(getUserRootNode().getNode(POTIONS, potionName));
if (potion != null) { if (potion != null) {
potionMap.put(potionName, potion); potionMap.put(potionName, potion);
pass++; pass++;
} else { } else {
fail++; fail++;
}
} }
mcMMO.p.debug("Loaded " + pass + " Alchemy potions, skipped " + fail + ".");
} catch (ObjectMappingException e) {
e.printStackTrace();
} }
mcMMO.p.debug("Loaded " + pass + " Alchemy potions, skipped " + fail + ".");
} }
/** /**

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.datatypes.MobHealthbarType; import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.database.DatabaseType; import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.database.PlayerStat; import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.database.UpgradeType;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.player.UniqueDataType; import com.gmail.nossr50.datatypes.player.UniqueDataType;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;

View File

@ -2,14 +2,12 @@ package com.gmail.nossr50.party;
import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.datatypes.chat.ChatMode; import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.database.UpgradeType;
import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.party.ItemShareType; import com.gmail.nossr50.datatypes.party.ItemShareType;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyLeader; import com.gmail.nossr50.datatypes.party.PartyLeader;
import com.gmail.nossr50.datatypes.party.ShareMode; import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.events.party.McMMOPartyAllianceChangeEvent; import com.gmail.nossr50.events.party.McMMOPartyAllianceChangeEvent;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.skills.fishing; package com.gmail.nossr50.skills.fishing;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.treasure.FishingTreasureConfig; import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure; import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;