diff --git a/Changelog.txt b/Changelog.txt index b1990a45c..19da7fcd0 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -16,6 +16,7 @@ Version 1.5.01-dev + Added API to experience events to get XP gain reason + Added API to check if an entity is bleeding + Added full support for repairables in tools.yml config files + + Added option to tools.yml config files to set a pretty repair material name = Fixed bug where pistons would mess with the block tracking = Fixed bug where the Updater was running on the main thread. = Fixed bug when players would use /ptp without being in a party diff --git a/src/main/java/com/gmail/nossr50/config/mods/CustomToolConfig.java b/src/main/java/com/gmail/nossr50/config/mods/CustomToolConfig.java index a69158c33..5f2a1e4b7 100644 --- a/src/main/java/com/gmail/nossr50/config/mods/CustomToolConfig.java +++ b/src/main/java/com/gmail/nossr50/config/mods/CustomToolConfig.java @@ -93,6 +93,7 @@ public class CustomToolConfig extends ConfigLoader { repairQuantity = config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Quantity", 2); } + String repairItemName = config.getString(toolType + "." + toolName + ".Repair_Material_Pretty_Name"); int repairMinimumLevel = config.getInt(toolType + "." + toolName + ".Repair_MinimumLevel", 0); double repairXpMultiplier = config.getDouble(toolType + "." + toolName + ".Repair_XpMultiplier", 1); @@ -102,7 +103,7 @@ public class CustomToolConfig extends ConfigLoader { durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 60); } - repairables.add(RepairableFactory.getRepairable(toolMaterial, repairMaterial, repairData, repairMinimumLevel, repairQuantity, durability, ItemType.TOOL, MaterialType.OTHER, repairXpMultiplier)); + repairables.add(RepairableFactory.getRepairable(toolMaterial, repairMaterial, repairData, repairItemName, repairMinimumLevel, repairQuantity, durability, ItemType.TOOL, MaterialType.OTHER, repairXpMultiplier)); } double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0); diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java index 06d68330f..070a06772 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -97,7 +97,8 @@ public class RepairManager extends SkillManager { // Check if they have the proper material to repair with if (!inventory.contains(repairMaterial)) { - String message = LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(repairMaterial)); + String prettyName = repairable.getRepairMaterialPrettyName() == null ? StringUtils.getPrettyItemString(repairMaterial) : repairable.getRepairMaterialPrettyName(); + String message = LocaleLoader.getString("Skills.NeedMore", prettyName); if (repairMaterialMetadata != (byte) -1 && !inventory.containsAtLeast(toRemove, 1)) { message += ":" + repairMaterialMetadata; diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java index 914e0f70f..89e3128cd 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java @@ -28,6 +28,13 @@ public interface Repairable { */ public byte getRepairMaterialMetadata(); + /** + * Gets the pretty name of the material used to repair this item + * + * @return the pretty name of the repair material + */ + public String getRepairMaterialPrettyName(); + /** * Gets the RepairItemType value for this repairable item * diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableFactory.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableFactory.java index 9e1e19b9b..07723f468 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableFactory.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableFactory.java @@ -8,11 +8,15 @@ import com.gmail.nossr50.datatypes.skills.MaterialType; public class RepairableFactory { public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, byte repairMetadata, int minimumQuantity, short maximumDurability) { - return getRepairable(itemMaterial, repairMaterial, repairMetadata, 0, minimumQuantity, maximumDurability, ItemType.OTHER, MaterialType.OTHER, 1); + return getRepairable(itemMaterial, repairMaterial, repairMetadata, null, 0, minimumQuantity, maximumDurability, ItemType.OTHER, MaterialType.OTHER, 1); } public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, byte repairMetadata, int minimumLevel, int minimumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) { + return getRepairable(itemMaterial, repairMaterial, repairMetadata, null, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier); + } + + public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, byte repairMetadata, String repairMaterialPrettyName, int minimumLevel, int minimumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) { // TODO: Add in loading from config what type of repairable we want. - return new SimpleRepairable(itemMaterial, repairMaterial, repairMetadata, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier); + return new SimpleRepairable(itemMaterial, repairMaterial, repairMetadata, repairMaterialPrettyName, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier); } } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java index 0efdf8ddd..bd5370ec7 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java @@ -11,14 +11,16 @@ public class SimpleRepairable implements Repairable { private final int minimumQuantity, minimumLevel; private final short maximumDurability, baseRepairDurability; private final byte repairMetadata; + private String repairMaterialPrettyName; private final ItemType repairItemType; private final MaterialType repairMaterialType; private final double xpMultiplier; - protected SimpleRepairable(Material type, Material repairMaterial, byte repairMetadata, int minimumLevel, int minimumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) { + protected SimpleRepairable(Material type, Material repairMaterial, byte repairMetadata, String repairMaterialPrettyName, int minimumLevel, int minimumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) { this.itemMaterial = type; this.repairMaterial = repairMaterial; this.repairMetadata = repairMetadata; + this.repairMaterialPrettyName = repairMaterialPrettyName; this.repairItemType = repairItemType; this.repairMaterialType = repairMaterialType; this.minimumLevel = minimumLevel; @@ -43,6 +45,11 @@ public class SimpleRepairable implements Repairable { return repairMetadata; } + @Override + public String getRepairMaterialPrettyName() { + return repairMaterialPrettyName; + } + @Override public ItemType getRepairItemType() { return repairItemType; diff --git a/src/main/resources/mods/tools.default.yml b/src/main/resources/mods/tools.default.yml index ecc83bc60..d3182ac87 100644 --- a/src/main/resources/mods/tools.default.yml +++ b/src/main/resources/mods/tools.default.yml @@ -24,6 +24,10 @@ ## This is typically the number of the repair material needed to create a new item, for example for a sword it is 2, for an axe it is 3 ## This defaults to 9 # +# Repair_Material_Pretty_Name: The pretty name of the repair material. +## Used in the feedback message when not enough repair materials are found. +## This defaults to the Repair_Material converted to string. +# # Repair_MinimumLevel: This is the minimum repair level needed to repair this item. ## Valid values are => 0 ## This defaults to 0 @@ -47,6 +51,7 @@ Axes: Repair_Material: REPAIR_MATERIAL_NAME Repair_Material_Data_Value: 0 Repair_Material_Quantity: 9 + Repair_Material_Pretty_Name: Repair Item Name Repair_MinimumLevel: 0 Repair_XpMultiplier: 1.0 Durability: 9999 @@ -58,6 +63,7 @@ Axes: Repair_Material: REPAIR_MATERIAL_NAME Repair_Material_Data_Value: 0 Repair_Material_Quantity: 9 + Repair_Material_Pretty_Name: Repair Item Name Repair_MinimumLevel: 0 Repair_XpMultiplier: 1.0 Durability: 9999 @@ -73,6 +79,7 @@ Bows: Repair_Material: REPAIR_MATERIAL_NAME Repair_Material_Data_Value: 0 Repair_Material_Quantity: 9 + Repair_Material_Pretty_Name: Repair Item Name Repair_MinimumLevel: 0 Repair_XpMultiplier: 1.0 Durability: 9999 @@ -84,6 +91,7 @@ Bows: Repair_Material: REPAIR_MATERIAL_NAME Repair_Material_Data_Value: 0 Repair_Material_Quantity: 9 + Repair_Material_Pretty_Name: Repair Item Name Repair_MinimumLevel: 0 Repair_XpMultiplier: 1.0 Durability: 9999 @@ -99,6 +107,7 @@ Hoes: Repair_Material: REPAIR_MATERIAL_NAME Repair_Material_Data_Value: 0 Repair_Material_Quantity: 9 + Repair_Material_Pretty_Name: Repair Item Name Repair_MinimumLevel: 0 Repair_XpMultiplier: 1.0 Durability: 9999 @@ -110,6 +119,7 @@ Hoes: Repair_Material: REPAIR_MATERIAL_NAME Repair_Material_Data_Value: 0 Repair_Material_Quantity: 9 + Repair_Material_Pretty_Name: Repair Item Name Repair_MinimumLevel: 0 Repair_XpMultiplier: 1.0 Durability: 9999 @@ -125,6 +135,7 @@ Pickaxes: Repair_Material: REPAIR_MATERIAL_NAME Repair_Material_Data_Value: 0 Repair_Material_Quantity: 9 + Repair_Material_Pretty_Name: Repair Item Name Repair_MinimumLevel: 0 Repair_XpMultiplier: 1.0 Durability: 9999 @@ -136,6 +147,7 @@ Pickaxes: Repair_Material: REPAIR_MATERIAL_NAME Repair_Material_Data_Value: 0 Repair_Material_Quantity: 9 + Repair_Material_Pretty_Name: Repair Item Name Repair_MinimumLevel: 0 Repair_XpMultiplier: 1.0 Durability: 9999 @@ -151,6 +163,7 @@ Shovels: Repair_Material: REPAIR_MATERIAL_NAME Repair_Material_Data_Value: 0 Repair_Material_Quantity: 9 + Repair_Material_Pretty_Name: Repair Item Name Repair_MinimumLevel: 0 Repair_XpMultiplier: 1.0 Durability: 9999 @@ -162,6 +175,7 @@ Shovels: Repair_Material: REPAIR_MATERIAL_NAME Repair_Material_Data_Value: 0 Repair_Material_Quantity: 9 + Repair_Material_Pretty_Name: Repair Item Name Repair_MinimumLevel: 0 Repair_XpMultiplier: 1.0 Durability: 9999 @@ -177,6 +191,7 @@ Swords: Repair_Material: REPAIR_MATERIAL_NAME Repair_Material_Data_Value: 0 Repair_Material_Quantity: 9 + Repair_Material_Pretty_Name: Repair Item Name Repair_MinimumLevel: 0 Repair_XpMultiplier: 1.0 Durability: 9999 @@ -188,6 +203,7 @@ Swords: Repair_Material: REPAIR_MATERIAL_NAME Repair_Material_Data_Value: 0 Repair_Material_Quantity: 9 + Repair_Material_Pretty_Name: Repair Item Name Repair_MinimumLevel: 0 Repair_XpMultiplier: 1.0 Durability: 9999 \ No newline at end of file