BlockPlace

Discussion in 'Plugin Development' started by TheDirtyDan, Dec 10, 2011.

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

    TheDirtyDan

    Here's the code:

    Code:
    public void onBlockPlace(BlockPlaceEvent event){
            Block p = event.getBlockPlaced() ;
            ChatColor GREEN = ChatColor.GREEN;
            ChatColor BLUE = ChatColor.BLUE;
    
        }
    I want to be able to put if a certain block is placed, then blah blah blah.
    So for instance:
    Code:
    public void onBlockPlace(BlockPlaceEvent event){
            Block p = event.getBlockPlaced() ;
            ChatColor GREEN = ChatColor.GREEN;
            ChatColor BLUE = ChatColor.BLUE;
         if(this block is placed){
    }   
        }
    How would that be done?

    Also, once I have getBlockPlaced, how would I take that so that everytime someone places a block, it gets logged?

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

    DomovoiButler

    just use if(event.getBlock()==Block.<block>){
    //do something here, i think
    }
     
  3. Offline

    Slamakans

    Code:java
    1. public void onBlockPlace(BlockPlaceEvent event){
    2.  
    3. Block p = event.getBlockPlaced();[/INDENT]
    4.  
    5. ChatColor GREEN = ChatColor.GREEN;[/INDENT]
    6.  
    7. ChatColor BLUE = ChatColor.BLUE;[/INDENT]
    8.  
    9. if(p.getType == Material.(Whatever block you want)){
    10.  
    11. (How you want it to get logged)[/INDENT]
    12.  
    13. }
    14.  
    15. }
     
  4. Offline

    tips48

    And make sure you register the event in onEnable with getPluginManager().registerEvent(Type.BLOCK_PLACE, new MyBlockListenerHere(), Priority.Normal, this);
     
Thread Status:
Not open for further replies.

Share This Page