Solved WorldGuard API - PvP Flags

Discussion in 'Plugin Help/Development/Requests' started by 2008Choco, Jul 30, 2015.

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

    2008Choco

    I'm attempting to cancel my event if the WorldGuard region that the player is currently in has PvP flagged as denied. There's one issue with that, and it's that I have NO IDEA how to check a region flag that the player is currently in. I've never used the WorldGuard API, and the official documentation didn't help. I've googled it as well. Found a post, however it was very outdated and the post didn't help in the slightest.

    The assistance I need is, how do I use the WorldGuard API to check what region the player is in, and check if the PvP flag is denied.
     
  2. Offline

    zr120cat

    I know how! Go into that region and do /region info
    It should say what the region is called and flags inside of it
     
  3. Offline

    2008Choco

    I... I mean with code... >.>

    I know how to do it inside of Minecraft. The tag for this post is "Development Assistance" meaning I need a bit of help developing CODE for this feature. I need to retrieve the PvP region flag state through Java code for a plugin I am currently working on. "/region info" is a command in-game that provides no information for developers
     
  4. Offline

    2008Choco

    Bump :p As soon as possible would be great <3

    I've solved the issue on my own after hours of messing with the API on my own. Here's the solution that I made for those that ever have issues with this in the future

    Code:
    ApplicableRegionSet set = WGBukkit.getPlugin().getRegionManager(player.getWorld()).getApplicableRegions(player.getLocation());
    if (set.queryState(null, DefaultFlag.PVP) == StateFlag.State.DENY){
        //DO WHATEVER YOU WANT HERE IF PVP IS OFF 
    }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
Thread Status:
Not open for further replies.

Share This Page