mirror of
https://github.com/songoda/UltimateTimber.git
synced 2024-11-29 05:16:29 +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
|
||||
public void applyToolDurability(Player player, int damage) {
|
||||
ItemStack tool = this.getItemInHand(player);
|
||||
|
||||
if (!tool.hasItemMeta() || !(tool.getItemMeta() instanceof Damageable))
|
||||
if (!(tool.getItemMeta() instanceof Damageable))
|
||||
return;
|
||||
|
||||
int unbreakingLevel = tool.getEnchantmentLevel(Enchantment.DURABILITY);
|
||||
@ -71,7 +70,8 @@ public class CurrentAdapter implements VersionAdapter {
|
||||
damageable.setDamage(damageable.getDamage() + actualDamage);
|
||||
tool.setItemMeta((ItemMeta) damageable);
|
||||
|
||||
|
||||
if (!this.hasEnoughDurability(tool, 1))
|
||||
this.removeItemInHand(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,7 +42,7 @@ public class Methods {
|
||||
* @return True if durability should be applied, otherwise false
|
||||
*/
|
||||
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)
|
||||
return;
|
||||
|
||||
if (!treeDefinitionManager.isToolValidForTreeDefinition(detectedTree.getTreeDefinition(), tool))
|
||||
return;
|
||||
|
||||
int toolDamage = ConfigurationManager.Setting.REALISTIC_TOOL_DAMAGE.getBoolean() ? detectedTree.getDetectedTreeBlocks().getLogBlocks().size() : 1;
|
||||
if (ConfigurationManager.Setting.PROTECT_TOOL.getBoolean() && !versionAdapter.hasEnoughDurability(tool, toolDamage))
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user