Little Trouble

Discussion in 'Plugin Development' started by Insain, Jan 15, 2011.

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

    Insain

    Well i am messing around with a plugin i am making. It compiles great loads in to Craft-Bukkit great but its not doing what its supposed to basically i am trying to get it to Delete TNT if a place hits it

    Code:
    package com.bukkit.insain.BoomBeGone;
    
    import org.bukkit.Material;
    import org.bukkit.event.block.BlockDamageEvent;
    import org.bukkit.event.block.BlockListener;
    import org.bukkit.block.BlockDamageLevel;
    
    public class BoomBeGoneBlockListener extends BlockListener
    {
      private final BoomBeGone plugin;
    
      public BoomBeGoneBlockListener(BoomBeGone plugin)
      {
        this.plugin = plugin;
      }
    
      public void onBlockDamaged(BlockDamageEvent event) {
            if ((event.getDamageLevel() == BlockDamageLevel.BROKEN) && event.getBlock().getType() .equals(Material.TNT)) {
                event.getBlock().setType(Material.AIR);
    
            }
      }
            }
    now as we see here there's no errors Logically but obviously there is a bug some where and i can't seem to snuff it out any help would be great
     
  2. Offline

    DjDCH

    What it's happening when you click the TNT ?
     
  3. Offline

    Insain

    the tnt just dose its Normal Flashing and Explodes instead of just Getting turned in to nothingness
     
  4. Offline

    DjDCH

    Hum ... as you say, you're code seems to be good. Try with an other type of block and replace the Material.AIR with an other material to really see an effect.
     
  5. Offline

    Insain

    Nope still didnt work i know theres a bug in the code format some where just can find it


    Edit Here is the Main file of the Script maybe something here?


    --- merged: Jan 16, 2011 8:28 AM ---
    Oh Man i Feel Stupid Looking at it right now i know exactly what i did wrong i forgot to add a Cancel :\ silly Insain
     
  6. Offline

    DjDCH

    I was going to say the same thing after seeing the source code of this plugin. So, it's working now ? And, what does the setCancelled statement means ?
     
  7. Offline

    Insain

    Basically SetCancelled will Cancel the Destroying of the block and cause it to turn in to the correct one now

    now that i got this working i can hop on to Creepers yay
     
Thread Status:
Not open for further replies.

Share This Page