Solved Player Move

Discussion in 'Plugin Development' started by jebbo, Nov 28, 2013.

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

    jebbo

    How can i check in the PlayerMoveEvent if the player MOVES, atm its counting mouse movements too, i dont want that.
     
  2. Offline

    Darq

    Code:
    Location old = event.getFrom();
    Location new = event.getTo();
     
    if (old.getX() != new.getX() || old.getY() != new.getY() || old.getZ() != new.getZ()) {
        // the player actually  moved (this will also be true if they jump, as we checked their Y coord as well)
    }
    
     
  3. Offline

    jebbo


    I used it in my spawn delay, but when i move my mouse, its still the same:

    Code:java
    1. @EventHandler
    2. public void onMove(PlayerMoveEvent e){
    3. Player p = e.getPlayer();
    4. Location old = e.getFrom();
    5. Location ne = e.getTo();
    6. if(old.getX() != ne.getX() || old.getY() != ne.getY() || old.getZ() != ne.getZ()) {
    7. if(tplist.contains(p.getName())){
    8. p.sendMessage(prefix+"Teleportation abgebrochen: Du hast dich Bewegt.");
    9. tplist.remove(p.getName());
    10. }
    11. }
    12. }
     
  4. Offline

    Chinwe

    Change .getY(), .getX() etc to .getBlockY(), .getBlockX()
     
  5. Offline

    jebbo


    Solved.

    Thank you both.
     
Thread Status:
Not open for further replies.

Share This Page