Fixed bug with being unable to repair Gold Hoe. Fixed bug with item durability - now uses getMaxDurability from org.bukkit.material

This commit is contained in:
gmcferrin 2012-01-19 12:46:54 -05:00
parent 523db7f0a2
commit da9a4b80e4

View File

@ -13,7 +13,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with mcMMO. If not, see <http://www.gnu.org/licenses/>. along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.gmail.nossr50.skills; package com.gmail.nossr50.skills;
import org.bukkit.Material; import org.bukkit.Material;
@ -211,6 +211,7 @@ public class Repair {
SpoutStuff.playRepairNoise(player); SpoutStuff.playRepairNoise(player);
} }
//GOLD TOOLS //GOLD TOOLS
else if(isGoldTools(is) && hasItem(player, rGold)){ else if(isGoldTools(is) && hasItem(player, rGold)){
removeItem(player, rGold); removeItem(player, rGold);
@ -242,34 +243,33 @@ public class Repair {
else { else {
player.sendMessage(mcLocale.getString("Skills.FullDurability")); player.sendMessage(mcLocale.getString("Skills.FullDurability"));
} }
//player.updateInventory();
/* /*
* GIVE SKILL IF THERE IS ENOUGH XP * GIVE SKILL IF THERE IS ENOUGH XP
*/ */
Skills.XpCheckSkill(SkillType.REPAIR, player); Skills.XpCheckSkill(SkillType.REPAIR, player);
} }
} }
public static int getArcaneForgingRank(PlayerProfile PP)
{ public static int getArcaneForgingRank(PlayerProfile PP){
int rank = 0; int rank = 0;
if(PP.getSkillLevel(SkillType.REPAIR) >= 750) if(PP.getSkillLevel(SkillType.REPAIR) >= 750)
{
rank = 4; rank = 4;
} else if (PP.getSkillLevel(SkillType.REPAIR) >= 500)
{ else if (PP.getSkillLevel(SkillType.REPAIR) >= 500)
rank = 3; rank = 3;
} else if(PP.getSkillLevel(SkillType.REPAIR) >= 250)
{ else if(PP.getSkillLevel(SkillType.REPAIR) >= 250)
rank = 2; rank = 2;
} else if (PP.getSkillLevel(SkillType.REPAIR) >= 100)
{ else if (PP.getSkillLevel(SkillType.REPAIR) >= 100)
rank = 1; rank = 1;
}
return rank; return rank;
} }
public static void addEnchants(ItemStack is, Enchantment[] enchants, int[] enchantsLvl, PlayerProfile PP, Player player)
{ public static void addEnchants(ItemStack is, Enchantment[] enchants, int[] enchantsLvl, PlayerProfile PP, Player player){
if(is.getEnchantments().keySet().size() == 0) if(is.getEnchantments().keySet().size() == 0)
return; return;
@ -328,8 +328,7 @@ public class Repair {
player.sendMessage(mcLocale.getString("Repair.Downgraded")); player.sendMessage(mcLocale.getString("Repair.Downgraded"));
} }
} }
public static int getEnchantChance(int rank) public static int getEnchantChance(int rank){
{
switch(rank) switch(rank)
{ {
case 4: case 4:
@ -361,9 +360,9 @@ public class Repair {
} }
} }
public static boolean isArmor(ItemStack is){ public static boolean isArmor(ItemStack is){
return is.getTypeId() == 306 || is.getTypeId() == 307 ||is.getTypeId() == 308 ||is.getTypeId() == 309 || return is.getTypeId() == 306 || is.getTypeId() == 307 ||is.getTypeId() == 308 ||is.getTypeId() == 309 || //IRON
is.getTypeId() == 310 ||is.getTypeId() == 311 ||is.getTypeId() == 312 ||is.getTypeId() == 313 || is.getTypeId() == 310 ||is.getTypeId() == 311 ||is.getTypeId() == 312 ||is.getTypeId() == 313 || //DIAMOND
is.getTypeId() == 314 || is.getTypeId() == 315 || is.getTypeId() == 316 || is.getTypeId() == 317; is.getTypeId() == 314 || is.getTypeId() == 315 || is.getTypeId() == 316 || is.getTypeId() == 317; //GOLD
} }
public static boolean isGoldArmor(ItemStack is){ public static boolean isGoldArmor(ItemStack is){
return is.getTypeId() == 314 || is.getTypeId() == 315 || is.getTypeId() == 316 || is.getTypeId() == 317; return is.getTypeId() == 314 || is.getTypeId() == 315 || is.getTypeId() == 316 || is.getTypeId() == 317;
@ -378,7 +377,7 @@ public class Repair {
{ {
return is.getTypeId() == 359 || is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267 || is.getTypeId() == 292 || //IRON return is.getTypeId() == 359 || is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267 || is.getTypeId() == 292 || //IRON
is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279 || is.getTypeId() == 293 || //DIAMOND is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279 || is.getTypeId() == 293 || //DIAMOND
is.getTypeId() == 283 || is.getTypeId() == 285 || is.getTypeId() == 286 || is.getTypeId() == 284 || //GOLD is.getTypeId() == 283 || is.getTypeId() == 285 || is.getTypeId() == 286 || is.getTypeId() == 284 || is.getTypeId() == 294 || //GOLD
is.getTypeId() == 268 || is.getTypeId() == 269 || is.getTypeId() == 270 || is.getTypeId() == 271 || is.getTypeId() == 290 ||//WOOD is.getTypeId() == 268 || is.getTypeId() == 269 || is.getTypeId() == 270 || is.getTypeId() == 271 || is.getTypeId() == 290 ||//WOOD
is.getTypeId() == 272 || is.getTypeId() == 273 || is.getTypeId() == 274 || is.getTypeId() == 275|| is.getTypeId() == 291; //STONE is.getTypeId() == 272 || is.getTypeId() == 273 || is.getTypeId() == 274 || is.getTypeId() == 275|| is.getTypeId() == 291; //STONE
} }
@ -394,14 +393,8 @@ public class Repair {
public static boolean isIronTools(ItemStack is){ public static boolean isIronTools(ItemStack is){
return is.getTypeId() == 359 || is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267 || is.getTypeId() == 292; return is.getTypeId() == 359 || is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267 || is.getTypeId() == 292;
} }
public static boolean isDiamondTools(ItemStack is){ public static boolean isDiamondTools(ItemStack is){
if(is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279 || is.getTypeId() == 293) return is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279 || is.getTypeId() == 293;
{
return true;
} else {
return false;
}
} }
public static void removeItem(Player player, int typeid) public static void removeItem(Player player, int typeid)
{ {
@ -437,9 +430,7 @@ public class Repair {
if(checkPlayerProcRepair(player)){ if(checkPlayerProcRepair(player)){
ramt = (short) (ramt * 2); ramt = (short) (ramt * 2);
} }
//player.sendMessage(ChatColor.DARK_RED + "test " +ChatColor.BLUE+ );
durability-=ramt; durability-=ramt;
// player.sendMessage(ChatColor.DARK_RED + "durability " +ChatColor.BLUE+ durability);
if(durability < 0){ if(durability < 0){
durability = 0; durability = 0;
} }
@ -453,13 +444,17 @@ public class Repair {
/* /*
* TOOLS * TOOLS
*/ */
//SHEARS //SHEARS
case 359: case 359:
ramt = Material.SHEARS.getMaxDurability(); ramt = Material.SHEARS.getMaxDurability() / 2;
break; break;
/* WOOD TOOLS */
//WOOD SWORD //WOOD SWORD
case 268: case 268:
ramt = Material.WOOD_SWORD.getMaxDurability(); ramt = Material.WOOD_SWORD.getMaxDurability() / 2;
break; break;
//WOOD SHOVEL //WOOD SHOVEL
case 269: case 269:
@ -467,19 +462,22 @@ public class Repair {
break; break;
//WOOD PICKAXE //WOOD PICKAXE
case 270: case 270:
ramt = Material.WOOD_PICKAXE.getMaxDurability(); ramt = Material.WOOD_PICKAXE.getMaxDurability() / 3;
break; break;
//WOOD AXE //WOOD AXE
case 271: case 271:
ramt = Material.WOOD_AXE.getMaxDurability(); ramt = Material.WOOD_AXE.getMaxDurability() / 3;
break; break;
//WOOD HOE //WOOD HOE
case 290: case 290:
ramt = Material.WOOD_HOE.getMaxDurability(); ramt = Material.WOOD_HOE.getMaxDurability() / 2;
break; break;
/* STONE TOOLS */
//STONE SWORD //STONE SWORD
case 272: case 272:
ramt = Material.STONE_SWORD.getMaxDurability(); ramt = Material.STONE_SWORD.getMaxDurability() / 2;
break; break;
//STONE SHOVEL //STONE SHOVEL
case 273: case 273:
@ -487,129 +485,150 @@ public class Repair {
break; break;
//STONE PICKAXE //STONE PICKAXE
case 274: case 274:
ramt = Material.STONE_PICKAXE.getMaxDurability(); ramt = Material.STONE_PICKAXE.getMaxDurability() / 3;
break; break;
//STONE AXE //STONE AXE
case 275: case 275:
ramt = Material.STONE_AXE.getMaxDurability(); ramt = Material.STONE_AXE.getMaxDurability() / 3;
break; break;
//STONE HOE //STONE HOE
case 291: case 291:
ramt = Material.STONE_HOE.getMaxDurability(); ramt = Material.STONE_HOE.getMaxDurability() / 2;
break; break;
//GOLD SHOVEL
case 284: /* IRON TOOLS */
ramt = Material.GOLD_SPADE.getMaxDurability();
//IRON SWORD
case 267:
ramt = Material.IRON_SWORD.getMaxDurability() / 2;
break; break;
//IRON SHOVEL //IRON SHOVEL
case 256: case 256:
ramt = Material.IRON_SPADE.getMaxDurability(); ramt = Material.IRON_SPADE.getMaxDurability();
break; break;
//IRON PICK
case 257:
ramt = Material.IRON_PICKAXE.getMaxDurability() / 3;
break;
//IRON AXE
case 258:
ramt = Material.IRON_AXE.getMaxDurability() / 3;
break;
//IRON HOE
case 292:
ramt = Material.IRON_HOE.getMaxDurability() / 2;
break;
/* DIAMOND TOOLS */
//DIAMOND SWORD
case 276:
ramt = Material.DIAMOND_SWORD.getMaxDurability() / 2;
break;
//DIAMOND SHOVEL //DIAMOND SHOVEL
case 277: case 277:
ramt = Material.DIAMOND_SPADE.getMaxDurability(); ramt = Material.DIAMOND_SPADE.getMaxDurability();
break; break;
//IRON PICK
case 257:
ramt = Material.IRON_PICKAXE.getMaxDurability();
break;
//IRON AXE
case 258:
ramt = Material.IRON_AXE.getMaxDurability();
break;
//IRON SWORD
case 267:
ramt = Material.IRON_SWORD.getMaxDurability();
break;
//IRON HOE
case 292:
ramt = Material.IRON_HOE.getMaxDurability();
break;
//DIAMOND SWORD
case 276:
ramt = Material.DIAMOND_SWORD.getMaxDurability();
break;
//DIAMOND PICK //DIAMOND PICK
case 278: case 278:
ramt = Material.DIAMOND_PICKAXE.getMaxDurability(); ramt = Material.DIAMOND_PICKAXE.getMaxDurability() / 3;
break; break;
//DIAMOND AXE //DIAMOND AXE
case 279: case 279:
ramt = Material.DIAMOND_AXE.getMaxDurability(); ramt = Material.DIAMOND_AXE.getMaxDurability() / 3;
break; break;
//DIAMOND HOE //DIAMOND HOE
case 293: case 293:
ramt = Material.DIAMOND_HOE.getMaxDurability(); ramt = Material.DIAMOND_HOE.getMaxDurability() / 2;
break; break;
/* GOLD TOOLS */
//GOLD SWORD //GOLD SWORD
case 283: case 283:
ramt = Material.GOLD_SWORD.getMaxDurability(); ramt = Material.GOLD_SWORD.getMaxDurability() / 2;
break;
//GOLD SHOVEL
case 284:
ramt = Material.GOLD_SPADE.getMaxDurability();
break; break;
//GOLD PICK //GOLD PICK
case 285: case 285:
ramt = Material.GOLD_PICKAXE.getMaxDurability(); ramt = Material.GOLD_PICKAXE.getMaxDurability() / 3;
break; break;
//GOLD AXE //GOLD AXE
case 286: case 286:
ramt = Material.GOLD_AXE.getMaxDurability(); ramt = Material.GOLD_AXE.getMaxDurability() / 3;
break; break;
//GOLD HOE //GOLD HOE
case 294: case 294:
ramt = Material.GOLD_HOE.getMaxDurability(); ramt = Material.GOLD_HOE.getMaxDurability() / 2;
break; break;
/* /*
* ARMOR * ARMOR
*/ */
/* IRON ARMOR */
//IRON HELMET
case 306: case 306:
ramt = 27; ramt = Material.IRON_HELMET.getMaxDurability() / 5;
break; break;
//IRON CHESTPLATE
case 310:
ramt = 55;
break;
case 307: case 307:
ramt = 24; ramt = Material.IRON_CHESTPLATE.getMaxDurability() / 8;
break; break;
//IRON LEGGINGS
case 311:
ramt = 48;
break;
case 308: case 308:
ramt = 27; ramt = Material.IRON_LEGGINGS.getMaxDurability() / 7;
break; break;
//IRON BOOTS
case 312:
ramt = 53;
break;
case 309: case 309:
ramt = 40; ramt = Material.IRON_BOOTS.getMaxDurability() / 4;
break; break;
/* DIAMOND ARMOR */
//DIAMOND HELMET
case 310:
ramt = Material.DIAMOND_HELMET.getMaxDurability() / 5;
break;
//DIAMOND CHESTPLATE
case 311:
ramt = Material.DIAMOND_CHESTPLATE.getMaxDurability() / 8;
break;
//DIAMOND LEGGINGS
case 312:
ramt = Material.DIAMOND_LEGGINGS.getMaxDurability() / 7;
break;
//DIAMOND BOOTS
case 313: case 313:
ramt = 80; ramt = Material.DIAMOND_BOOTS.getMaxDurability() / 4;
break; break;
/* GOLD ARMOR */
//GOLD HELMET
case 314: case 314:
ramt = 13; ramt = Material.GOLD_HELMET.getMaxDurability() / 5;
break; break;
//GOLD CHESTPLATE
case 315: case 315:
ramt = 12; ramt = Material.GOLD_CHESTPLATE.getMaxDurability() / 8;
break; break;
//GOLD LEGGINGS
case 316: case 316:
ramt = 14; ramt = Material.GOLD_LEGGINGS.getMaxDurability() / 7;
break; break;
//GOLD BOOTS
case 317: case 317:
ramt = 20; ramt = Material.GOLD_BOOTS.getMaxDurability() / 4;
break; break;
} }
return repairCalculate(player, durability, ramt); return repairCalculate(player, durability, ramt);
} }
public static void needMoreVespeneGas(ItemStack is, Player player) public static void needMoreVespeneGas(ItemStack is, Player player)
{ {
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);