diff --git a/README.md b/README.md index aa9a3aa..6e9f25a 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ AhosallTreeCapitator is a simple and efficient plugin that automates the process - Compatible with all types of Minecraft axes and trees. - Players who only want to mine one block can use sneaking mode to disable the capping of entire trees. +- Trees are replanted after cutting them above the first block of the tree, if you cut them on the first block the saplings will not be replanted. ## Compatibility diff --git a/pom.xml b/pom.xml index 6497eb3..dadb562 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ xyz.ahosall.treecapitator ahosall-tree-capitator - 1.0.1 + 1.1.0 17 diff --git a/src/main/java/xyz/ahosall/treecapitator/listeners/TreeCapitatorListener.java b/src/main/java/xyz/ahosall/treecapitator/listeners/TreeCapitatorListener.java index 720c4aa..8cbcf15 100644 --- a/src/main/java/xyz/ahosall/treecapitator/listeners/TreeCapitatorListener.java +++ b/src/main/java/xyz/ahosall/treecapitator/listeners/TreeCapitatorListener.java @@ -76,7 +76,14 @@ private void processConnectedWood(Block block, Player player, ItemStack tool, Se adjacentBlock.getWorld().playSound(player.getLocation(), Sound.BLOCK_WOOD_BREAK, 1.0f, 1.0f); adjacentBlock.getWorld().dropItemNaturally(adjacentBlock.getLocation(), new ItemStack(adjacentBlock.getType())); - adjacentBlock.setType(Material.AIR); + + Material blockMaterial = Material.AIR; + Boolean isDirt = adjacentBlock.getRelative(0, -1, 0).getType().equals(Material.DIRT); + + if (isDirt) + blockMaterial = Material.getMaterial(adjacentBlock.getType().toString().replace("_LOG", "_SAPLING")); + + adjacentBlock.setType(blockMaterial); updateDurability(tool); processConnectedWood(adjacentBlock, player, tool, processedBlocks);