mirror of
https://github.com/songoda/UltimateTimber.git
synced 2024-12-11 11:10:04 +01:00
Fix tool damage not being applied
This commit is contained in:
parent
120cb29c3b
commit
e94a0c6259
@ -56,8 +56,7 @@ public class CurrentAdapter implements VersionAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public void applyToolDurability(Player player, int damage) {
|
public void applyToolDurability(Player player, int damage) {
|
||||||
ItemStack tool = this.getItemInHand(player);
|
ItemStack tool = this.getItemInHand(player);
|
||||||
|
if (!(tool.getItemMeta() instanceof Damageable))
|
||||||
if (!tool.hasItemMeta() || !(tool.getItemMeta() instanceof Damageable))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int unbreakingLevel = tool.getEnchantmentLevel(Enchantment.DURABILITY);
|
int unbreakingLevel = tool.getEnchantmentLevel(Enchantment.DURABILITY);
|
||||||
@ -71,7 +70,8 @@ public class CurrentAdapter implements VersionAdapter {
|
|||||||
damageable.setDamage(damageable.getDamage() + actualDamage);
|
damageable.setDamage(damageable.getDamage() + actualDamage);
|
||||||
tool.setItemMeta((ItemMeta) damageable);
|
tool.setItemMeta((ItemMeta) damageable);
|
||||||
|
|
||||||
|
if (!this.hasEnoughDurability(tool, 1))
|
||||||
|
this.removeItemInHand(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,7 +42,7 @@ public class Methods {
|
|||||||
* @return True if durability should be applied, otherwise false
|
* @return True if durability should be applied, otherwise false
|
||||||
*/
|
*/
|
||||||
public static boolean checkUnbreakingChance(int level) {
|
public static boolean checkUnbreakingChance(int level) {
|
||||||
return ((double) 1 / (level + 1)) > random.nextDouble();
|
return (1.0 / (level + 1)) > random.nextDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,9 @@ public class TreeFallManager extends Manager implements Listener {
|
|||||||
if (detectedTree == null)
|
if (detectedTree == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!treeDefinitionManager.isToolValidForTreeDefinition(detectedTree.getTreeDefinition(), tool))
|
||||||
|
return;
|
||||||
|
|
||||||
int toolDamage = ConfigurationManager.Setting.REALISTIC_TOOL_DAMAGE.getBoolean() ? detectedTree.getDetectedTreeBlocks().getLogBlocks().size() : 1;
|
int toolDamage = ConfigurationManager.Setting.REALISTIC_TOOL_DAMAGE.getBoolean() ? detectedTree.getDetectedTreeBlocks().getLogBlocks().size() : 1;
|
||||||
if (ConfigurationManager.Setting.PROTECT_TOOL.getBoolean() && !versionAdapter.hasEnoughDurability(tool, toolDamage))
|
if (ConfigurationManager.Setting.PROTECT_TOOL.getBoolean() && !versionAdapter.hasEnoughDurability(tool, toolDamage))
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user