package com.github.club559.Timber;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.event.block.BlockBreakEvent;
public class Timber extends org.bukkit.plugin.java.JavaPlugin
{
public Timber() {}
public void onEnable()
{
getConfig().options().copyDefaults(true);
saveConfig();
getLogger().info("Loaded config file");
getServer().getPluginManager().registerEvents(new org.bukkit.event.Listener() {
@org.bukkit.event.EventHandler
public void timberIt(BlockBreakEvent event) {
int ih = event.getPlayer().getItemInHand().getTypeId();
World tw = event.getPlayer().getWorld();
int x = event.getBlock().getX();
int y = event.getBlock().getY();
int z = event.getBlock().getZ();
reloadConfig();
if ((event.getBlock().getTypeId() == 17) && (getConfig().getIntegerList("timber-items").contains(Integer.valueOf(ih)))) {
breakChain(tw, x, y, z);
}
}
}, this);
}
private Integer gb(World world, int x, int y, int z) {
return Integer.valueOf(world.getBlockTypeIdAt(x, y, z));
}
public void breakChain(World w, int x, int y, int z)
{
String t = getConfig().getString("timber-type");
String ty; if ((t.equals("classic")) || (t.equals("classic-leaves")) || (t.equals("full")) || (t.equals("full-noleaves"))) {
ty = t;
} else {
return;
}
String ty;
w.getBlockAt(x, y, z).breakNaturally();
if (gb(w, x, y + 1, z).intValue() == 17) {
breakChain(w, x, y + 1, z);
}
if ((ty.equals("classic-leaves")) || (ty.equals("full"))) {
if (gb(w, x, y + 1, z).intValue() == 18) {
breakChain(w, x, y + 1, z);
}
if (gb(w, x, y - 1, z).intValue() == 18) {
breakChain(w, x, y - 1, z);
}
if (gb(w, x + 1, y, z).intValue() == 18) {
breakChain(w, x + 1, y, z);
}
if (gb(w, x - 1, y, z).intValue() == 18) {
breakChain(w, x - 1, y, z);
}
if (gb(w, x, y, z + 1).intValue() == 18) {
breakChain(w, x, y, z + 1);
}
if (gb(w, x, y, z - 1).intValue() == 18) {
breakChain(w, x, y, z - 1);
}
}
if ((ty.equals("full")) || (ty.equals("full-noleaves"))) {
if (gb(w, x, y - 1, z).intValue() == 17) {
breakChain(w, x, y - 1, z);
}
if (gb(w, x + 1, y, z).intValue() == 17) {
breakChain(w, x + 1, y, z);
}
if (gb(w, x - 1, y, z).intValue() == 17) {
breakChain(w, x - 1, y, z);
}
if (gb(w, x, y, z + 1).intValue() == 17) {
breakChain(w, x, y, z + 1);
}
if (gb(w, x, y, z - 1).intValue() == 17) {
breakChain(w, x, y, z - 1);
}
}
}
}