Delaying a explosion

Discussion in 'Plugin Development' started by Th3Controller, Jul 9, 2012.

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

    Th3Controller

    Hello once again Bukkit community :p,

    So today I've been thinking really hard on how this plugin will handle TNT explosions. I recently came up with a really good solution but now I need help from you guys. I need to place a delay timer on when the "TNT explosion" will occur AND when it will remove the block acting as a placeholder for the "TNT entity".

    So here's the code, fairly well written I should say :p
    Code:
        @EventHandler
        public void PlayerTouchTnt(PlayerInteractEvent event){
            Block cblock = event.getClickedBlock();
            ItemStack stack = event.getItem();
            if(event.getAction() == Action.RIGHT_CLICK_BLOCK && cblock != null){
                if(cblock.getTypeId() == 46){
                    if(stack.getTypeId() == 259){
                        float explosionPower = 4F;
                        event.setCancelled(true);
                        cblock.setTypeId(49);
                        cblock.getWorld().createExplosion(cblock.getLocation(), explosionPower);
                    }
                }
            }
        }
    If you helped solved my problem in a understandable way, by that meaning you tell me where to put the code you told me, I will happily put you in the BukkitDev page as a contributor.
     
  2. long delay; // delay in ticks
    Plugin plugin; //plugin running this
    bukkit.getSchedular().scheduleSyncDelayedTask(plugin,new Runnable(){
    // explotion code here
    }, delay)
     
  3. Offline

    Th3Controller

    Lol I was about to edit my post, but my friend solved it for me. Thanks anyways and its similar to yours so your going as a contributor also! :D
     
Thread Status:
Not open for further replies.

Share This Page