Instant death in water?

Discussion in 'Plugin Development' started by Faith, Jun 27, 2013.

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

    Faith

    How would I make a player die when they touch water?
     
  2. Offline

    boboman13

    1) Listen for a PlayerMoveEvent
    2) Check if the block at their feet is water
    3) If it is, kill them :)
     
    Minnymin3 likes this.
  3. Offline

    YuzkoCode

    Code:java
    1. @EventHandler
    2. public void onPlayerMove(PlayerMoveEvent e) {
    3. Player p = e.getPlayer();
    4.  
    5. if (p.getLocation().getBlock().getType() == Material.WATER
    6. || (p.getLocation().getBlock().getType() == Material.STATIONARY_WATER)) {
    7. p.setHealth(0);
    8. }
    9. }

    I believe this should work, going to test it now.

    EDIT: It works, but it spams (player has died) like 7 times for some reaosn.
     
Thread Status:
Not open for further replies.

Share This Page