Mod Support - Item Tiers.

1 is Wood, 2 is Stone, 3 is Iron, 4 is Diamond.
This commit is contained in:
GJ 2012-05-17 21:19:17 -04:00
parent 01235ff398
commit d17fe6bb7a
5 changed files with 34 additions and 7 deletions

View File

@ -72,6 +72,7 @@ public class CustomToolsConfig extends ModConfigLoader {
int id = config.getInt(toolType + "." + toolName + ".ID", 0); int id = config.getInt(toolType + "." + toolName + ".ID", 0);
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0); double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);
boolean abilityEnabled = config.getBoolean(toolType + "." + toolName + ".Ability_Enabled", true); boolean abilityEnabled = config.getBoolean(toolType + "." + toolName + ".Ability_Enabled", true);
int tier = config.getInt(toolType + "." + toolName + ".Tier", 1);
boolean repairable = config.getBoolean(toolType + "." + toolName + ".Repairable"); boolean repairable = config.getBoolean(toolType + "." + toolName + ".Repairable");
int repairID = config.getInt(toolType + "." + toolName + ".Repair_Material_ID", 0); int repairID = config.getInt(toolType + "." + toolName + ".Repair_Material_ID", 0);
byte repairData = (byte) config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Value", 0); byte repairData = (byte) config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Value", 0);
@ -92,10 +93,10 @@ public class CustomToolsConfig extends ModConfigLoader {
if (repairable) { if (repairable) {
ItemStack repairMaterial = new ItemStack(repairID, 1, (short) 0, repairData); ItemStack repairMaterial = new ItemStack(repairID, 1, (short) 0, repairData);
tool = new CustomTool(durability, repairMaterial, repairQuantity, repairable, abilityEnabled, multiplier, id); tool = new CustomTool(durability, repairMaterial, repairQuantity, repairable, tier, abilityEnabled, multiplier, id);
} }
else { else {
tool = new CustomTool(durability, null, 0, repairable, abilityEnabled, multiplier, id); tool = new CustomTool(durability, null, 0, repairable, tier, abilityEnabled, multiplier, id);
} }
idList.add(id); idList.add(id);

View File

@ -5,11 +5,13 @@ import org.bukkit.inventory.ItemStack;
public class CustomTool extends CustomItem { public class CustomTool extends CustomItem {
private double xpMultiplier; private double xpMultiplier;
private boolean abilityEnabled; private boolean abilityEnabled;
private int tier;
public CustomTool(short durability, ItemStack repairMaterial, int repairQuantity, boolean repairable, boolean abilityEnabled, double xpMultiplier, int itemID) { public CustomTool(short durability, ItemStack repairMaterial, int repairQuantity, boolean repairable, int tier, boolean abilityEnabled, double xpMultiplier, int itemID) {
super(durability, repairMaterial, repairQuantity, repairable, itemID); super(durability, repairMaterial, repairQuantity, repairable, itemID);
this.xpMultiplier = xpMultiplier; this.xpMultiplier = xpMultiplier;
this.abilityEnabled = abilityEnabled; this.abilityEnabled = abilityEnabled;
this.tier = tier;
} }
public double getXpMultiplier() { public double getXpMultiplier() {
@ -27,4 +29,12 @@ public class CustomTool extends CustomItem {
public void setAbilityEnabled(boolean abilityEnabled) { public void setAbilityEnabled(boolean abilityEnabled) {
this.abilityEnabled = abilityEnabled; this.abilityEnabled = abilityEnabled;
} }
public int getTier() {
return tier;
}
public void setTier(int tier) {
this.tier = tier;
}
} }

View File

@ -243,10 +243,10 @@ public class ItemChecks {
} }
/** /**
* Checks to see if an item is a custom tool. * Checks to see if an item is custom armor.
* *
* @param is Item to check * @param is Item to check
* @return true if the item is a custom tool, false otherwise * @return true if the item is custom armor, false otherwise
*/ */
public static boolean isCustomArmor(ItemStack is) { public static boolean isCustomArmor(ItemStack is) {
if (customArmorEnabled && CustomArmorConfig.getInstance().customIDs.contains(is.getTypeId())) { if (customArmorEnabled && CustomArmorConfig.getInstance().customIDs.contains(is.getTypeId())) {

View File

@ -143,8 +143,12 @@ public class Misc {
else if (ItemChecks.isGoldTool(inHand)) { else if (ItemChecks.isGoldTool(inHand)) {
tier = 1; tier = 1;
} }
else if(ItemChecks.isDiamondTool(inHand)) else if (ItemChecks.isDiamondTool(inHand)) {
tier = 4; tier = 4;
}
else if (ItemChecks.isCustomTool(inHand)) {
tier = ModChecks.getToolFromItemStack(inHand).getTier();
}
return tier; return tier;
} }

View File

@ -6,6 +6,7 @@ Axes:
ID: 999 ID: 999
XP_Modifer: 1.0 XP_Modifer: 1.0
Ability_Enabled: true Ability_Enabled: true
Tier: 1
Repairable: true Repairable: true
Repair_Material_ID: 99 Repair_Material_ID: 99
Repair_Material_Data_Value: 0 Repair_Material_Data_Value: 0
@ -15,6 +16,7 @@ Axes:
ID: 999 ID: 999
XP_Modifer: 1.0 XP_Modifer: 1.0
Ability_Enabled: true Ability_Enabled: true
Tier: 1
Repairable: true Repairable: true
Repair_Material_ID: 99 Repair_Material_ID: 99
Repair_Material_Data_Value: 0 Repair_Material_Data_Value: 0
@ -29,6 +31,7 @@ Bows:
ID: 999 ID: 999
XP_Modifer: 1.0 XP_Modifer: 1.0
Ability_Enabled: true Ability_Enabled: true
Tier: 1
Repairable: true Repairable: true
Repair_Material_ID: 99 Repair_Material_ID: 99
Repair_Material_Data_Value: 0 Repair_Material_Data_Value: 0
@ -38,6 +41,7 @@ Bows:
ID: 999 ID: 999
XP_Modifer: 1.0 XP_Modifer: 1.0
Ability_Enabled: true Ability_Enabled: true
Tier: 1
Repairable: true Repairable: true
Repair_Material_ID: 99 Repair_Material_ID: 99
Repair_Material_Data_Value: 0 Repair_Material_Data_Value: 0
@ -52,6 +56,7 @@ Hoes:
ID: 999 ID: 999
XP_Modifer: 1.0 XP_Modifer: 1.0
Ability_Enabled: true Ability_Enabled: true
Tier: 1
Repairable: true Repairable: true
Repair_Material_ID: 99 Repair_Material_ID: 99
Repair_Material_Data_Value: 0 Repair_Material_Data_Value: 0
@ -61,6 +66,7 @@ Hoes:
ID: 999 ID: 999
XP_Modifer: 1.0 XP_Modifer: 1.0
Ability_Enabled: true Ability_Enabled: true
Tier: 1
Repairable: true Repairable: true
Repair_Material_ID: 99 Repair_Material_ID: 99
Repair_Material_Data_Value: 0 Repair_Material_Data_Value: 0
@ -75,6 +81,7 @@ Pickaxes:
ID: 999 ID: 999
XP_Modifer: 1.0 XP_Modifer: 1.0
Ability_Enabled: true Ability_Enabled: true
Tier: 1
Repairable: true Repairable: true
Repair_Material_ID: 99 Repair_Material_ID: 99
Repair_Material_Data_Value: 0 Repair_Material_Data_Value: 0
@ -84,6 +91,7 @@ Pickaxes:
ID: 999 ID: 999
XP_Modifer: 1.0 XP_Modifer: 1.0
Ability_Enabled: true Ability_Enabled: true
Tier: 1
Repairable: true Repairable: true
Repair_Material_ID: 99 Repair_Material_ID: 99
Repair_Material_Data_Value: 0 Repair_Material_Data_Value: 0
@ -98,6 +106,7 @@ Shovels:
ID: 999 ID: 999
XP_Modifer: 1.0 XP_Modifer: 1.0
Ability_Enabled: true Ability_Enabled: true
Tier: 1
Repairable: true Repairable: true
Repair_Material_ID: 99 Repair_Material_ID: 99
Repair_Material_Data_Value: 0 Repair_Material_Data_Value: 0
@ -107,6 +116,7 @@ Shovels:
ID: 999 ID: 999
XP_Modifer: 1.0 XP_Modifer: 1.0
Ability_Enabled: true Ability_Enabled: true
Tier: 1
Repairable: true Repairable: true
Repair_Material_ID: 99 Repair_Material_ID: 99
Repair_Material_Data_Value: 0 Repair_Material_Data_Value: 0
@ -121,6 +131,7 @@ Swords:
ID: 999 ID: 999
XP_Modifer: 1.0 XP_Modifer: 1.0
Ability_Enabled: true Ability_Enabled: true
Tier: 1
Repairable: true Repairable: true
Repair_Material_ID: 99 Repair_Material_ID: 99
Repair_Material_Data_Value: 0 Repair_Material_Data_Value: 0
@ -130,6 +141,7 @@ Swords:
ID: 999 ID: 999
XP_Modifer: 1.0 XP_Modifer: 1.0
Ability_Enabled: true Ability_Enabled: true
Tier: 1
Repairable: true Repairable: true
Repair_Material_ID: 99 Repair_Material_ID: 99
Repair_Material_Data_Value: 0 Repair_Material_Data_Value: 0