TreeChecker update

Made so Mushrooms replant,
Increased accuracy of TreeChecker
This commit is contained in:
Brian 2018-12-15 13:32:50 +02:00
parent 5af145615b
commit 9495d15d67
6 changed files with 104 additions and 8 deletions

View File

@ -6,9 +6,11 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.inventory.ItemStack;
import sun.reflect.generics.tree.Tree;
import java.util.HashSet;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;
public class NoAnimationTreeDestroyer {
@ -17,13 +19,23 @@ public class NoAnimationTreeDestroyer {
*/
public static void destroyTree(HashSet<Block> blocks, boolean hasBonusLoot, boolean hasSilkTouch, Block minedLog) {
Block mainLog = getMainLog(minedLog.getLocation());
Material leavesType = null;
Location mainLogLocation = mainLog.getLocation().clone();
if(!blocks.stream().filter(b -> b.getType() == Material.BROWN_MUSHROOM_BLOCK).collect(Collectors.toList()).isEmpty()){
leavesType = Material.BROWN_MUSHROOM_BLOCK;
leavesType = Material.RED_MUSHROOM_BLOCK;
} else {
}
for (Block block : blocks) {
if(leavesType != null){
TreeReplant.replaceOriginalBlock(block, leavesType);
} else{
TreeReplant.replaceOriginalBlock(block);
}
Material material = LeafToSaplingConverter.convertLeaves(block.getType());

View File

@ -57,7 +57,7 @@ public class TreeChecker {
offset determines the search radius around the main trunk
maxheight sets the maximum height the plugin will crawl through to find a tree
*/
int offset = 8;
int offset = 5;
int maxHeight = 31;
/*
@ -141,11 +141,11 @@ public class TreeChecker {
int radMin, radMax;
if (i > 5) {
radMin = -4;
radMax = 5;
} else {
radMin = -3;
radMax = 4;
} else {
radMin = -2;
radMax = 3;
}

View File

@ -28,7 +28,7 @@ public class TreeReplant {
}
if (!block.getLocation().clone().subtract(new Vector(0, 1, 0)).getBlock().getType().equals(Material.DIRT) &&
!block.getLocation().clone().subtract(new Vector(0, 1, 0)).getBlock().getType().equals(Material.COARSE_DIRT)) {
!block.getLocation().clone().subtract(new Vector(0, 1, 0)).getBlock().getType().equals(Material.COARSE_DIRT) && !block.getLocation().clone().subtract(new Vector(0,1,0)).getBlock().getType().equals(Material.PODZOL)) {
block.setType(Material.AIR);
return;
}
@ -82,6 +82,70 @@ public class TreeReplant {
}
public static void replaceOriginalBlock(Block block, Material leavesType) {
boolean isTimeout = UltimateTimber.getInstance().getConfig().getBoolean(DefaultConfig.TIMEOUT_BREAK);
if (!UltimateTimber.getInstance().getConfig().getBoolean(DefaultConfig.REPLANT_SAPLING)) {
block.setType(Material.AIR);
return;
}
if (!block.getLocation().clone().subtract(new Vector(0, 1, 0)).getBlock().getType().equals(Material.DIRT) &&
!block.getLocation().clone().subtract(new Vector(0, 1, 0)).getBlock().getType().equals(Material.COARSE_DIRT) && !block.getLocation().clone().subtract(new Vector(0,1,0)).getBlock().getType().equals(Material.PODZOL)) {
block.setType(Material.AIR);
return;
}
Material material = block.getType();
if (isTimeout) {
timeout.add(block.getLocation());
Bukkit.getScheduler().scheduleSyncDelayedTask(UltimateTimber.getInstance(), () -> timeout.remove(block.getLocation()), 20 * 5);
}
new BukkitRunnable() {
@Override
public void run() {
switch (material) {
case ACACIA_LOG:
case STRIPPED_ACACIA_LOG:
block.setType(Material.ACACIA_SAPLING);
return;
case BIRCH_LOG:
case STRIPPED_BIRCH_LOG:
block.setType(Material.BIRCH_SAPLING);
return;
case DARK_OAK_LOG:
case STRIPPED_DARK_OAK_LOG:
block.setType(Material.DARK_OAK_SAPLING);
return;
case JUNGLE_LOG:
case STRIPPED_JUNGLE_LOG:
block.setType(Material.JUNGLE_SAPLING);
return;
case OAK_LOG:
case STRIPPED_OAK_LOG:
block.setType(Material.OAK_SAPLING);
return;
case SPRUCE_LOG:
case STRIPPED_SPRUCE_LOG:
block.setType(Material.SPRUCE_SAPLING);
return;
default:
if(leavesType == Material.BROWN_MUSHROOM_BLOCK){
block.setType(Material.BROWN_MUSHROOM);
} else if(leavesType == Material.RED_MUSHROOM_BLOCK){
block.setType(Material.RED_MUSHROOM);
} else{
block.setType(Material.AIR);
}
}
}
}.runTaskLater(UltimateTimber.getInstance(), 1);
}
public static void leafFallReplant(FallingBlock fallingBlock) {
Material material;

View File

@ -0,0 +1,2 @@
com\songoda\ultimatetimber\treefall\TreeReplant$3.class
com\songoda\ultimatetimber\utils\VersionChecker.class

View File

@ -0,0 +1,18 @@
G:\work\ultimatetimber\src\main\java\com\songoda\ultimatetimber\treefall\CustomLoot.java
G:\work\ultimatetimber\src\main\java\com\songoda\ultimatetimber\treefall\TreeSounds.java
G:\work\ultimatetimber\src\main\java\com\songoda\ultimatetimber\treefall\NoAnimationTreeDestroyer.java
G:\work\ultimatetimber\src\main\java\com\songoda\ultimatetimber\commands\CommandHandler.java
G:\work\ultimatetimber\src\main\java\com\songoda\ultimatetimber\treefall\TreeFallEvent.java
G:\work\ultimatetimber\src\main\java\com\songoda\ultimatetimber\treefall\TreeFallAnimation.java
G:\work\ultimatetimber\src\main\java\com\songoda\ultimatetimber\configurations\DefaultConfig.java
G:\work\ultimatetimber\src\main\java\com\songoda\ultimatetimber\treefall\TreeEntityDamage.java
G:\work\ultimatetimber\src\main\java\com\songoda\ultimatetimber\commands\ReloadCommand.java
G:\work\ultimatetimber\src\main\java\com\songoda\ultimatetimber\utils\Methods.java
G:\work\ultimatetimber\src\main\java\com\songoda\ultimatetimber\treefall\TreeLoot.java
G:\work\ultimatetimber\src\main\java\com\songoda\ultimatetimber\utils\VersionChecker.java
G:\work\ultimatetimber\src\main\java\com\songoda\ultimatetimber\utils\LeafToSaplingConverter.java
G:\work\ultimatetimber\src\main\java\com\songoda\ultimatetimber\treefall\TreeChecker.java
G:\work\ultimatetimber\src\main\java\com\songoda\ultimatetimber\UltimateTimber.java
G:\work\ultimatetimber\src\main\java\com\songoda\ultimatetimber\treefall\AxeDurability.java
G:\work\ultimatetimber\src\main\java\com\songoda\ultimatetimber\treefall\TreeReplant.java
G:\work\ultimatetimber\src\main\java\com\songoda\ultimatetimber\treefall\EventFilter.java