WorldGuard API, Checking which region a player is in.

Discussion in 'Plugin Development' started by LulzCop, Oct 16, 2012.

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

    LulzCop

    Sorry if this is a noob question, but I am new to the WorldGuard API, and want to know if anyone can help me check which region a player is in.
     
  2. Offline

    javoris767

    Could I have the link, I would like to look at the API as I could not find it lol
     
  3. Offline

    Tzeentchful

    Fist off i would get the location of the player.
    Then get the region manager for the world the player is in and get all the regions at the player location.
    PHP:
    Location loc player.getLocation(); 
    Iterator<ProtectedRegionregions getWorldGuard().getRegionManager(loc.getWorld()).getApplicableRegions(loc).iterator();
    while(
    regions.hasNext()){
        
    //bla bla bla
    }
     
  4. Offline

    chaseoes

  5. Tzeentchful I have this code in my plugin like this:
    Code:java
    1. @EventHandler
    2. public void onPlayerMove(PlayerMoveEvent e) {
    3. if(tag.contains(e.getPlayer())) {
    4. Location loc = e.getTo();
    5. Iterator<ProtectedRegion> regions = getWorldGuard().getRegionManager(loc.getWorld()).getApplicableRegions(loc).iterator();
    6. while(regions.hasNext()){
    7. //CHECK IF THE PLAYER IS IN THE REGION CALLED "Safezone"
    8. e.setCancelled(true);
    9. }
    10. }
    11. }

    But at first, i get a red line under
    Code:java
    1. getWorldGuard().getRegionManager(loc.getWorld()).getApplicableRegions(loc)

    and then my other problem is.. how to do the thing in the comment?
    (Check if the player is in the region called "Safezone") ?

    I tagged Tzeentchful because he seems to have knowledge with this because he answered the question this thread is about.

    Kind Regards,
    Bas
     
Thread Status:
Not open for further replies.

Share This Page