Discover areas

Discussion in 'Spigot Plugin Development' started by Christophe6, May 26, 2017.

  1. Hi

    How can I add worldguard regions to an arraylist when you reach them?
    The only way I can think of is using the PlayerMoveEvent but won't that cause a lot of lag?
    If there are 50 players moving it needs to check every player has already discovered the region and if not add it to the arraylist. Is there an easier way?

    Thank you!
  2. ScarabCoder

    ScarabCoder Retired Resource Staff

    PlayerMoveEvent is a bit tricky to use. However, my preferred method is not to check if the player is in an area, but rather check if the from location is outside the area and the to location is inside the area, then add it to a list. For exiting the area, vice versa.
  3. You don't need the move event, there's already a "RegionEnterEvent" / "RegionLeaveEvent"
  4. ScarabCoder

    ScarabCoder Retired Resource Staff

    Oh, that's convenient then.

    In which case, simply store a HashMap of Region, Player and add/remove from it with those events.