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
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
*/
*/
package com.gmail.nossr50.skills;
import org.bukkit.Material;
@ -34,19 +34,19 @@ import com.gmail.nossr50.locale.mcLocale;
public class Repair {
/*
* Repair requirements for each material
*/
private static int rGold = LoadProperties.rGold;
private static String nGold = LoadProperties.nGold;
private static int rStone = LoadProperties.rStone;
private static String nStone = LoadProperties.nStone;
private static int rWood = LoadProperties.rWood;
private static String nWood = LoadProperties.nWood;
private static int rDiamond = LoadProperties.rDiamond;
private static String nDiamond = LoadProperties.nDiamond;
private static int rIron = LoadProperties.rIron;
private static String nIron = LoadProperties.nIron;
/*
* Repair requirements for each material
*/
private static int rGold = LoadProperties.rGold;
private static String nGold = LoadProperties.nGold;
private static int rStone = LoadProperties.rStone;
private static String nStone = LoadProperties.nStone;
private static int rWood = LoadProperties.rWood;
private static String nWood = LoadProperties.nWood;
private static int rDiamond = LoadProperties.rDiamond;
private static String nDiamond = LoadProperties.nDiamond;
private static int rIron = LoadProperties.rIron;
private static String nIron = LoadProperties.nIron;
public static void repairCheck(Player player, ItemStack is, Block block){
@ -67,209 +67,209 @@ public class Repair {
pos++;
}
if(block != null && mcPermissions.getInstance().repair(player)){
if(player.getItemInHand().getDurability() > 0 && player.getItemInHand().getAmount() < 2){
if(block != null && mcPermissions.getInstance().repair(player)){
if(player.getItemInHand().getDurability() > 0 && player.getItemInHand().getAmount() < 2){
/*
* REPAIR ARMOR
*/
if(isArmor(is)){
/*
* REPAIR ARMOR
*/
if(isArmor(is)){
//DIAMOND ARMOR
if(isDiamondArmor(is) && hasItem(player, rDiamond) && PP.getSkillLevel(SkillType.REPAIR) >= LoadProperties.repairdiamondlevel){
removeItem(player, rDiamond);
repairItem(player, enchants, enchantsLevel);
//DIAMOND ARMOR
if(isDiamondArmor(is) && hasItem(player, rDiamond) && PP.getSkillLevel(SkillType.REPAIR) >= LoadProperties.repairdiamondlevel){
removeItem(player, rDiamond);
repairItem(player, enchants, enchantsLevel);
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 6); //Boost XP
PP.addXP(SkillType.REPAIR, dif*10, player);
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 6); //Boost XP
PP.addXP(SkillType.REPAIR, dif*10, player);
//CLANG CLANG
if(LoadProperties.spoutEnabled)
SpoutStuff.playRepairNoise(player);
}
//CLANG CLANG
if(LoadProperties.spoutEnabled)
SpoutStuff.playRepairNoise(player);
}
//IRON ARMOR
else if (isIronArmor(is) && hasItem(player, rIron)){
removeItem(player, rIron);
repairItem(player, enchants, enchantsLevel);
//IRON ARMOR
else if (isIronArmor(is) && hasItem(player, rIron)){
removeItem(player, rIron);
repairItem(player, enchants, enchantsLevel);
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 2); //Boost XP
PP.addXP(SkillType.REPAIR, dif*10, player);
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 2); //Boost XP
PP.addXP(SkillType.REPAIR, dif*10, player);
//CLANG CLANG
if(LoadProperties.spoutEnabled)
SpoutStuff.playRepairNoise(player);
}
//CLANG CLANG
if(LoadProperties.spoutEnabled)
SpoutStuff.playRepairNoise(player);
}
//GOLD ARMOR
else if (isGoldArmor(is) && hasItem(player, rGold)){
removeItem(player, rGold);
repairItem(player, enchants, enchantsLevel);
//GOLD ARMOR
else if (isGoldArmor(is) && hasItem(player, rGold)){
removeItem(player, rGold);
repairItem(player, enchants, enchantsLevel);
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 4); //Boost XP
PP.addXP(SkillType.REPAIR, dif*10, player);
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 4); //Boost XP
PP.addXP(SkillType.REPAIR, dif*10, player);
//CLANG CLANG
if(LoadProperties.spoutEnabled)
SpoutStuff.playRepairNoise(player);
}
//CLANG CLANG
if(LoadProperties.spoutEnabled)
SpoutStuff.playRepairNoise(player);
}
//UNABLE TO REPAIR
else {
needMoreVespeneGas(is, player);
}
}
//UNABLE TO REPAIR
else {
needMoreVespeneGas(is, player);
}
}
/*
* REPAIR TOOLS
*/
if(isTools(is)){
/*
* REPAIR TOOLS
*/
if(isTools(is)){
//STONE TOOLS
if(isStoneTools(is) && hasItem(player, rStone)){
removeItem(player, rStone);
repairItem(player, enchants, enchantsLevel);
//STONE TOOLS
if(isStoneTools(is) && hasItem(player, rStone)){
removeItem(player, rStone);
repairItem(player, enchants, enchantsLevel);
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
if(m.isShovel(is))
dif = (short) (dif / 3);
if(m.isSwords(is))
dif = (short) (dif / 2);
if(m.isHoe(is))
dif = (short) (dif / 2);
//STONE NERF
dif = (short) (dif / 2);
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
if(m.isShovel(is))
dif = (short) (dif / 3);
if(m.isSwords(is))
dif = (short) (dif / 2);
if(m.isHoe(is))
dif = (short) (dif / 2);
//STONE NERF
dif = (short) (dif / 2);
PP.addXP(SkillType.REPAIR, dif*10, player);
}
PP.addXP(SkillType.REPAIR, dif*10, player);
}
//WOOD TOOLS
else if(isWoodTools(is) && hasItem(player,rWood)){
removeItem(player,rWood);
repairItem(player, enchants, enchantsLevel);
//WOOD TOOLS
else if(isWoodTools(is) && hasItem(player,rWood)){
removeItem(player,rWood);
repairItem(player, enchants, enchantsLevel);
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
if(m.isShovel(is))
dif = (short) (dif / 3);
if(m.isSwords(is))
dif = (short) (dif / 2);
if(m.isHoe(is))
dif = (short) (dif / 2);
//WOOD NERF
dif = (short) (dif / 2);
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
if(m.isShovel(is))
dif = (short) (dif / 3);
if(m.isSwords(is))
dif = (short) (dif / 2);
if(m.isHoe(is))
dif = (short) (dif / 2);
//WOOD NERF
dif = (short) (dif / 2);
PP.addXP(SkillType.REPAIR, dif*10, player);
}
PP.addXP(SkillType.REPAIR, dif*10, player);
}
//IRON TOOLS
else if(isIronTools(is) && hasItem(player, rIron)){
removeItem(player, rIron);
repairItem(player, enchants, enchantsLevel);
//IRON TOOLS
else if(isIronTools(is) && hasItem(player, rIron)){
removeItem(player, rIron);
repairItem(player, enchants, enchantsLevel);
durabilityAfter = (short) (player.getItemInHand().getDurability()-getRepairAmount(is, player));
dif = (short) (durabilityBefore - durabilityAfter);
if(m.isShovel(is))
dif = (short) (dif / 3);
if(m.isSwords(is))
dif = (short) (dif / 2);
if(m.isHoe(is))
dif = (short) (dif / 2);
durabilityAfter = (short) (player.getItemInHand().getDurability()-getRepairAmount(is, player));
dif = (short) (durabilityBefore - durabilityAfter);
if(m.isShovel(is))
dif = (short) (dif / 3);
if(m.isSwords(is))
dif = (short) (dif / 2);
if(m.isHoe(is))
dif = (short) (dif / 2);
PP.addXP(SkillType.REPAIR, dif*10, player);
PP.addXP(SkillType.REPAIR, dif*10, player);
//CLANG CLANG
if(LoadProperties.spoutEnabled)
SpoutStuff.playRepairNoise(player);
//CLANG CLANG
if(LoadProperties.spoutEnabled)
SpoutStuff.playRepairNoise(player);
}
}
//DIAMOND TOOLS
else if (isDiamondTools(is) && hasItem(player, rDiamond) && PP.getSkillLevel(SkillType.REPAIR) >= LoadProperties.repairdiamondlevel){
removeItem(player, rDiamond);
repairItem(player, enchants, enchantsLevel);
//DIAMOND TOOLS
else if (isDiamondTools(is) && hasItem(player, rDiamond) && PP.getSkillLevel(SkillType.REPAIR) >= LoadProperties.repairdiamondlevel){
removeItem(player, rDiamond);
repairItem(player, enchants, enchantsLevel);
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
if(m.isShovel(is))
dif = (short) (dif / 3);
if(m.isSwords(is))
dif = (short) (dif / 2);
if(m.isHoe(is))
dif = (short) (dif / 2);
PP.addXP(SkillType.REPAIR, dif*10, player);
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
if(m.isShovel(is))
dif = (short) (dif / 3);
if(m.isSwords(is))
dif = (short) (dif / 2);
if(m.isHoe(is))
dif = (short) (dif / 2);
PP.addXP(SkillType.REPAIR, dif*10, player);
//CLANG CLANG
if(LoadProperties.spoutEnabled)
SpoutStuff.playRepairNoise(player);
//CLANG CLANG
if(LoadProperties.spoutEnabled)
SpoutStuff.playRepairNoise(player);
}
//GOLD TOOLS
else if(isGoldTools(is) && hasItem(player, rGold)){
removeItem(player, rGold);
repairItem(player, enchants, enchantsLevel);
}
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 7.6); //Boost XP for Gold to that of around Iron
if(m.isShovel(is))
dif = (short) (dif / 3);
if(m.isSwords(is))
dif = (short) (dif / 2);
if(m.isHoe(is))
dif = (short) (dif / 2);
PP.addXP(SkillType.REPAIR, dif*10, player);
//GOLD TOOLS
else if(isGoldTools(is) && hasItem(player, rGold)){
removeItem(player, rGold);
repairItem(player, enchants, enchantsLevel);
//CLANG CLANG
if(LoadProperties.spoutEnabled)
SpoutStuff.playRepairNoise(player);
}
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 7.6); //Boost XP for Gold to that of around Iron
if(m.isShovel(is))
dif = (short) (dif / 3);
if(m.isSwords(is))
dif = (short) (dif / 2);
if(m.isHoe(is))
dif = (short) (dif / 2);
PP.addXP(SkillType.REPAIR, dif*10, player);
//UNABLE TO REPAIR
else {
needMoreVespeneGas(is, player);
}
}
//CLANG CLANG
if(LoadProperties.spoutEnabled)
SpoutStuff.playRepairNoise(player);
}
//UNABLE TO REPAIR
else {
needMoreVespeneGas(is, player);
}
}
}
else {
player.sendMessage(mcLocale.getString("Skills.FullDurability"));
}
/*
* GIVE SKILL IF THERE IS ENOUGH XP
*/
Skills.XpCheckSkill(SkillType.REPAIR, player);
}
}
else {
player.sendMessage(mcLocale.getString("Skills.FullDurability"));
}
//player.updateInventory();
/*
* GIVE SKILL IF THERE IS ENOUGH XP
*/
Skills.XpCheckSkill(SkillType.REPAIR, player);
}
}
public static int getArcaneForgingRank(PlayerProfile PP)
{
public static int getArcaneForgingRank(PlayerProfile PP){
int rank = 0;
if(PP.getSkillLevel(SkillType.REPAIR) >= 750)
{
rank = 4;
} else if (PP.getSkillLevel(SkillType.REPAIR) >= 500)
{
else if (PP.getSkillLevel(SkillType.REPAIR) >= 500)
rank = 3;
} else if(PP.getSkillLevel(SkillType.REPAIR) >= 250)
{
else if(PP.getSkillLevel(SkillType.REPAIR) >= 250)
rank = 2;
} else if (PP.getSkillLevel(SkillType.REPAIR) >= 100)
{
else if (PP.getSkillLevel(SkillType.REPAIR) >= 100)
rank = 1;
}
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)
return;
@ -328,8 +328,7 @@ public class Repair {
player.sendMessage(mcLocale.getString("Repair.Downgraded"));
}
}
public static int getEnchantChance(int rank)
{
public static int getEnchantChance(int rank){
switch(rank)
{
case 4:
@ -361,260 +360,280 @@ public class Repair {
}
}
public static boolean isArmor(ItemStack is){
return is.getTypeId() == 306 || is.getTypeId() == 307 ||is.getTypeId() == 308 ||is.getTypeId() == 309 ||
is.getTypeId() == 310 ||is.getTypeId() == 311 ||is.getTypeId() == 312 ||is.getTypeId() == 313 ||
is.getTypeId() == 314 || is.getTypeId() == 315 || is.getTypeId() == 316 || is.getTypeId() == 317;
}
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 || //DIAMOND
is.getTypeId() == 314 || is.getTypeId() == 315 || is.getTypeId() == 316 || is.getTypeId() == 317; //GOLD
}
public static boolean isGoldArmor(ItemStack is){
return is.getTypeId() == 314 || is.getTypeId() == 315 || is.getTypeId() == 316 || is.getTypeId() == 317;
}
public static boolean isIronArmor(ItemStack is){
return is.getTypeId() == 306 || is.getTypeId() == 307 || is.getTypeId() == 308 || is.getTypeId() == 309;
}
public static boolean isDiamondArmor(ItemStack is){
return is.getTypeId() == 310 || is.getTypeId() == 311 || is.getTypeId() == 312 || is.getTypeId() == 313;
}
public static boolean isTools(ItemStack is)
{
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() == 283 || is.getTypeId() == 285 || is.getTypeId() == 286 || is.getTypeId() == 284 || //GOLD
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
}
public static boolean isStoneTools(ItemStack is){
return is.getTypeId() == 272 || is.getTypeId() == 273 || is.getTypeId() == 274 || is.getTypeId() == 275 || is.getTypeId() == 291;
}
public static boolean isWoodTools(ItemStack is){
return is.getTypeId() == 268 || is.getTypeId() == 269 || is.getTypeId() == 270 || is.getTypeId() == 271 || is.getTypeId() == 290;
}
public static boolean isGoldTools(ItemStack is){
return is.getTypeId() == 283 || is.getTypeId() == 285 || is.getTypeId() == 286 || is.getTypeId() == 284 || is.getTypeId() == 294;
}
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;
}
public static boolean isDiamondTools(ItemStack is){
if(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)
{
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x != null && x.getTypeId() == typeid){
if(x.getAmount() == 1){
x.setTypeId(0);
x.setAmount(0);
player.getInventory().setContents(inventory);
} else{
x.setAmount(x.getAmount() - 1);
player.getInventory().setContents(inventory);
}
return;
}
}
}
public static boolean hasItem(Player player, int typeid){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x != null && x.getTypeId() == typeid){
return true;
}
}
return false;
}
public static short repairCalculate(Player player, short durability, short ramt){
PlayerProfile PP = Users.getProfile(player);
float bonus = (PP.getSkillLevel(SkillType.REPAIR) / 500);
bonus = (ramt * bonus);
ramt = ramt+=bonus;
if(checkPlayerProcRepair(player)){
ramt = (short) (ramt * 2);
}
//player.sendMessage(ChatColor.DARK_RED + "test " +ChatColor.BLUE+ );
durability-=ramt;
// player.sendMessage(ChatColor.DARK_RED + "durability " +ChatColor.BLUE+ durability);
if(durability < 0){
durability = 0;
}
return durability;
}
public static short getRepairAmount(ItemStack is, Player player){
short durability = is.getDurability();
short ramt = 0;
switch(is.getTypeId())
{
/*
* TOOLS
*/
//SHEARS
case 359:
ramt = Material.SHEARS.getMaxDurability();
break;
//WOOD SWORD
case 268:
ramt = Material.WOOD_SWORD.getMaxDurability();
break;
//WOOD SHOVEL
case 269:
ramt = Material.WOOD_SPADE.getMaxDurability();
break;
//WOOD PICKAXE
case 270:
ramt = Material.WOOD_PICKAXE.getMaxDurability();
break;
//WOOD AXE
case 271:
ramt = Material.WOOD_AXE.getMaxDurability();
break;
//WOOD HOE
case 290:
ramt = Material.WOOD_HOE.getMaxDurability();
break;
//STONE SWORD
case 272:
ramt = Material.STONE_SWORD.getMaxDurability();
break;
//STONE SHOVEL
case 273:
ramt = Material.STONE_SPADE.getMaxDurability();
break;
//STONE PICKAXE
case 274:
ramt = Material.STONE_PICKAXE.getMaxDurability();
break;
//STONE AXE
case 275:
ramt = Material.STONE_AXE.getMaxDurability();
break;
//STONE HOE
case 291:
ramt = Material.STONE_HOE.getMaxDurability();
break;
//GOLD SHOVEL
case 284:
ramt = Material.GOLD_SPADE.getMaxDurability();
break;
//IRON SHOVEL
case 256:
ramt = Material.IRON_SPADE.getMaxDurability();
break;
//DIAMOND SHOVEL
case 277:
ramt = Material.DIAMOND_SPADE.getMaxDurability();
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
case 278:
ramt = Material.DIAMOND_PICKAXE.getMaxDurability();
break;
//DIAMOND AXE
case 279:
ramt = Material.DIAMOND_AXE.getMaxDurability();
break;
//DIAMOND HOE
case 293:
ramt = Material.DIAMOND_HOE.getMaxDurability();
break;
//GOLD SWORD
case 283:
ramt = Material.GOLD_SWORD.getMaxDurability();
break;
//GOLD PICK
case 285:
ramt = Material.GOLD_PICKAXE.getMaxDurability();
break;
//GOLD AXE
case 286:
ramt = Material.GOLD_AXE.getMaxDurability();
break;
//GOLD HOE
case 294:
ramt = Material.GOLD_HOE.getMaxDurability();
break;
/*
* ARMOR
*/
case 306:
ramt = 27;
break;
case 310:
ramt = 55;
break;
case 307:
ramt = 24;
break;
case 311:
ramt = 48;
break;
case 308:
ramt = 27;
break;
case 312:
ramt = 53;
break;
case 309:
ramt = 40;
break;
case 313:
ramt = 80;
break;
case 314:
ramt = 13;
break;
case 315:
ramt = 12;
break;
case 316:
ramt = 14;
break;
case 317:
ramt = 20;
break;
public static boolean isIronArmor(ItemStack is){
return is.getTypeId() == 306 || is.getTypeId() == 307 || is.getTypeId() == 308 || is.getTypeId() == 309;
}
public static boolean isDiamondArmor(ItemStack is){
return is.getTypeId() == 310 || is.getTypeId() == 311 || is.getTypeId() == 312 || is.getTypeId() == 313;
}
public static boolean isTools(ItemStack is)
{
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() == 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() == 272 || is.getTypeId() == 273 || is.getTypeId() == 274 || is.getTypeId() == 275|| is.getTypeId() == 291; //STONE
}
public static boolean isStoneTools(ItemStack is){
return is.getTypeId() == 272 || is.getTypeId() == 273 || is.getTypeId() == 274 || is.getTypeId() == 275 || is.getTypeId() == 291;
}
public static boolean isWoodTools(ItemStack is){
return is.getTypeId() == 268 || is.getTypeId() == 269 || is.getTypeId() == 270 || is.getTypeId() == 271 || is.getTypeId() == 290;
}
public static boolean isGoldTools(ItemStack is){
return is.getTypeId() == 283 || is.getTypeId() == 285 || is.getTypeId() == 286 || is.getTypeId() == 284 || is.getTypeId() == 294;
}
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;
}
public static boolean isDiamondTools(ItemStack is){
return is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279 || is.getTypeId() == 293;
}
public static void removeItem(Player player, int typeid)
{
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x != null && x.getTypeId() == typeid){
if(x.getAmount() == 1){
x.setTypeId(0);
x.setAmount(0);
player.getInventory().setContents(inventory);
} else{
x.setAmount(x.getAmount() - 1);
player.getInventory().setContents(inventory);
}
return;
}
}
}
public static boolean hasItem(Player player, int typeid){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x != null && x.getTypeId() == typeid){
return true;
}
}
return false;
}
public static short repairCalculate(Player player, short durability, short ramt){
PlayerProfile PP = Users.getProfile(player);
float bonus = (PP.getSkillLevel(SkillType.REPAIR) / 500);
bonus = (ramt * bonus);
ramt = ramt+=bonus;
if(checkPlayerProcRepair(player)){
ramt = (short) (ramt * 2);
}
durability-=ramt;
if(durability < 0){
durability = 0;
}
return durability;
}
public static short getRepairAmount(ItemStack is, Player player){
short durability = is.getDurability();
short ramt = 0;
switch(is.getTypeId())
{
/*
* TOOLS
*/
//SHEARS
case 359:
ramt = Material.SHEARS.getMaxDurability() / 2;
break;
/* WOOD TOOLS */
//WOOD SWORD
case 268:
ramt = Material.WOOD_SWORD.getMaxDurability() / 2;
break;
//WOOD SHOVEL
case 269:
ramt = Material.WOOD_SPADE.getMaxDurability();
break;
//WOOD PICKAXE
case 270:
ramt = Material.WOOD_PICKAXE.getMaxDurability() / 3;
break;
//WOOD AXE
case 271:
ramt = Material.WOOD_AXE.getMaxDurability() / 3;
break;
//WOOD HOE
case 290:
ramt = Material.WOOD_HOE.getMaxDurability() / 2;
break;
/* STONE TOOLS */
//STONE SWORD
case 272:
ramt = Material.STONE_SWORD.getMaxDurability() / 2;
break;
//STONE SHOVEL
case 273:
ramt = Material.STONE_SPADE.getMaxDurability();
break;
//STONE PICKAXE
case 274:
ramt = Material.STONE_PICKAXE.getMaxDurability() / 3;
break;
//STONE AXE
case 275:
ramt = Material.STONE_AXE.getMaxDurability() / 3;
break;
//STONE HOE
case 291:
ramt = Material.STONE_HOE.getMaxDurability() / 2;
break;
/* IRON TOOLS */
//IRON SWORD
case 267:
ramt = Material.IRON_SWORD.getMaxDurability() / 2;
break;
//IRON SHOVEL
case 256:
ramt = Material.IRON_SPADE.getMaxDurability();
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
case 277:
ramt = Material.DIAMOND_SPADE.getMaxDurability();
break;
//DIAMOND PICK
case 278:
ramt = Material.DIAMOND_PICKAXE.getMaxDurability() / 3;
break;
//DIAMOND AXE
case 279:
ramt = Material.DIAMOND_AXE.getMaxDurability() / 3;
break;
//DIAMOND HOE
case 293:
ramt = Material.DIAMOND_HOE.getMaxDurability() / 2;
break;
/* GOLD TOOLS */
//GOLD SWORD
case 283:
ramt = Material.GOLD_SWORD.getMaxDurability() / 2;
break;
//GOLD SHOVEL
case 284:
ramt = Material.GOLD_SPADE.getMaxDurability();
break;
//GOLD PICK
case 285:
ramt = Material.GOLD_PICKAXE.getMaxDurability() / 3;
break;
//GOLD AXE
case 286:
ramt = Material.GOLD_AXE.getMaxDurability() / 3;
break;
//GOLD HOE
case 294:
ramt = Material.GOLD_HOE.getMaxDurability() / 2;
break;
/*
* ARMOR
*/
/* IRON ARMOR */
//IRON HELMET
case 306:
ramt = Material.IRON_HELMET.getMaxDurability() / 5;
break;
//IRON CHESTPLATE
case 307:
ramt = Material.IRON_CHESTPLATE.getMaxDurability() / 8;
break;
//IRON LEGGINGS
case 308:
ramt = Material.IRON_LEGGINGS.getMaxDurability() / 7;
break;
//IRON BOOTS
case 309:
ramt = Material.IRON_BOOTS.getMaxDurability() / 4;
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:
ramt = Material.DIAMOND_BOOTS.getMaxDurability() / 4;
break;
/* GOLD ARMOR */
//GOLD HELMET
case 314:
ramt = Material.GOLD_HELMET.getMaxDurability() / 5;
break;
//GOLD CHESTPLATE
case 315:
ramt = Material.GOLD_CHESTPLATE.getMaxDurability() / 8;
break;
//GOLD LEGGINGS
case 316:
ramt = Material.GOLD_LEGGINGS.getMaxDurability() / 7;
break;
//GOLD BOOTS
case 317:
ramt = Material.GOLD_BOOTS.getMaxDurability() / 4;
break;
}
return repairCalculate(player, durability, ramt);
}
public static void needMoreVespeneGas(ItemStack is, Player player)
{
PlayerProfile PP = Users.getProfile(player);
if ((isDiamondTools(is) || isDiamondArmor(is)) && PP.getSkillLevel(SkillType.REPAIR) < LoadProperties.repairdiamondlevel)
{
}
public static void needMoreVespeneGas(ItemStack is, Player player)
{
PlayerProfile PP = Users.getProfile(player);
if ((isDiamondTools(is) || isDiamondArmor(is)) && PP.getSkillLevel(SkillType.REPAIR) < LoadProperties.repairdiamondlevel)
{
player.sendMessage(mcLocale.getString("Skills.AdeptDiamond"));
} else if (isDiamondTools(is) && !hasItem(player, rDiamond) || isIronTools(is) && !hasItem(player, rIron) || isGoldTools(is) && !hasItem(player, rGold)){
if(isDiamondTools(is) && !hasItem(player, rDiamond))
@ -635,10 +654,10 @@ public class Repair {
player.sendMessage(mcLocale.getString("Skills.NeedMore")+" "+ChatColor.GOLD+ nGold);
} else if (is.getAmount() > 1)
player.sendMessage(mcLocale.getString("Skills.StackedItems"));
}
public static boolean checkPlayerProcRepair(Player player)
{
PlayerProfile PP = Users.getProfile(player);
}
public static boolean checkPlayerProcRepair(Player player)
{
PlayerProfile PP = Users.getProfile(player);
if(player != null)
{
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.REPAIR))
@ -648,13 +667,13 @@ public class Repair {
}
}
return false;
}
public static void repairItem(Player player, Enchantment[] enchants, int[] enchantsLevel)
{
PlayerProfile PP = Users.getProfile(player);
ItemStack is = player.getItemInHand();
//Handle the enchantments
addEnchants(player.getItemInHand(), enchants, enchantsLevel, PP, player);
player.getItemInHand().setDurability(getRepairAmount(is, player));
}
}
public static void repairItem(Player player, Enchantment[] enchants, int[] enchantsLevel)
{
PlayerProfile PP = Users.getProfile(player);
ItemStack is = player.getItemInHand();
//Handle the enchantments
addEnchants(player.getItemInHand(), enchants, enchantsLevel, PP, player);
player.getItemInHand().setDurability(getRepairAmount(is, player));
}
}