Event for Player Entering Water?

Discussion in 'Plugin Development' started by NGBDevon, Jun 27, 2011.

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

    NGBDevon

    I'm following up with a request that disables swimming for people as my first plugin and need to know if there is an event for players entering water. If there isn't what would you suggest for a work around? Thanks a lot.
     
  2. Offline

    Jayjay110

    Location loc = player.getLocation();
    if (player.getWorld().getBlockAt(loc).getType() == Material.WATER || player.getWorld().getBlockAt( loc.getX(), loc.getY() - 1, loc.getZ()).getType() == Material.WATER)
    {
    //player is currently in water (I think?)
    }
     
  3. Offline

    nickguletskii

    Location has a getBlock() method you know...

    @NGBDevon You need to set up a move event and check if the target location has a water block in it.
     
  4. Offline

    WinSock

    You need to check for stationary water also
    Code:
    Location loc = player.getLocation();
    if (loc.getBlock().getType() == Material.WATER || loc.getBlock().getType() == Material.STATIONARY_WATER)
    {
        // Player is in water
    }
    
     
Thread Status:
Not open for further replies.

Share This Page