[WorldEdit API]Check if a player leave a region

Discussion in 'Plugin Development' started by O_soldier, Dec 21, 2012.

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

    O_soldier

    Hey,
    I got a problem, I don't know how to check if a player leave a defined region, this is the name of my method to check if he IS on a region:
    Code:
    if(isLocInRegion(p.getLocation(), "tour1")){
    I tried to check:
    Code:
    if(!isLocInRegion(p.getLocation(), "tour1")){
    Here are the method used:
    Code:
          public static boolean isLocInRegion(Location loc, String regionName) {
                if (regionName == null) {
                    return true;
                }
                ApplicableRegionSet set = getWGSet(loc);
                if (set == null) {
                    return false;
                }
                for (ProtectedRegion r : set) {
                    if (r.getId().equalsIgnoreCase(regionName)) {
                        return true;
                    }
                }
                return false;
            }
       
            private static ApplicableRegionSet getWGSet(Location loc) {
                WorldGuardPlugin wg = getWorldGuard();
                if (wg == null) {
                    return null;
                }
                RegionManager rm = wg.getRegionManager(loc.getWorld());
                if (rm == null) {
                    return null;
                }
                return rm.getApplicableRegions(com.sk89q.worldguard.bukkit.BukkitUtil.toVector(loc));
            }
        
    But it doesn't work, can someone help me ?

    Thank you

    P.S: sorry if i did any mistake, I'm not english :p
     
  2. Offline

    ZeusAllMighty11

    WorldEdit != WorldGuard


    Maybe that's the problem.
     
Thread Status:
Not open for further replies.

Share This Page