Most Efficient Way To Check When A Player Gets To A Certain Coordinate (Or Close To It)

Discussion in 'Plugin Development' started by quaz3l, Apr 11, 2012.

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

    quaz3l

    I have a radius script that returns a value of true or false when a player is at the location needed, but I just need to have an efficient way to check every player every few seconds.
     
  2. Offline

    BloodShura

    PlayerMoveEvent my dear.
     
  3. Offline

    quaz3l

    I would have liked to avoid this, is there any other way?
     
  4. Offline

    BloodShura

    Only PlayerMoveEvent and scheduler.
     
  5. Offline

    quaz3l

    Alright thanks.
     
  6. I've done this too in my quest plugin. I've created a player move event listener that stores the last location of the player as integers (so only whole numbers are stored.) I then check if the player has moved from one block to another ignoring change in yaw and pitch (looking around also fires a player move event) by checking the current location with the stored one. If those are changed I will continue my code.

    This way the player move event will still be fired every time, but I only check it if the player has moved a block.

    PS: I've read somewhere that someone added something to the event to check if the player has moved from block to block. But I can't see it in the JavaDocs. (So probably isn't implemented yet.)
     
  7. Offline

    Njol

    You can use if (!event.getTo().getBlock().equals(event.getFrom().getBlock())) to check whether the player moved to a different block.
     
Thread Status:
Not open for further replies.

Share This Page