[Help] Checking if a player climbs a ladder?

Discussion in 'Plugin Development' started by Purple_Penguin, Jun 8, 2013.

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

    Purple_Penguin

    Hi, please excuse my noobiness, I am extremely new to bukkit development. So anyways, I was wondering if it is possible, and if it is, how, to check if a player climbs a ladder.

    Thanks for the help in advance! ^-^
     
  2. Offline

    ZeusAllMighty11

    PlayerMoveEvent, check if their Y value changes and the block at their location is a ladder
     
  3. Offline

    ocomobock

    Maybe something like this:

    Code:java
    1.  
    2. @EventHandler
    3. public void ladder(PlayerMoveEvent e)
    4. {
    5. Player player = e.getPlayer();
    6. if((new Location(p.getWorld(), p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ()).getBlock().getTypeId == 65) && !p.isOnGround())
    7. {
    8. p.sendMessage("You're on a ladder");
    9. }
    10. }
     
  4. Offline

    Purple_Penguin

    @ocomoback Thanks, that works perfectly! ^_^
     
  5. Offline

    jorisk322

    Code:java
    1.  
    2.  
    3. Jumping? Falling?
     
  6. Offline

    ocomobock

    What?
     
  7. Offline

    ZeusAllMighty11

    Jumping or falling should not trigger when on a ladder
     
  8. Offline

    LucasEmanuel

    ocomobock
    no need to create a new location object just to get the block, just call player.getLocation().getBlock().
     
  9. Offline

    jorisk322

    Oh, sorry. Misread your code.
    No, but your way would trigger when a player jumps or falls, etc.
     
  10. Offline

    ocomobock

    I know, I forgot to change that after I edited my code when I noticed I did something wrong.

    I suppose '&& !player.isOnGround()' doesn't need to be there either. As long as their location is the same as a ladder's, they're technically still climbing the ladder. Unless they want you to actually be going upwards or something. Whatever works best.
     
  11. Offline

    ZeusAllMighty11



    No it wouldn't.
     
  12. Offline

    jorisk322

    You're right. I'm really derpy today.
     
Thread Status:
Not open for further replies.

Share This Page