From 8988679f2ae50c29c29816f95a6d07d31f13da48 Mon Sep 17 00:00:00 2001 From: Esophose Date: Sat, 4 May 2019 20:09:20 -0600 Subject: [PATCH] Misc bug fixes --- .../CurrentAdapter.java | 2 +- .../ultimatetimber/manager/TreeDefinitionManager.java | 4 ++-- .../ultimatetimber/manager/TreeDetectionManager.java | 10 ++++++++++ .../Plugin/src/main/resources/config-current.yml | 4 +++- .../Plugin/src/main/resources/config-legacy.yml | 4 +++- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/UltimateTimber-Adapter/Current/src/main/java/com.songoda.ultimatetimber.adapter.current/CurrentAdapter.java b/UltimateTimber-Adapter/Current/src/main/java/com.songoda.ultimatetimber.adapter.current/CurrentAdapter.java index e07150c..e6c7537 100644 --- a/UltimateTimber-Adapter/Current/src/main/java/com.songoda.ultimatetimber.adapter.current/CurrentAdapter.java +++ b/UltimateTimber-Adapter/Current/src/main/java/com.songoda.ultimatetimber.adapter.current/CurrentAdapter.java @@ -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); diff --git a/UltimateTimber/Plugin/src/main/java/com/songoda/ultimatetimber/manager/TreeDefinitionManager.java b/UltimateTimber/Plugin/src/main/java/com/songoda/ultimatetimber/manager/TreeDefinitionManager.java index a0393d9..a08cce5 100644 --- a/UltimateTimber/Plugin/src/main/java/com/songoda/ultimatetimber/manager/TreeDefinitionManager.java +++ b/UltimateTimber/Plugin/src/main/java/com/songoda/ultimatetimber/manager/TreeDefinitionManager.java @@ -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")) diff --git a/UltimateTimber/Plugin/src/main/java/com/songoda/ultimatetimber/manager/TreeDetectionManager.java b/UltimateTimber/Plugin/src/main/java/com/songoda/ultimatetimber/manager/TreeDetectionManager.java index d50ca0e..a59c792 100644 --- a/UltimateTimber/Plugin/src/main/java/com/songoda/ultimatetimber/manager/TreeDetectionManager.java +++ b/UltimateTimber/Plugin/src/main/java/com/songoda/ultimatetimber/manager/TreeDetectionManager.java @@ -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; diff --git a/UltimateTimber/Plugin/src/main/resources/config-current.yml b/UltimateTimber/Plugin/src/main/resources/config-current.yml index addf49b..2c50a41 100644 --- a/UltimateTimber/Plugin/src/main/resources/config-current.yml +++ b/UltimateTimber/Plugin/src/main/resources/config-current.yml @@ -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 diff --git a/UltimateTimber/Plugin/src/main/resources/config-legacy.yml b/UltimateTimber/Plugin/src/main/resources/config-legacy.yml index 9eb2a5d..43b2352 100644 --- a/UltimateTimber/Plugin/src/main/resources/config-legacy.yml +++ b/UltimateTimber/Plugin/src/main/resources/config-legacy.yml @@ -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