Limit player movement

Discussion in 'Spigot Plugin Development' started by Arionas_MC, Apr 28, 2017.

  1. Hello everyone,
    I have two Locations "loc1", "loc2". How can I make it so that the player can only move inside of these two locations? Should I use the "PlayerMoveEvent"?
    [​IMG]
    This is an example.

    Thanks.
     
  2. Yeah, you can check if where the player moves to is within those 2 points. If not, cancel the event.
     
    • Like Like x 1
  3. You could possibly use WorldGuard to create a region and prevent the player from exiting it?
    That would be the easiest and quickest way.
     
  4. if the getTo() location is not within the parameters so i.e) if Y level is above or below, or X/Z or above below max/min values.
     
    • Like Like x 1
  5. If you want to say redistribute the plugin, sell it, call it all your own, etc, that would not be the way to go.
     
  6. Ok thanks for your ideas, and I wouldn't like to use WorldGuard:D.
     
  7. Using it as a dependency is not the same as redistributing it :p
    Your solution is probably better none the less, didn't think it could be done that easily
     
  8. Technically you can, if you implement the API and set the exit flag to deny. This will allow entry but not exit (coming from looking at the docs, haven't tried).
     
  9. When the location 'getTo()' reaches the bounds, should I teleport the player to the 'getFrom()' location?
     
  10. Just cancel the move event.