[Resolved] WorldGuard get region name

Discussion in 'Plugin Development' started by Sorroko, Feb 18, 2012.

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

    Sorroko

    So my issue is I want to stop the player from leaving a worldguard area, so on every move event I check to see all the regions the player is in, then I get the list of regions, I want to get the name of all the regions and compare to a list of regions in a config file. But I cant seem to find where to get the region names. here is my code:

    Code:java
    1.  
    2. @EventHandler
    3. public void PlayerMove(PlayerMoveEvent event){
    4. Player p = event.getPlayer();
    5. if(!(p.isOp())){
    6. Vector to = toVector(event.getTo());
    7. RegionManager regionManager = worldGuard.getRegionManager(p.getWorld());
    8. ApplicableRegionSet set = regionManager.getApplicableRegions(to);
    9. }
    10. }
    11.  


    Is there a way to get the names? And is there a less cpu intensive way of stopping a player leaving a zone? Thanks in advance!

    Ah, never mind I answered my own question eventually...
    Code:java
    1.  
    2. Set<String> result = new HashSet<String>();
    3. for (ProtectedRegion pr : ars) {
    4. // Ignore global region
    5. if (!"__global__".equals(pr.getId())) // NB: Hardcoded and not available as constant in WorldGuard
    6. result.add(pr.getId().toLowerCase());
    7. }
    8.  
    9. Set<String> regions = getRegions(event.getPlayer().getLocation());
    10.  


    That is not the full code and may not work on its own like that but you get the idea.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 24, 2016
Thread Status:
Not open for further replies.

Share This Page