mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Changed tool ability damage to use built in Bukkit methods.
This commit is contained in:
parent
b199568ec3
commit
6f9fc26ab5
@ -144,26 +144,6 @@ public class m
|
||||
return false; //Return false if something went wrong
|
||||
}
|
||||
}
|
||||
|
||||
public static void damageTool(Player player, short damage)
|
||||
{
|
||||
if(player.getItemInHand().getTypeId() == 0)
|
||||
return;
|
||||
player.getItemInHand().setDurability((short) (player.getItemInHand().getDurability() + damage));
|
||||
if(player.getItemInHand().getDurability() >= getMaxDurability(getTier(player), player.getItemInHand()))
|
||||
{
|
||||
ItemStack[] inventory = player.getInventory().getContents();
|
||||
for(ItemStack x : inventory)
|
||||
{
|
||||
if(x != null && x.getTypeId() == player.getItemInHand().getTypeId() && x.getDurability() == player.getItemInHand().getDurability()){
|
||||
x.setTypeId(0);
|
||||
x.setAmount(0);
|
||||
player.getInventory().setContents(inventory);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Integer getTier(Player player)
|
||||
{
|
||||
@ -182,26 +162,6 @@ public class m
|
||||
return 1; //UNRECOGNIZED
|
||||
}
|
||||
}
|
||||
|
||||
public static Integer getMaxDurability(Integer tier, ItemStack item)
|
||||
{
|
||||
int id = item.getTypeId();
|
||||
if(tier == 1){
|
||||
if((id == 283 || id == 284 || id == 285 || id == 286 || id == 294)){
|
||||
return 33; //GOLD
|
||||
} else {
|
||||
return 60; //WOOD
|
||||
}
|
||||
} else if (tier == 2){
|
||||
return 132;
|
||||
} else if (tier == 3){
|
||||
return 251;
|
||||
} else if (tier == 4){
|
||||
return 1562;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static double getDistance(Location loca, Location locb)
|
||||
{
|
||||
|
@ -204,7 +204,11 @@ public class Excavation
|
||||
if(LoadProperties.toolsLoseDurabilityFromAbilities)
|
||||
{
|
||||
if(!player.getItemInHand().containsEnchantment(Enchantment.DURABILITY))
|
||||
m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss);
|
||||
{
|
||||
short durability = player.getItemInHand().getDurability();
|
||||
durability -= LoadProperties.abilityDurabilityLoss;
|
||||
player.getItemInHand().setDurability(durability);
|
||||
}
|
||||
}
|
||||
|
||||
if(block.getData() != (byte)5)
|
||||
|
@ -264,7 +264,11 @@ public class Mining
|
||||
if(LoadProperties.toolsLoseDurabilityFromAbilities)
|
||||
{
|
||||
if(!player.getItemInHand().containsEnchantment(Enchantment.DURABILITY))
|
||||
m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss);
|
||||
{
|
||||
short durability = player.getItemInHand().getDurability();
|
||||
durability -= LoadProperties.abilityDurabilityLoss;
|
||||
player.getItemInHand().setDurability(durability);
|
||||
}
|
||||
}
|
||||
|
||||
//Pre-processing
|
||||
|
@ -36,6 +36,7 @@ import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.config.*;
|
||||
|
||||
import org.getspout.spoutapi.sound.SoundEffect;
|
||||
|
||||
|
||||
@ -261,7 +262,15 @@ public class WoodCutting
|
||||
if(LoadProperties.toolsLoseDurabilityFromAbilities)
|
||||
{
|
||||
if(!player.getItemInHand().containsEnchantment(Enchantment.DURABILITY))
|
||||
m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss);
|
||||
{
|
||||
System.out.println("BEFORE");
|
||||
System.out.println(player.getItemInHand().getDurability());
|
||||
short durability = player.getItemInHand().getDurability();
|
||||
durability -= LoadProperties.abilityDurabilityLoss;
|
||||
player.getItemInHand().setDurability(durability);
|
||||
System.out.println("AFTER");
|
||||
System.out.println(player.getItemInHand().getDurability());
|
||||
}
|
||||
}
|
||||
|
||||
if(LoadProperties.spoutEnabled)
|
||||
|
Loading…
Reference in New Issue
Block a user