Help with getting block placed

Discussion in 'Plugin Development' started by TheDirtyDan, Nov 10, 2012.

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

    TheDirtyDan

    I want to register whenever a chest gets placed, but this isn't working
    Code:
    public void onChestPlace(BlockPlaceEvent event){
            Block b = event.getBlock();
            if(b.getState() instanceof Chest){
                Main.chests.add(b);
                event.getPlayer().sendMessage("You have successfully placed one " + b);
            }
        }
    Any help?
     
  2. Offline

    david_rosales

    Try getBlockPlaced() insteead of getBlock()
     
  3. Offline

    thehutch

    Also you should cast "b" to a chest then put that in the list you have.
    Also when you print the message it's going to write out a string representation of the Block object which you don't want.
     
  4. Offline

    cman1885

    Register the event and use the eventhandler annotation.
     
Thread Status:
Not open for further replies.

Share This Page