event.getDamageLevel().getLevel() == 3)

Discussion in 'Plugin Development' started by iPhysX, Mar 24, 2011.

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

    iPhysX

    Ok. When i use this..


    if


    (block.getType().equals(Material.DIRT)
    && event.getDamageLevel().getLevel()==3) {
    player.sendMessage(ChatColor.
    GOLD + "Blahblahblah");

    That should send a message to the player when they destroy dirt correct?

    Please guys :O its the last thing i need to do to complete my plugin :D
    Thanks

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 13, 2016
  2. Offline

    Danza

    when player damage block.
    that will send message every time as player hit block of dirt.
     
  3. Offline

    iPhysX

    Thank, but it doesnt send any messages, when hit or destroyed. Im trying to get it to send a message when the block is destroyed :/
     
  4. Offline

    Raphfrk

    I think that event is a little weird, different versions of Bukkit react differently.
     
  5. Offline

    iPhysX

    When i do it without
    .getLevel()==3) {
    }

    It works, but every time the block is hit a message comes up. I only want a message when the block dies :D

    Ah! found out what it is!
    instead of onBlockDamageEvent();

    i need to use onBlockBreakEvent();

    Can anybody help me use onBlockBreak? In the same code i used before?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 13, 2016
  6. Offline

    Danza

    Code:
    @Override
    public void onBlockBreak(BlockBreakEvent event) {
    Player p = event.getPlayer();
            Block b = event.getBlock();
            if(b.getType().equals(Material.DIRT) && p!=null){
                p.sendMessage(ChatColor.GOLD + "Blahblahblah");
            }
    }
    ps: i dont think what p!=null is necessary cuz in BlockBreakEvent i dont found any Entity. only player. Anyway its must work.
     
  7. Offline

    iPhysX

    Thanks ill give it a go!

    Works like a charm :D
    Thanks!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 13, 2016
Thread Status:
Not open for further replies.

Share This Page