mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
Only grab List<String> if it's a proper list
This commit is contained in:
parent
4ab5e5e925
commit
049b76f651
@ -4,8 +4,6 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
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.yaml.YAMLConfigurationLoader;
|
||||
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
|
||||
* @param path path to the node
|
||||
* @return a list of strings at the node, if null it will most likely zero initialize (empty list)
|
||||
* @throws ObjectMappingException
|
||||
* Returns the children of a specific node
|
||||
* @param path the path to the parent node
|
||||
* @return the list of children for the target parent node
|
||||
*/
|
||||
public List<String> getStringValueList(String... path) throws ObjectMappingException {
|
||||
return userRootNode.getList(TypeToken.of(String.class));
|
||||
public List<? extends ConfigurationNode> getChildren(String... path) {
|
||||
return userRootNode.getNode(path).getChildrenList();
|
||||
}
|
||||
|
||||
public List<String> getListFromNode(String... path) throws ObjectMappingException
|
||||
{
|
||||
return userRootNode.getNode(path).getList(TypeToken.of(String.class));
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
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.inventory.ItemStack;
|
||||
|
||||
@ -48,171 +48,168 @@ public class RepairConfig extends ConfigCollection {
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
try {
|
||||
//Grab the "keys" under the Repairables node
|
||||
ArrayList<String> keys = new ArrayList<>(getStringValueList(REPAIRABLES));
|
||||
//Grab the "keys" under the Repairables node
|
||||
ArrayList<ConfigurationNode> repairChildrenNodes = new ArrayList<>(getChildren(REPAIRABLES));
|
||||
|
||||
//TODO: Remove Debug
|
||||
if(keys.size() <= 0) {
|
||||
mcMMO.p.getLogger().severe("DEBUG: Repair MultiConfigContainer key list is empty");
|
||||
return;
|
||||
//TODO: Remove Debug
|
||||
if(repairChildrenNodes.size() <= 0) {
|
||||
mcMMO.p.getLogger().severe("DEBUG: Repair MultiConfigContainer key list is empty");
|
||||
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!
|
||||
List<String> errorMessages = new ArrayList<String>();
|
||||
/*
|
||||
* Determine Repair Material Type
|
||||
*/
|
||||
MaterialType repairMaterialType = MaterialType.OTHER;
|
||||
String repairMaterialTypeString = getRepairMaterialTypeString(repairChildNodeName);
|
||||
|
||||
/*
|
||||
* Match the name of the key to a Material constant definition
|
||||
*/
|
||||
Material itemMaterial = Material.matchMaterial(key);
|
||||
if (hasNode(REPAIRABLES, repairChildNodeName, MATERIAL_TYPE)) {
|
||||
ItemStack repairItem = new ItemStack(itemMaterial);
|
||||
|
||||
if (itemMaterial == null) {
|
||||
mcMMO.p.getLogger().severe("Repair Invalid material: " + key);
|
||||
if (ItemUtils.isWoodTool(repairItem)) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine Repair Material Type
|
||||
*/
|
||||
MaterialType repairMaterialType = MaterialType.OTHER;
|
||||
String repairMaterialTypeString = getRepairMaterialTypeString(key);
|
||||
// Repair Material
|
||||
String repairMaterialName = getRepairMaterialStringName(repairChildNodeName);
|
||||
Material repairMaterial = (repairMaterialName == null ? repairMaterialType.getDefaultMaterial() : Material.matchMaterial(repairMaterialName));
|
||||
|
||||
if (hasNode(REPAIRABLES, key, MATERIAL_TYPE)) {
|
||||
ItemStack repairItem = new ItemStack(itemMaterial);
|
||||
if (repairMaterial == null) {
|
||||
errorMessages.add(repairChildNodeName + " has an invalid repair material: " + repairMaterialName);
|
||||
}
|
||||
|
||||
if (ItemUtils.isWoodTool(repairItem)) {
|
||||
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;
|
||||
}
|
||||
// Maximum Durability
|
||||
short maximumDurability = (itemMaterial != null ? itemMaterial.getMaxDurability() : getRepairableMaximumDurability(repairChildNodeName));
|
||||
|
||||
if (maximumDurability <= 0) {
|
||||
maximumDurability = getRepairableMaximumDurability(repairChildNodeName);
|
||||
}
|
||||
|
||||
if (maximumDurability <= 0) {
|
||||
errorMessages.add("Maximum durability of " + repairChildNodeName + " must be greater than 0!");
|
||||
}
|
||||
|
||||
// Item Type
|
||||
ItemType repairItemType = ItemType.OTHER;
|
||||
String repairItemTypeString = "";
|
||||
|
||||
if(hasNode(REPAIRABLES, repairChildNodeName, ITEM_TYPE))
|
||||
repairItemTypeString = getStringValue(REPAIRABLES, repairChildNodeName, ITEM_TYPE);
|
||||
else
|
||||
repairItemTypeString = "OTHER";
|
||||
|
||||
if (!hasNode(REPAIRABLES, repairChildNodeName, ITEM_TYPE) && itemMaterial != null) {
|
||||
ItemStack repairItem = new ItemStack(itemMaterial);
|
||||
|
||||
if (ItemUtils.isMinecraftTool(repairItem)) {
|
||||
repairItemType = ItemType.TOOL;
|
||||
}
|
||||
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: " + 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);
|
||||
else if (ItemUtils.isArmor(repairItem)) {
|
||||
repairItemType = ItemType.ARMOR;
|
||||
}
|
||||
}
|
||||
} catch (ObjectMappingException e) {
|
||||
e.printStackTrace();
|
||||
else {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
||||
import com.gmail.nossr50.skills.salvage.salvageables.SalvageableFactory;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
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.inventory.ItemStack;
|
||||
|
||||
@ -44,138 +44,133 @@ public class SalvageConfig extends ConfigCollection {
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
//Grab the "keys" under the Repairables node
|
||||
ArrayList<ConfigurationNode> salvageChildrenNodes = new ArrayList<>(getChildren(SALVAGEABLES));
|
||||
|
||||
try {
|
||||
//Grab the "keys" under the Repairables node
|
||||
ArrayList<String> keys = new ArrayList<>(getStringValueList(SALVAGEABLES));
|
||||
for (ConfigurationNode salvageChildNode : salvageChildrenNodes) {
|
||||
// Validate all the things!
|
||||
List<String> errorMessages = new ArrayList<String>();
|
||||
|
||||
for (String key : keys) {
|
||||
// Validate all the things!
|
||||
List<String> errorMessages = new ArrayList<String>();
|
||||
// ItemStack Material
|
||||
String salvageChildNodeName = salvageChildNode.getString();
|
||||
Material itemMaterial = Material.matchMaterial(salvageChildNodeName);
|
||||
|
||||
// ItemStack Material
|
||||
Material itemMaterial = Material.matchMaterial(key);
|
||||
if (itemMaterial == null) {
|
||||
errorMessages.add("Salvage Config: Invalid material - " + salvageChildNodeName);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (itemMaterial == null) {
|
||||
errorMessages.add("Salvage Config: Invalid material - " + key);
|
||||
continue;
|
||||
// Salvage Material Type
|
||||
MaterialType salvageMaterialType = MaterialType.OTHER;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// Salvage Material Type
|
||||
MaterialType salvageMaterialType = MaterialType.OTHER;
|
||||
|
||||
String 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);
|
||||
} else {
|
||||
try {
|
||||
salvageMaterialType = MaterialType.valueOf(salvageMaterialTypeString.replace(" ", "_").toUpperCase());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
errorMessages.add("Salvage Config: " + salvageChildNodeName + " has an invalid MaterialType of " + salvageMaterialTypeString);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (ObjectMappingException e) {
|
||||
e.printStackTrace();
|
||||
// Salvage Material
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import ninja.leaping.configurate.objectmapping.Setting;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
|
@ -66,7 +66,7 @@ public class ItemWeightConfig extends Config {
|
||||
HashSet<Material> miscItems = new HashSet<Material>();
|
||||
|
||||
try {
|
||||
for (String item : getStringValueList(PARTY_SHAREABLES, MISC_ITEMS)) {
|
||||
for (String item : getListFromNode(PARTY_SHAREABLES, MISC_ITEMS)) {
|
||||
Material material = Material.getMaterial(item.toUpperCase());
|
||||
|
||||
if (material != null) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.config.skills.alchemy;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.ConfigCollection;
|
||||
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@ -98,14 +97,14 @@ public class PotionConfig extends ConfigCollection {
|
||||
|
||||
private void loadConcoctions() {
|
||||
try {
|
||||
loadConcoctionsTier(concoctionsIngredientsTierOne, getStringValueList(CONCOCTIONS, TIER_ONE_INGREDIENTS));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierTwo, getStringValueList(CONCOCTIONS, TIER_TWO_INGREDIENTS));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierThree, getStringValueList(CONCOCTIONS, TIER_THREE_INGREDIENTS));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierFour, getStringValueList(CONCOCTIONS, TIER_FOUR_INGREDIENTS));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierFive, getStringValueList(CONCOCTIONS, TIER_FIVE_INGREDIENTS));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierSix, getStringValueList(CONCOCTIONS, TIER_SIX_INGREDIENTS));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierSeven, getStringValueList(CONCOCTIONS, TIER_SEVEN_INGREDIENTS));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierEight, getStringValueList(CONCOCTIONS, TIER_EIGHT_INGREDIENTS));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierOne, getListFromNode(CONCOCTIONS, TIER_ONE_INGREDIENTS));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierTwo, getListFromNode(CONCOCTIONS, TIER_TWO_INGREDIENTS));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierThree, getListFromNode(CONCOCTIONS, TIER_THREE_INGREDIENTS));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierFour, getListFromNode(CONCOCTIONS, TIER_FOUR_INGREDIENTS));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierFive, getListFromNode(CONCOCTIONS, TIER_FIVE_INGREDIENTS));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierSix, getListFromNode(CONCOCTIONS, TIER_SIX_INGREDIENTS));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierSeven, getListFromNode(CONCOCTIONS, TIER_SEVEN_INGREDIENTS));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierEight, getListFromNode(CONCOCTIONS, TIER_EIGHT_INGREDIENTS));
|
||||
|
||||
concoctionsIngredientsTierTwo.addAll(concoctionsIngredientsTierOne);
|
||||
concoctionsIngredientsTierThree.addAll(concoctionsIngredientsTierTwo);
|
||||
@ -114,15 +113,14 @@ public class PotionConfig extends ConfigCollection {
|
||||
concoctionsIngredientsTierSix.addAll(concoctionsIngredientsTierFive);
|
||||
concoctionsIngredientsTierSeven.addAll(concoctionsIngredientsTierSix);
|
||||
concoctionsIngredientsTierEight.addAll(concoctionsIngredientsTierSeven);
|
||||
|
||||
} catch (ObjectMappingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadConcoctionsTier(List<ItemStack> ingredientList, List<String> ingredientStrings) {
|
||||
if (ingredientStrings != null && ingredientStrings.size() > 0) {
|
||||
for (String ingredientString : ingredientStrings) {
|
||||
private void loadConcoctionsTier(List<ItemStack> ingredientList, List<String> ingredients) {
|
||||
if (ingredients != null && ingredients.size() > 0) {
|
||||
for (String ingredientString : ingredients) {
|
||||
ItemStack ingredient = loadIngredient(ingredientString);
|
||||
|
||||
if (ingredient != null) {
|
||||
@ -140,23 +138,20 @@ public class PotionConfig extends ConfigCollection {
|
||||
int pass = 0;
|
||||
int fail = 0;
|
||||
|
||||
try {
|
||||
for (String potionName : getStringValueList(POTIONS)) {
|
||||
//Grab the child node corresponding to this potion
|
||||
AlchemyPotion potion = loadPotion(getUserRootNode().getNode(POTIONS, potionName));
|
||||
for (ConfigurationNode potionNode : getChildren(POTIONS)) {
|
||||
//Grab the child node corresponding to this potion
|
||||
String potionName = potionNode.getString();
|
||||
AlchemyPotion potion = loadPotion(getUserRootNode().getNode(POTIONS, potionName));
|
||||
|
||||
if (potion != null) {
|
||||
potionMap.put(potionName, potion);
|
||||
pass++;
|
||||
} else {
|
||||
fail++;
|
||||
}
|
||||
if (potion != null) {
|
||||
potionMap.put(potionName, potion);
|
||||
pass++;
|
||||
} else {
|
||||
fail++;
|
||||
}
|
||||
|
||||
mcMMO.p.debug("Loaded " + pass + " Alchemy potions, skipped " + fail + ".");
|
||||
} catch (ObjectMappingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
mcMMO.p.debug("Loaded " + pass + " Alchemy potions, skipped " + fail + ".");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,6 @@ import com.gmail.nossr50.config.MainConfig;
|
||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
||||
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.UniqueDataType;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
|
@ -2,14 +2,12 @@ package com.gmail.nossr50.party;
|
||||
|
||||
import com.gmail.nossr50.config.MainConfig;
|
||||
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.party.ItemShareType;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyLeader;
|
||||
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||
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.McMMOPartyChangeEvent;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.skills.fishing;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
|
||||
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
Loading…
Reference in New Issue
Block a user