BlockBreakEvent

Discussion in 'Plugin Development' started by MyNameIsHariK, Dec 1, 2013.

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

    MyNameIsHariK

    Hey!

    I am creating a minigame which I need to allow players to break crops(wheat). So what would the code be to check if its a wheat(crop) block?

    Code:java
    1. @EventHandler
    2. public void onBreak(BlockBreakEvent e) {
    3. if//code {
    4. e.setCancelled(false);
    5. }
    6. else {
    7. e.setCancelled(true);
    8. }
    9. }


    thanks for your time,
    Hari
     
  2. Offline

    Elsifo92

    Code:java
    1. @EventHandler
    2. public void onBreak(BlockBreakEvent e) {
    3. if(e.getBlock().getType().equals(Material.CROPS)) {
    4. e.setCancelled(false);
    5. }
    6. else {
    7. e.setCancelled(true);
    8. }
    9. }
     
Thread Status:
Not open for further replies.

Share This Page