Solved Fire PlayerMoveEvent only when X, Y or Z changes. - Not Yaw / Pitch

Discussion in 'Plugin Development' started by baenii, Oct 31, 2019.

  1. Offline

    baenii

    Hej everyone, it's me again.

    Im currently working on a spawn command, which teleports u to spawn after 3 seconds !if you do not move while those 3 seconds!.
    But changing yaw and pitch should be allowed. So Im using the PlayerMoveEvent and check if the getFrom and getTo locations are equal, expect for the yaw and pitch. - So im only checking X, Y and Z. But strangely it stops also, when I'm turning around (changing yaw and pitch). Any ideas?

    My code:
    Code:
    Player p = e.getPlayer();
            double oldLocX = e.getFrom().getX();
            double oldLocY = e.getFrom().getY();
            double oldLocZ = e.getFrom().getZ();
         
            double newLocX = e.getTo().getX();
            double newLocY = e.getTo().getY();
            double newLocZ = e.getTo().getZ();
         
            if(oldLocX != newLocX || oldLocY != newLocY || oldLocZ != newLocZ) {
         
                if(Spawn.teleporting.contains(p)) {
                 
                    p.sendMessage(Main.prefix + "Der Teleportvorgang wurde unterbrochen.");
                 
                    Spawn.teleporting.remove(p);
                 
                }
             
            }
    
    //EDIT
    I solved my problem by myself.. I just had to do getBlockX instead of getX() and so on.
     
    Last edited: Oct 31, 2019

Share This Page