[fixed]blockdrop doesn't work

Discussion in 'Plugin Development' started by mickverm, May 20, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    mickverm

    Hey guys, i've been making a plugin that makes ice drop iceblocks when mined with a pickaxe but for some reason nothing happens. (+ I don't get console errors)

    here is the code, I hope that someone can find what's wrong
    Code:
    package me.mickverm.silktouchIce;
     
    import org.bukkit.Material;
    import org.bukkit.World;
    import org.bukkit.block.Block;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockBreakEvent;
    import org.bukkit.inventory.ItemStack;
     
     
     
    public class EventListeners
        implements Listener
    {
     
        public EventListeners(Main plugin)
        {
            this.plugin = plugin;
        }
        
        public void onBlockBreak(BlockBreakEvent event)
       {
       if(event.isCancelled()) return;
       
       Block block = event.getBlock();
            World world = block.getWorld();
            boolean silkTouch = false;
            if(event.getPlayer().getItemInHand().getEnchantments().containsKey(Enchantment.SILK_TOUCH))
           silkTouch = true;
            if(block.getType() == Material.ICE && silkTouch)
            {
           ItemStack drop = new ItemStack(Material.ICE, 1);
           world.dropItemNaturally(block.getLocation(), drop);
                };
            }
        
    Main plugin;
    }
     
  2. Offline

    Acrobot

    No @EventHandler?
     
  3. Offline

    mickverm

    OMG, thank you
    forgetting one simple thing can break your plugin =S
    well, my plugin is finished now, i'm going to put it on bukkitdev later
     
  4. Offline

    Acrobot

    mickverm
    No problem :p

    I know that feeling, sometimes you need a second pair of eyes to look at the code :)
     
Thread Status:
Not open for further replies.

Share This Page