mirror of
https://github.com/songoda/UltimateTimber.git
synced 2025-02-14 18:51:54 +01:00
cleaned
This commit is contained in:
parent
2ff0745a32
commit
08d304444e
@ -24,12 +24,14 @@ PS: MagmaGuy was here
|
||||
|
||||
public class UltimateTimber extends JavaPlugin {
|
||||
private static CommandSender console = Bukkit.getConsoleSender();
|
||||
|
||||
private final String prefix = "&8[&6UltimateTimber&8]";
|
||||
|
||||
private static UltimateTimber INSTANCE;
|
||||
private final String prefix = "&8[&6UltimateTimber&8]";
|
||||
private List<World> validWorlds = new ArrayList<>();
|
||||
|
||||
public static UltimateTimber getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
@ -76,10 +78,6 @@ public class UltimateTimber extends JavaPlugin {
|
||||
validWorlds.clear();
|
||||
}
|
||||
|
||||
public static UltimateTimber getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public List<World> getValidWorlds() {
|
||||
return Collections.unmodifiableList(validWorlds);
|
||||
}
|
||||
@ -87,6 +85,7 @@ public class UltimateTimber extends JavaPlugin {
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
private boolean checkVersion() {
|
||||
int workingVersion = 13;
|
||||
int currentVersion = Integer.parseInt(Bukkit.getServer().getClass()
|
||||
|
@ -7,13 +7,13 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ReloadCommand {
|
||||
class ReloadCommand {
|
||||
|
||||
public static void reloadConfig(CommandSender commandSender) {
|
||||
static void reloadConfig(CommandSender commandSender) {
|
||||
|
||||
if(commandSender instanceof Player){
|
||||
if (commandSender instanceof Player) {
|
||||
|
||||
if(!commandSender.hasPermission("ut.reload")){
|
||||
if (!commandSender.hasPermission("ut.reload")) {
|
||||
commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cYou don't have permission!"));
|
||||
return;
|
||||
}
|
||||
|
@ -8,15 +8,14 @@ import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
public class AxeDurability {
|
||||
class AxeDurability {
|
||||
|
||||
/*
|
||||
This class handles all durability damage dealt to the axe used to chop down the tree, only takes into account
|
||||
wood blocks chopped down
|
||||
*/
|
||||
public static void adjustAxeDamage(HashSet<Block> blocks, Player player) {
|
||||
static void adjustAxeDamage(HashSet<Block> blocks, Player player) {
|
||||
ItemStack item = player.getInventory().getItemInMainHand();
|
||||
|
||||
if (!(item.getType().equals(Material.DIAMOND_AXE) ||
|
||||
@ -44,7 +43,8 @@ public class AxeDurability {
|
||||
|
||||
item.setItemMeta((ItemMeta) damageableMeta);
|
||||
|
||||
if (item.getDurability() >= item.getType().getMaxDurability()) player.setItemInHand(new ItemStack(Material.AIR));
|
||||
if (item.getDurability() >= item.getType().getMaxDurability())
|
||||
player.setItemInHand(new ItemStack(Material.AIR));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class CustomLoot {
|
||||
*/
|
||||
private static HashMap<ItemStack, Double> itemMap = new HashMap<>();
|
||||
|
||||
public static void doCustomItemDrop(Location location) {
|
||||
static void doCustomItemDrop(Location location) {
|
||||
for (ItemStack itemStack : itemMap.keySet())
|
||||
if ((ThreadLocalRandom.current().nextDouble()) < itemMap.get(itemStack) / 100)
|
||||
location.getWorld().dropItem(location, itemStack);
|
||||
|
@ -7,23 +7,21 @@ import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
public class EventFilter {
|
||||
class EventFilter {
|
||||
|
||||
/*
|
||||
Incorporate all checks that would disqualify this event from happening
|
||||
Mostly config settings, also permissions
|
||||
*/
|
||||
public static boolean eventIsValid(BlockBreakEvent event) {
|
||||
static boolean eventIsValid(BlockBreakEvent event) {
|
||||
UltimateTimber plugin = UltimateTimber.getInstance();
|
||||
|
||||
/*
|
||||
General catchers
|
||||
*/
|
||||
if (event.isCancelled()) return false;
|
||||
|
||||
if (!plugin.getValidWorlds().contains(event.getPlayer().getWorld())) return false;
|
||||
|
||||
if (!TreeChecker.validMaterials.contains(event.getBlock().getType())) return false;
|
||||
if (event.isCancelled()
|
||||
|| !plugin.getValidWorlds().contains(event.getPlayer().getWorld())
|
||||
|| !TreeChecker.validMaterials.contains(event.getBlock().getType())) return false;
|
||||
|
||||
FileConfiguration fileConfiguration = UltimateTimber.getInstance().getConfig();
|
||||
|
||||
|
@ -1,31 +1,28 @@
|
||||
package com.songoda.ultimatetimber.treefall;
|
||||
|
||||
import com.songoda.ultimatetimber.utils.LeafToSaplingConverter;
|
||||
import org.bukkit.Bukkit;
|
||||
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 {
|
||||
class NoAnimationTreeDestroyer {
|
||||
|
||||
/*
|
||||
Only ever triggers when people have tree falling animations off in the config
|
||||
*/
|
||||
public static void destroyTree(HashSet<Block> blocks, boolean hasBonusLoot, boolean hasSilkTouch) {
|
||||
static void destroyTree(HashSet<Block> blocks, boolean hasBonusLoot, boolean hasSilkTouch) {
|
||||
|
||||
Material leavesType = null;
|
||||
|
||||
if(!blocks.stream().filter(b -> b.getType() == Material.BROWN_MUSHROOM_BLOCK).collect(Collectors.toList()).isEmpty()){
|
||||
if (!blocks.stream().filter(b -> b.getType() == Material.BROWN_MUSHROOM_BLOCK).collect(Collectors.toList()).isEmpty()) {
|
||||
|
||||
leavesType = Material.BROWN_MUSHROOM_BLOCK;
|
||||
|
||||
} else if(!blocks.stream().filter(b -> b.getType() == Material.RED_MUSHROOM_BLOCK).collect(Collectors.toList()).isEmpty()){
|
||||
} else if (!blocks.stream().filter(b -> b.getType() == Material.RED_MUSHROOM_BLOCK).collect(Collectors.toList()).isEmpty()) {
|
||||
leavesType = Material.RED_MUSHROOM_BLOCK;
|
||||
}
|
||||
|
||||
@ -33,8 +30,7 @@ public class NoAnimationTreeDestroyer {
|
||||
|
||||
Material material = LeafToSaplingConverter.convertLeaves(block.getType());
|
||||
|
||||
if (material.equals(Material.AIR)) continue;
|
||||
if (material.equals(Material.VINE)) continue;
|
||||
if (material.equals(Material.AIR) || material.equals(Material.VINE)) continue;
|
||||
|
||||
ItemStack toDrop = getItem(material);
|
||||
|
||||
@ -78,9 +74,9 @@ public class NoAnimationTreeDestroyer {
|
||||
block.setType(Material.AIR);
|
||||
CustomLoot.doCustomItemDrop(block.getLocation());
|
||||
|
||||
if(leavesType != null){
|
||||
if (leavesType != null) {
|
||||
TreeReplant.replaceOriginalBlock(block, leavesType);
|
||||
} else{
|
||||
} else {
|
||||
TreeReplant.replaceOriginalBlock(block);
|
||||
}
|
||||
|
||||
@ -89,11 +85,11 @@ public class NoAnimationTreeDestroyer {
|
||||
|
||||
}
|
||||
|
||||
static ItemStack getItem(Material material){
|
||||
static ItemStack getItem(Material material) {
|
||||
|
||||
if(material == Material.BROWN_MUSHROOM_BLOCK){
|
||||
if (material == Material.BROWN_MUSHROOM_BLOCK) {
|
||||
return new ItemStack(Material.BROWN_MUSHROOM, 1);
|
||||
} else if(material == Material.RED_MUSHROOM_BLOCK){
|
||||
} else if (material == Material.RED_MUSHROOM_BLOCK) {
|
||||
return new ItemStack(Material.RED_MUSHROOM, 1);
|
||||
}
|
||||
return new ItemStack(material, 1);
|
||||
|
@ -8,14 +8,87 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class TreeChecker {
|
||||
class TreeChecker {
|
||||
|
||||
/*
|
||||
Used to check if a tree is a tree
|
||||
*/
|
||||
static List<Material> validMaterials = new ArrayList<>(Arrays.asList(
|
||||
Material.ACACIA_LOG,
|
||||
Material.STRIPPED_ACACIA_LOG,
|
||||
Material.BIRCH_LOG,
|
||||
Material.STRIPPED_BIRCH_LOG,
|
||||
Material.DARK_OAK_LOG,
|
||||
Material.STRIPPED_DARK_OAK_LOG,
|
||||
Material.JUNGLE_LOG,
|
||||
Material.STRIPPED_JUNGLE_LOG,
|
||||
Material.OAK_LOG,
|
||||
Material.STRIPPED_OAK_LOG,
|
||||
Material.SPRUCE_LOG,
|
||||
Material.STRIPPED_SPRUCE_LOG,
|
||||
Material.MUSHROOM_STEM
|
||||
));
|
||||
/*
|
||||
Used to limit the blocks that constitute a tree
|
||||
*/
|
||||
private static List<Material> validTreeMaterials = new ArrayList<>(Arrays.asList(
|
||||
Material.ACACIA_LEAVES,
|
||||
Material.BIRCH_LEAVES,
|
||||
Material.DARK_OAK_LEAVES,
|
||||
Material.JUNGLE_LEAVES,
|
||||
Material.OAK_LEAVES,
|
||||
Material.SPRUCE_LEAVES,
|
||||
Material.COCOA_BEANS,
|
||||
Material.BROWN_MUSHROOM_BLOCK,
|
||||
Material.RED_MUSHROOM_BLOCK
|
||||
));
|
||||
/*
|
||||
A list of materials found in a forest, allows the plugin to work in dense woods
|
||||
*/
|
||||
private static List<Material> forestMaterials = new ArrayList<>(Arrays.asList(
|
||||
Material.AIR,
|
||||
Material.CAVE_AIR,
|
||||
Material.VOID_AIR,
|
||||
Material.VINE,
|
||||
Material.ROSE_BUSH,
|
||||
Material.ORANGE_TULIP,
|
||||
Material.PINK_TULIP,
|
||||
Material.RED_TULIP,
|
||||
Material.POPPY,
|
||||
Material.WHITE_TULIP,
|
||||
Material.OXEYE_DAISY,
|
||||
Material.AZURE_BLUET,
|
||||
Material.BLUE_ORCHID,
|
||||
Material.ALLIUM,
|
||||
Material.DANDELION,
|
||||
Material.DANDELION_YELLOW,
|
||||
Material.LILAC,
|
||||
Material.PEONY,
|
||||
Material.TALL_GRASS,
|
||||
Material.FERN,
|
||||
Material.LARGE_FERN,
|
||||
Material.DEAD_BUSH,
|
||||
Material.BROWN_MUSHROOM,
|
||||
Material.RED_MUSHROOM,
|
||||
Material.GRASS,
|
||||
Material.SPRUCE_SAPLING,
|
||||
Material.OAK_SAPLING,
|
||||
Material.JUNGLE_SAPLING,
|
||||
Material.ACACIA_SAPLING,
|
||||
Material.BIRCH_SAPLING,
|
||||
Material.DARK_OAK_SAPLING,
|
||||
Material.DIRT,
|
||||
Material.COARSE_DIRT,
|
||||
Material.GRASS_BLOCK,
|
||||
Material.SNOW,
|
||||
Material.SNOW_BLOCK
|
||||
));
|
||||
/*
|
||||
This stores all the blocks returned later on
|
||||
*/
|
||||
private HashSet<Block> allBlocks = new HashSet<>();
|
||||
|
||||
public HashSet<Block> validTreeHandler(Block block) {
|
||||
HashSet<Block> validTreeHandler(Block block) {
|
||||
|
||||
HashSet<Block> blocks = parseTree(block);
|
||||
|
||||
@ -28,7 +101,7 @@ public class TreeChecker {
|
||||
if (TreeChecker.validTreeMaterials.contains(localBlock.getType())) {
|
||||
containsLeaves = true;
|
||||
break;
|
||||
} else if(TreeChecker.validMaterials.contains(localBlock.getType())){
|
||||
} else if (TreeChecker.validMaterials.contains(localBlock.getType())) {
|
||||
containsLeaves = true;
|
||||
break;
|
||||
}
|
||||
@ -46,7 +119,7 @@ public class TreeChecker {
|
||||
* @param block block the player originally destroys
|
||||
* @return returns null if the tree isn't valid or all blocks in the tree if it isn't
|
||||
*/
|
||||
public HashSet<Block> parseTree(Block block) {
|
||||
private HashSet<Block> parseTree(Block block) {
|
||||
|
||||
/*
|
||||
Check if material is parsed by this plugin
|
||||
@ -203,80 +276,4 @@ public class TreeChecker {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Used to check if a tree is a tree
|
||||
*/
|
||||
public static List<Material> validMaterials = new ArrayList<>(Arrays.asList(
|
||||
Material.ACACIA_LOG,
|
||||
Material.STRIPPED_ACACIA_LOG,
|
||||
Material.BIRCH_LOG,
|
||||
Material.STRIPPED_BIRCH_LOG,
|
||||
Material.DARK_OAK_LOG,
|
||||
Material.STRIPPED_DARK_OAK_LOG,
|
||||
Material.JUNGLE_LOG,
|
||||
Material.STRIPPED_JUNGLE_LOG,
|
||||
Material.OAK_LOG,
|
||||
Material.STRIPPED_OAK_LOG,
|
||||
Material.SPRUCE_LOG,
|
||||
Material.STRIPPED_SPRUCE_LOG,
|
||||
Material.MUSHROOM_STEM
|
||||
));
|
||||
|
||||
/*
|
||||
Used to limit the blocks that constitute a tree
|
||||
*/
|
||||
public static List<Material> validTreeMaterials = new ArrayList<>(Arrays.asList(
|
||||
Material.ACACIA_LEAVES,
|
||||
Material.BIRCH_LEAVES,
|
||||
Material.DARK_OAK_LEAVES,
|
||||
Material.JUNGLE_LEAVES,
|
||||
Material.OAK_LEAVES,
|
||||
Material.SPRUCE_LEAVES,
|
||||
Material.COCOA_BEANS,
|
||||
Material.BROWN_MUSHROOM_BLOCK,
|
||||
Material.RED_MUSHROOM_BLOCK
|
||||
));
|
||||
|
||||
/*
|
||||
A list of materials found in a forest, allows the plugin to work in dense woods
|
||||
*/
|
||||
private static List<Material> forestMaterials = new ArrayList<>(Arrays.asList(
|
||||
Material.AIR,
|
||||
Material.CAVE_AIR,
|
||||
Material.VOID_AIR,
|
||||
Material.VINE,
|
||||
Material.ROSE_BUSH,
|
||||
Material.ORANGE_TULIP,
|
||||
Material.PINK_TULIP,
|
||||
Material.RED_TULIP,
|
||||
Material.POPPY,
|
||||
Material.WHITE_TULIP,
|
||||
Material.OXEYE_DAISY,
|
||||
Material.AZURE_BLUET,
|
||||
Material.BLUE_ORCHID,
|
||||
Material.ALLIUM,
|
||||
Material.DANDELION,
|
||||
Material.DANDELION_YELLOW,
|
||||
Material.LILAC,
|
||||
Material.PEONY,
|
||||
Material.TALL_GRASS,
|
||||
Material.FERN,
|
||||
Material.LARGE_FERN,
|
||||
Material.DEAD_BUSH,
|
||||
Material.BROWN_MUSHROOM,
|
||||
Material.RED_MUSHROOM,
|
||||
Material.GRASS,
|
||||
Material.SPRUCE_SAPLING,
|
||||
Material.OAK_SAPLING,
|
||||
Material.JUNGLE_SAPLING,
|
||||
Material.ACACIA_SAPLING,
|
||||
Material.BIRCH_SAPLING,
|
||||
Material.DARK_OAK_SAPLING,
|
||||
Material.DIRT,
|
||||
Material.COARSE_DIRT,
|
||||
Material.GRASS_BLOCK,
|
||||
Material.SNOW,
|
||||
Material.SNOW_BLOCK
|
||||
));
|
||||
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
public class TreeEntityDamage {
|
||||
class TreeEntityDamage {
|
||||
|
||||
public static void runDamage(FallingBlock fallingBlock) {
|
||||
static void runDamage(FallingBlock fallingBlock) {
|
||||
|
||||
for (Entity entity : fallingBlock.getNearbyEntities(0.5, 0.5, 0.5)) {
|
||||
|
||||
|
@ -17,16 +17,28 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
public class TreeFallAnimation implements Listener {
|
||||
|
||||
/*
|
||||
Register all instances of falling trees.
|
||||
*/
|
||||
private static ArrayList<TreeFallAnimation> treeFallAnimationInstances = new ArrayList<>();
|
||||
/*
|
||||
This field gets updated based on player permissions, doubles loot from trees
|
||||
*/
|
||||
private boolean hasBonusLoot;
|
||||
/*
|
||||
If a player's tool has the silk touch enchantment, it changes the loot table
|
||||
*/
|
||||
private boolean hasSilkTouch;
|
||||
/*
|
||||
This field stores every falling block in this instance of the animation
|
||||
This list is also used to identify if a falling block is a part of an animation
|
||||
*/
|
||||
private ArrayList<FallingBlock> fallingBlocks = new ArrayList<>();
|
||||
|
||||
public boolean hasBonusLoot() {
|
||||
private boolean hasBonusLoot() {
|
||||
return this.hasBonusLoot;
|
||||
}
|
||||
|
||||
@ -34,12 +46,7 @@ public class TreeFallAnimation implements Listener {
|
||||
this.hasBonusLoot = bool;
|
||||
}
|
||||
|
||||
/*
|
||||
If a player's tool has the silk touch enchantment, it changes the loot table
|
||||
*/
|
||||
private boolean hasSilkTouch;
|
||||
|
||||
public boolean hasSilkTouch() {
|
||||
private boolean hasSilkTouch() {
|
||||
return this.hasSilkTouch;
|
||||
}
|
||||
|
||||
@ -47,13 +54,7 @@ public class TreeFallAnimation implements Listener {
|
||||
this.hasSilkTouch = bool;
|
||||
}
|
||||
|
||||
/*
|
||||
This field stores every falling block in this instance of the animation
|
||||
This list is also used to identify if a falling block is a part of an animation
|
||||
*/
|
||||
private ArrayList<FallingBlock> fallingBlocks = new ArrayList<>();
|
||||
|
||||
public boolean isFallingTreeBlock(FallingBlock fallingBlock) {
|
||||
private boolean isFallingTreeBlock(FallingBlock fallingBlock) {
|
||||
return this.fallingBlocks.contains(fallingBlock);
|
||||
}
|
||||
|
||||
@ -69,19 +70,14 @@ public class TreeFallAnimation implements Listener {
|
||||
return this.fallingBlocks;
|
||||
}
|
||||
|
||||
/*
|
||||
Register all instances of falling trees.
|
||||
*/
|
||||
public static ArrayList<TreeFallAnimation> treeFallAnimationInstances = new ArrayList<>();
|
||||
|
||||
public boolean isInTreeFallInstance(FallingBlock fallingBlock) {
|
||||
private boolean isInTreeFallInstance(FallingBlock fallingBlock) {
|
||||
for (TreeFallAnimation treeFallAnimation : treeFallAnimationInstances)
|
||||
if (treeFallAnimation.isFallingTreeBlock(fallingBlock))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public TreeFallAnimation getTreeFallAnimation(FallingBlock fallingBlock) {
|
||||
private TreeFallAnimation getTreeFallAnimation(FallingBlock fallingBlock) {
|
||||
for (TreeFallAnimation treeFallAnimation : treeFallAnimationInstances)
|
||||
if (treeFallAnimation.isFallingTreeBlock(fallingBlock))
|
||||
return treeFallAnimation;
|
||||
@ -102,7 +98,7 @@ public class TreeFallAnimation implements Listener {
|
||||
Initially, the tree will start slowly toppling over.
|
||||
After a short while, it goes over the tipping point and the fall accelerates.
|
||||
*/
|
||||
public void startAnimation(Block originalBlock, HashSet<Block> blocks, Player player) {
|
||||
void startAnimation(Block originalBlock, HashSet<Block> blocks, Player player) {
|
||||
/*
|
||||
This vector makes sure that the entire tree falls in the same direction from the same reference point
|
||||
*/
|
||||
@ -128,7 +124,7 @@ public class TreeFallAnimation implements Listener {
|
||||
|
||||
for (Block block : blocks) {
|
||||
|
||||
FallingBlock fallingBlock = block.getWorld().spawnFallingBlock(block.getLocation().clone().add(0.5,0,0.5), block.getBlockData());
|
||||
FallingBlock fallingBlock = block.getWorld().spawnFallingBlock(block.getLocation().clone().add(0.5, 0, 0.5), block.getBlockData());
|
||||
fallingBlock.setDropItem(false);
|
||||
|
||||
|
||||
|
@ -2,7 +2,6 @@ package com.songoda.ultimatetimber.treefall;
|
||||
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
import com.songoda.ultimatetimber.configurations.DefaultConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@ -28,7 +27,7 @@ public class TreeFallEvent implements Listener {
|
||||
fileConfiguration.getBoolean(DefaultConfig.TIMEOUT_BREAK) && TreeReplant.isTimeout(event.getBlock()))
|
||||
event.setCancelled(true);
|
||||
if (!EventFilter.eventIsValid(event)) return;
|
||||
if(fileConfiguration.getBoolean(DefaultConfig.SNEAK_ONLY) && !event.getPlayer().isSneaking()) return;
|
||||
if (fileConfiguration.getBoolean(DefaultConfig.SNEAK_ONLY) && !event.getPlayer().isSneaking()) return;
|
||||
|
||||
TreeChecker treeChecker = new TreeChecker();
|
||||
HashSet<Block> blocks = treeChecker.validTreeHandler(event.getBlock());
|
||||
|
@ -4,13 +4,12 @@ import com.songoda.ultimatetimber.utils.LeafToSaplingConverter;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class TreeLoot {
|
||||
class TreeLoot {
|
||||
|
||||
public static void convertFallingBlock(FallingBlock fallingBlock, boolean hasBonusLoot, boolean hasSilkTouch) {
|
||||
static void convertFallingBlock(FallingBlock fallingBlock, boolean hasBonusLoot, boolean hasSilkTouch) {
|
||||
|
||||
Material material = LeafToSaplingConverter.convertLeaves(fallingBlock.getBlockData().getMaterial());
|
||||
|
||||
|
@ -14,11 +14,11 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class TreeReplant {
|
||||
class TreeReplant {
|
||||
|
||||
private static List<Location> timeout = new ArrayList<>();
|
||||
|
||||
public static void replaceOriginalBlock(Block block) {
|
||||
static void replaceOriginalBlock(Block block) {
|
||||
|
||||
|
||||
boolean isTimeout = UltimateTimber.getInstance().getConfig().getBoolean(DefaultConfig.TIMEOUT_BREAK);
|
||||
@ -29,7 +29,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.PODZOL)) {
|
||||
!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;
|
||||
}
|
||||
@ -83,7 +83,7 @@ public class TreeReplant {
|
||||
|
||||
}
|
||||
|
||||
public static void replaceOriginalBlock(Block block, Material leavesType) {
|
||||
static void replaceOriginalBlock(Block block, Material leavesType) {
|
||||
|
||||
boolean isTimeout = UltimateTimber.getInstance().getConfig().getBoolean(DefaultConfig.TIMEOUT_BREAK);
|
||||
|
||||
@ -93,7 +93,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.PODZOL)) {
|
||||
!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;
|
||||
}
|
||||
@ -134,11 +134,11 @@ public class TreeReplant {
|
||||
block.setType(Material.SPRUCE_SAPLING);
|
||||
return;
|
||||
default:
|
||||
if(leavesType == Material.BROWN_MUSHROOM_BLOCK){
|
||||
if (leavesType == Material.BROWN_MUSHROOM_BLOCK) {
|
||||
block.setType(Material.BROWN_MUSHROOM);
|
||||
} else if(leavesType == Material.RED_MUSHROOM_BLOCK){
|
||||
} else if (leavesType == Material.RED_MUSHROOM_BLOCK) {
|
||||
block.setType(Material.RED_MUSHROOM);
|
||||
} else{
|
||||
} else {
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
@ -147,7 +147,7 @@ public class TreeReplant {
|
||||
|
||||
}
|
||||
|
||||
public static void leafFallReplant(FallingBlock fallingBlock) {
|
||||
static void leafFallReplant(FallingBlock fallingBlock) {
|
||||
|
||||
Material material;
|
||||
|
||||
@ -191,7 +191,7 @@ public class TreeReplant {
|
||||
|
||||
}
|
||||
|
||||
public static boolean isTimeout(Block block) {
|
||||
static boolean isTimeout(Block block) {
|
||||
return timeout.contains(block.getLocation());
|
||||
}
|
||||
|
||||
|
@ -5,12 +5,12 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
|
||||
public class TreeSounds {
|
||||
class TreeSounds {
|
||||
|
||||
public static void tipOverNoise(Location location) {
|
||||
static void tipOverNoise(Location location) {
|
||||
|
||||
if(Bukkit.getServer().getClass().getPackage().toString().contains("8")){
|
||||
location.getWorld().playSound(location, Sound.valueOf("CHEST_OPEN"), 3f,0.1f);
|
||||
if (Bukkit.getServer().getClass().getPackage().toString().contains("8")) {
|
||||
location.getWorld().playSound(location, Sound.valueOf("CHEST_OPEN"), 3f, 0.1f);
|
||||
} else {
|
||||
|
||||
location.getWorld().playSound(location, Sound.BLOCK_CHEST_OPEN, 3F, 0.1F);
|
||||
@ -18,9 +18,9 @@ public class TreeSounds {
|
||||
|
||||
}
|
||||
|
||||
public static void fallNoise(FallingBlock fallingBlock) {
|
||||
static void fallNoise(FallingBlock fallingBlock) {
|
||||
|
||||
if(Bukkit.getServer().getClass().getPackage().toString().contains("8")){
|
||||
if (Bukkit.getServer().getClass().getPackage().toString().contains("8")) {
|
||||
fallingBlock.getWorld().playSound(fallingBlock.getLocation(), Sound.valueOf("ANVIL_LAND"), 3F, 0.1F);
|
||||
return;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ public class Methods {
|
||||
return formatText(text, false);
|
||||
}
|
||||
|
||||
public static String formatText(String text, boolean cap) {
|
||||
private static String formatText(String text, boolean cap) {
|
||||
if (text == null || text.equals(""))
|
||||
return "";
|
||||
if (cap)
|
||||
|
Loading…
Reference in New Issue
Block a user