Misc bug fixes

This commit is contained in:
Esophose 2019-05-04 20:09:20 -06:00
parent 119e54ad28
commit 8988679f2a
5 changed files with 19 additions and 5 deletions

View File

@ -60,7 +60,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) || tool.getType().getMaxDurability() < 1)
if (tool.getType().getMaxDurability() < 1)
return;
int unbreakingLevel = tool.getEnchantmentLevel(Enchantment.DURABILITY);

View File

@ -128,10 +128,10 @@ public class TreeDefinitionManager extends Manager {
this.globalLeafLoot.add(this.getTreeLootEntry(versionAdapter, TreeBlockType.LEAF, leafSection.getConfigurationSection(lootKey)));
// Load global entire tree drops
ConfigurationSection entireTreeSection = config.getConfigurationSection("global-leaf-loot");
ConfigurationSection entireTreeSection = config.getConfigurationSection("global-entire-tree-loot");
if (entireTreeSection != null)
for (String lootKey : entireTreeSection.getKeys(false))
this.globalEntireTreeLoot.add(this.getTreeLootEntry(versionAdapter, TreeBlockType.LEAF, entireTreeSection.getConfigurationSection(lootKey)));
this.globalEntireTreeLoot.add(this.getTreeLootEntry(versionAdapter, TreeBlockType.LOG, entireTreeSection.getConfigurationSection(lootKey)));
// Load global tools
for (String itemStackString : config.getStringList("global-required-tools"))

View File

@ -98,6 +98,14 @@ public class TreeDetectionManager extends Manager {
possibleTreeDefinitions.retainAll(this.treeDefinitionManager.narrowTreeDefinition(possibleTreeDefinitions, targetBlock, TreeBlockType.LOG));
}
if (!this.onlyBreakLogsUpwards) {
targetBlock = initialBlock;
while (this.isValidLogType(possibleTreeDefinitions, null, (targetBlock = targetBlock.getRelative(BlockFace.DOWN)))) {
trunkBlocks.add(targetBlock);
possibleTreeDefinitions.retainAll(this.treeDefinitionManager.narrowTreeDefinition(possibleTreeDefinitions, targetBlock, TreeBlockType.LOG));
}
}
// Lowest blocks at the front of the list
Collections.reverse(trunkBlocks);
@ -256,6 +264,8 @@ public class TreeDetectionManager extends Manager {
Location location = block.getLocation();
for (TreeDefinition treeDefinition : treeDefinitions) {
double maxDistance = treeDefinition.getMaxLogDistanceFromTrunk() * treeDefinition.getMaxLogDistanceFromTrunk();
if (!this.onlyBreakLogsUpwards) // Help detect logs more often if the tree isn't broken at the base
maxDistance *= 1.5;
for (Block trunkBlock : trunkBlocks)
if (location.distanceSquared(trunkBlock.getLocation()) < maxDistance)
return true;

View File

@ -47,7 +47,7 @@ protect-tool: false
apply-silk-touch: true
# Damage the tool extra for each leaf block broken, this is vanilla behavior but can be disabled here
# Note: Does nothing if realistic-tool-damage is false
# Does nothing if realistic-tool-damage is false
# Default: true
apply-silk-touch-tool-damage: true
@ -82,6 +82,7 @@ player-tree-topple-cooldown: false
# The amount of seconds a player has to wait before they can chop a tree again
# Does nothing if player-tree-topple-cooldown is false
# The time is in seconds and must be a postive whole number
# Default: 5
player-tree-topple-cooldown-length: 5
@ -100,6 +101,7 @@ always-replant-sapling: false
# How many seconds to prevent players from breaking replanted saplings
# Set to 0 to disable
# Does nothing if replant-saplings is false
# The time is in seconds and must be a postive whole number
# Default: 3
replant-saplings-cooldown: 3

View File

@ -48,7 +48,7 @@ protect-tool: false
apply-silk-touch: true
# Damage the tool extra for each leaf block broken, this is vanilla behavior but can be disabled here
# Note: Does nothing if realistic-tool-damage is false
# Does nothing if realistic-tool-damage is false
# Default: true
apply-silk-touch-tool-damage: true
@ -83,6 +83,7 @@ player-tree-topple-cooldown: false
# The amount of seconds a player has to wait before they can chop a tree again
# Does nothing if player-tree-topple-cooldown is false
# The time is in seconds and must be a postive whole number
# Default: 5
player-tree-topple-cooldown-length: 5
@ -101,6 +102,7 @@ always-replant-sapling: false
# How many seconds to prevent players from breaking replanted saplings
# Set to 0 to disable
# Does nothing if replant-saplings is false
# The time is in seconds and must be a postive whole number
# Default: 3
replant-saplings-cooldown: 3