Help Checking if a Player is in a WG Region

Discussion in 'Plugin Development' started by SuperOriginal, Mar 13, 2014.

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

    SuperOriginal

    So i'm trying to check if a player is in a region called donatorshop here's my code:
    Code:java
    1. public boolean test1(Player p, World w) {
    2. WorldGuardPlugin wg = new WorldGuardPlugin();
    3. RegionManager regionm = wg.getRegionManager(p.getWorld());
    4. ApplicableRegionSet set = regionm.getApplicableRegions(p.getLocation());
    5. for(ProtectedRegion pr : set) {
    6. if (pr.getId().equalsIgnoreCase("donatorshop")) {
    7. return true;
    8. }
    9. }
    10. return false;
    11. }
    12.  
    13.  
    14. @EventHandler
    15. public void onInteract(SignInteractEvent e){
    16.  
    17. if(e.getEssentialsSign().getClass().equals(SignBuy.class) || e.getEssentialsSign().getClass().equals(SignSell.class)){
    18. if(!e.getUser().getBase().hasPermission("donate.donate")){
    19. if(test1(e.getUser().getBase(), e.getUser().getBase().getWorld()) == true){
    20. e.setCancelled(true);
    21. e.getUser().sendMessage(ChatColor.RED + "You do not have access to that sign!");
    22. }
    23.  
    24.  
    25. }
    26.  
    27.  
    28. }


    For some reason it isn't working, no errors thrown. Any ideas?

    bump

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

Share This Page