Browse Source

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

nossr50 6 years ago
parent
commit
30bc73be7d

+ 2 - 0
Changelog.txt

@@ -13,6 +13,8 @@ Version 2.2.0
     mcMMO will now warn you in the console if it thinks you are running incompatible server software
     mcMMO will now warn you in the console if it thinks you are running incompatible server software
     Parties no longer have a cap, you can level them forever for bragging rights
     Parties no longer have a cap, you can level them forever for bragging rights
     You can now specify multiple repair-items for an item (such as specifying that a wooden sword can be repaired by all types of planks)
     You can now specify multiple repair-items for an item (such as specifying that a wooden sword can be repaired by all types of planks)
+    Repair no longer consumes materials with item lore, players are informed that they cannot repair with that material if its the only matching repair material in their inventory
+    Added new locale string - Repair.NoBasicRepairMatsFound
     Simplified the config entries for Repairables in the Repair config
     Simplified the config entries for Repairables in the Repair config
     Repairables in the repair config now use their internal registry key names instead of Bukkit material names
     Repairables in the repair config now use their internal registry key names instead of Bukkit material names
     Diamond Armor XP multiplier vanilla config setting reduced from 6x -> 2x
     Diamond Armor XP multiplier vanilla config setting reduced from 6x -> 2x

+ 3 - 3
src/main/java/com/gmail/nossr50/config/hocon/experience/ConfigExperienceRepair.java

@@ -32,9 +32,9 @@ public class ConfigExperienceRepair {
 
 
     @Setting(value = "Repair-XP-Base", comment = "The base amount of XP for repairing an item." +
     @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 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." +
             "\nAnd finally, the XP multiplier of the item material category defined in this config." +
             "\nDefault value: "+REPAIR_XP_BASE_DEFAULT)
             "\nDefault value: "+REPAIR_XP_BASE_DEFAULT)
     private double repairXPBase = REPAIR_XP_BASE_DEFAULT;
     private double repairXPBase = REPAIR_XP_BASE_DEFAULT;

+ 22 - 2
src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java

@@ -94,14 +94,34 @@ public class RepairManager extends SkillManager {
 
 
         PlayerInventory inventory = player.getInventory();
         PlayerInventory inventory = player.getInventory();
         Material repairMaterial = null;
         Material repairMaterial = null;
+        boolean foundNonBasicMaterial = false;
 
 
         //Find the first compatible repair material
         //Find the first compatible repair material
         for(Material repairMaterialCandidate : repairable.getRepairMaterials())
         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();
         //byte repairMaterialMetadata = repairable.getRepairMaterialMetadata();
         ItemStack toRemove = new ItemStack(repairMaterial);
         ItemStack toRemove = new ItemStack(repairMaterial);
 
 

+ 1 - 0
src/main/resources/locale/locale_en_US.properties

@@ -364,6 +364,7 @@ Repair.Skills.Adept=[[RED]]You must be level [[YELLOW]]{0}[[RED]] to repair [[YE
 Repair.Skills.FeltEasy=[[GRAY]]That felt easy.
 Repair.Skills.FeltEasy=[[GRAY]]That felt easy.
 Repair.Skills.FullDurability=[[GRAY]]That is at full durability.
 Repair.Skills.FullDurability=[[GRAY]]That is at full durability.
 Repair.Skills.StackedItems=[[DARK_RED]]You can't repair stacked items.
 Repair.Skills.StackedItems=[[DARK_RED]]You can't repair stacked items.
+Repair.NoBasicRepairMatsFound=[[RED]]You can only repair using basic materials.
 Repair.Pretty.Name=Repair
 Repair.Pretty.Name=Repair
 #Arcane Forging
 #Arcane Forging
 Repair.Arcane.Downgrade=Arcane power has decreased for this item.
 Repair.Arcane.Downgrade=Arcane power has decreased for this item.