Water on blocks

Discussion in 'Spigot Plugin Development' started by Limesix, Jun 4, 2017.

  1. Hello guys, i'm not exactly sure how to explain this, so i made a video, that probably explains it a bit better:

    So basically, how do i prevent, people being able to destroy grass, flowers etc. with a waterbucket? (If you don't know what i mean, check the video^^)

    Thanks in advance,
    - Limesix.
     
  2. Try this.
    Code (Text):

        @EventHandler
        public void onFromTo(BlockFromToEvent e){
            if(e.getToBlock().getType() != Material.AIR){
                e.setCancelled(true);
            }
        }
    //EDIT: You should also check if the block is water and not lava (or something else)
     
  3. Hmm, never thought of this, I'm assuming when this happens it would be under blockbreakevent but I'm not sure how to check if it's water or lava.
     
  4. Code (Text):
     if(e.getBlock().getType() == Material.WATER){ ... }
     
  5. That wouldn't work when it comes to blockbreakevent, that would just mean that if the block broken is water.
     
  6. Don't use the BlockBreakEvent, use the BlockFromToEvent
     
    • Agree Agree x 1
    • Agree Agree x 2
  7. So i would do on the PlayerBucketEmptyEvent,

    if(e.getBlock().getType() == Material.TALLGRASS){ ... }
    e.setcancelled(true);