Set a pretty repair material name in tools.yml

Adds #1863
This commit is contained in:
TfT_02 2014-06-15 17:31:50 +02:00
parent f2b892b7d5
commit f75e15dfdc
7 changed files with 42 additions and 5 deletions

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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
*

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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