Repair no longer consumes items with item lore + Fixing logic errors in repair.

This commit is contained in:
nossr50
2019-04-16 11:17:56 -07:00
parent bbd43e156a
commit 30bc73be7d
4 changed files with 28 additions and 5 deletions

View File

@ -32,9 +32,9 @@ public class ConfigExperienceRepair {
@Setting(value = "Repair-XP-Base", comment = "The base amount of XP for repairing an item." +
"\nThe repair XP formula is a simple multiplication of these 4 values in this order" +
"\nThe amount repair (0.0 to 1.0)" +
"\nThe item XP multiplier defined in the Repair config" +
"\nThe Base Repair XP defined here (default 1000.0D)" +
"\nThe % amount repaired (0.0 to 1.0)" +
"\nThe Item XP multiplier defined in the Repair config (not this config)" +
"\nThe Base Repair XP defined here (default 1000.0)" +
"\nAnd finally, the XP multiplier of the item material category defined in this config." +
"\nDefault value: "+REPAIR_XP_BASE_DEFAULT)
private double repairXPBase = REPAIR_XP_BASE_DEFAULT;

View File

@ -94,14 +94,34 @@ public class RepairManager extends SkillManager {
PlayerInventory inventory = player.getInventory();
Material repairMaterial = null;
boolean foundNonBasicMaterial = false;
//Find the first compatible repair material
for(Material repairMaterialCandidate : repairable.getRepairMaterials())
{
if(player.getInventory().contains(new ItemStack(repairMaterialCandidate)))
repairMaterial = repairMaterialCandidate;
for(ItemStack is : player.getInventory().getContents())
{
if(is.getType() == repairMaterialCandidate)
{
if(is.getItemMeta().getLore().isEmpty())
{
repairMaterial = repairMaterialCandidate;
break;
} else {
foundNonBasicMaterial = true;
}
}
}
}
/* Abort the repair if no compatible basic repairing item found */
if(repairMaterial == null && foundNonBasicMaterial == true)
{
player.sendMessage(LocaleLoader.getString("Repair.NoBasicRepairMatsFound"));
return;
}
//byte repairMaterialMetadata = repairable.getRepairMaterialMetadata();
ItemStack toRemove = new ItemStack(repairMaterial);