BlockBreakEvent with a players empty hand

Discussion in 'Spigot Plugin Development' started by PCPSells, Jun 19, 2017 at 4:23 PM.

  1. Code -
    Code (Text):
     if (e.getBlock().getType().equals(Material.TNT)) {
                 if (type == Material.AIR) {
                     e.setCancelled(true);
                     p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8(&b!&8) &3&l» &cMine TNT &fmust be broken with your pickaxe."));
                 return;
             } if (type == Material.DIAMOND_PICKAXE || type == Material.GOLD_PICKAXE || type == Material.IRON_PICKAXE || type == Material.STONE_PICKAXE || type == Material.WOOD_PICKAXE) {
                p.playSound(p.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1.0F, 1.0F);
                p.spawnParticle(Particle.EXPLOSION_LARGE, e.getBlock().getLocation(), 1);
                createExplosion(e.getBlock().getLocation(), p, 250);
             } else {
                 e.setCancelled(true);
                 p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8(&b!&8) &3&l» &cMine TNT &fmust be broken with your pickaxe."));
                 return;
             }} if (e.getBlock().getType().equals(Material.SPONGE)) {
                 if (type == Material.AIR) {
                     e.setCancelled(true);
                     p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8(&b!&8) &3&l» &6L&eu&ec&6k&6y &eB&6l&eo&6c&ek&6s &fmust be broken with your pickaxe."));
                 return;
             }
    I know I made this extensive but it was my last shot at hoping maybe this worked.
    Any idea?

    What happens is whenever I use any other actually item than a pickaxe it tells me the message properly.
    But if I'm holding nothing in my hand, the sponge/tnt will still drop to the ground.
     

Share This Page