mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-28 11:37:39 +01:00
Changed tool ability damage to use built in Bukkit methods.
This commit is contained in:
parent
b199568ec3
commit
6f9fc26ab5
@ -145,26 +145,6 @@ public class m
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
public static Integer getTier(Player player)
|
||||||
{
|
{
|
||||||
int i = player.getItemInHand().getTypeId();
|
int i = player.getItemInHand().getTypeId();
|
||||||
@ -183,26 +163,6 @@ public class m
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
public static double getDistance(Location loca, Location locb)
|
||||||
{
|
{
|
||||||
return Math.sqrt(Math.pow(loca.getX() - locb.getX(), 2) + Math.pow(loca.getY() - locb.getY(), 2)
|
return Math.sqrt(Math.pow(loca.getX() - locb.getX(), 2) + Math.pow(loca.getY() - locb.getY(), 2)
|
||||||
|
@ -204,7 +204,11 @@ public class Excavation
|
|||||||
if(LoadProperties.toolsLoseDurabilityFromAbilities)
|
if(LoadProperties.toolsLoseDurabilityFromAbilities)
|
||||||
{
|
{
|
||||||
if(!player.getItemInHand().containsEnchantment(Enchantment.DURABILITY))
|
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)
|
if(block.getData() != (byte)5)
|
||||||
|
@ -264,7 +264,11 @@ public class Mining
|
|||||||
if(LoadProperties.toolsLoseDurabilityFromAbilities)
|
if(LoadProperties.toolsLoseDurabilityFromAbilities)
|
||||||
{
|
{
|
||||||
if(!player.getItemInHand().containsEnchantment(Enchantment.DURABILITY))
|
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
|
//Pre-processing
|
||||||
|
@ -36,6 +36,7 @@ import com.gmail.nossr50.datatypes.SkillType;
|
|||||||
import com.gmail.nossr50.locale.mcLocale;
|
import com.gmail.nossr50.locale.mcLocale;
|
||||||
import com.gmail.nossr50.spout.SpoutStuff;
|
import com.gmail.nossr50.spout.SpoutStuff;
|
||||||
import com.gmail.nossr50.config.*;
|
import com.gmail.nossr50.config.*;
|
||||||
|
|
||||||
import org.getspout.spoutapi.sound.SoundEffect;
|
import org.getspout.spoutapi.sound.SoundEffect;
|
||||||
|
|
||||||
|
|
||||||
@ -261,7 +262,15 @@ public class WoodCutting
|
|||||||
if(LoadProperties.toolsLoseDurabilityFromAbilities)
|
if(LoadProperties.toolsLoseDurabilityFromAbilities)
|
||||||
{
|
{
|
||||||
if(!player.getItemInHand().containsEnchantment(Enchantment.DURABILITY))
|
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)
|
if(LoadProperties.spoutEnabled)
|
||||||
|
Loading…
Reference in New Issue
Block a user