Player On Water Event

Discussion in 'Plugin Development' started by G_CODE649B, Dec 18, 2012.

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

    G_CODE649B

    Hello, I need help with this. Does anyone know code/event to make certain thing happened when a player go into water? Like I want to gives potion effects to a player that's in water. I'm kinda new to this whole plugin and coding stuffs.

    Please help. Thanks. :)
     
  2. Offline

    gomeow

    PlayerMoveEvent
    if(player.getLocation().getBlock().isLiquid())
     
  3. Offline

    G_CODE649B

    Thanks a lot! It works! :) But do you know how to give them the potion effects while they're not moving?
     
  4. Offline

    suckycomedian

    I'm just guessing with this. haven't tried it.
    Code:
    //create an ArrayList and add players to it who step on water. I'll call the string waterPlayers
    if(player.getLocation().getBlock().isLiquid()){
    if(!plugin.waterPlayers.contains(event.getPlayer().getName()){
    plugin.waterPlayers.add(event.getPlayer().getName());
    event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.<potion effect>, <enter in a long duration>, <potion level>));
    }
    }
     
    if(!player.getLocation().getBlock().isLiquid()){
    if(plugin.waterPlayers.contains(event.getPlayer().getName()){
    plugin.waterPlayers.remove(event.getPlayer().getName());
    event.getPlayer().removePotionEffect(PotionEffectType.<same potion effect>));
    }
    }
    
    The first part just set a ridiculous time for and the second part should get rid of the potion effect when they leave the water. They'll have to move to trigger the event if you're using PlayerMoveEvent
     
Thread Status:
Not open for further replies.

Share This Page