package org.steelrework.log_tim;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
public class Log_Tim
extends JavaPlugin
implements Listener {
public void onEnable() {
Bukkit.getServer().getPluginManager().registerEvents(this, this);
this.getLogger().info("LogRestorationPlugin has been enabled!");
}
public void onDisable() {
this.getLogger().info("LogRestorationPlugin has been disabled.");
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
Block block = event.getClickedBlock();
ItemStack itemInHand = event.getItem();
if (block != null && itemInHand != null && itemInHand.getType() == Material.BONE_MEAL) {
switch (block.getType()) {
case STRIPPED_OAK_LOG: {
block.setType(Material.OAK_LOG);
break;
}
case STRIPPED_BIRCH_LOG: {
block.setType(Material.BIRCH_LOG);
break;
}
case STRIPPED_SPRUCE_LOG: {
block.setType(Material.SPRUCE_LOG);
break;
}
case STRIPPED_JUNGLE_LOG: {
block.setType(Material.JUNGLE_LOG);
break;
}
case STRIPPED_ACACIA_LOG: {
block.setType(Material.ACACIA_LOG);
break;
}
case STRIPPED_DARK_OAK_LOG: {
block.setType(Material.DARK_OAK_LOG);
break;
}
case STRIPPED_MANGROVE_LOG: {
block.setType(Material.MANGROVE_LOG);
break;
}
case STRIPPED_CRIMSON_STEM: {
block.setType(Material.CRIMSON_STEM);
break;
}
case STRIPPED_WARPED_STEM: {
block.setType(Material.WARPED_STEM);
break;
}
case STRIPPED_CHERRY_LOG: {
block.setType(Material.CHERRY_LOG);
break;
}
default: {
return;
}
}
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_WOOD_PLACE, 1.0f, 1.0f);
block.getWorld().spawnParticle(Particle.LANDING_HONEY, block.getLocation().add(0.5, 0.5, 0.5), 100, 1.0, 1.0, 1.0, 0.5);
if (!event.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
itemInHand.setAmount(itemInHand.getAmount() - 1);
}
}
}
}
}