Set WorldGuard flag

Discussion in 'Plugin Development' started by MrCreeper, Aug 13, 2011.

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


    Hey :)
    How can I use ProtectedRegion.setFlag() to set PVP to true?
    My region:
    ProtectedRegion region = worldguard.getRegionManager(user.getWorld()).getRegion("test")
    The documentation:
    public <T extends Flag<V>,V> void setFlag(T flag,
                                              V val)
        Set a flag's value.
        Type Parameters:
            T -
            V -
            flag -
            val -
    Does no one know how to use this method? =/

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 18, 2016
  2. Offline


    Want to kniow this too :(
  3. Offline


    Me either. I have problems with creating a flag variable. If I use e.g. DefaultFlag.PVP, there is an NullPointerException.
  4. Offline


    I wrote a request to sk89q for tutorial to SetFlag. He said, that he will do it and update the wiki tutorials in the next few days. :)
  5. Offline


    Its not a tutorial that's needed its new function that will simply use region.setflag(string,string) where arg0 = flag arg1= Value(Deny/Allow)

    If you look at how its done using the /region flag regionname pvp allow in the worldguard sourcecode
    its a bit complicated you basically have the parse the entire "array" of flags set for that region. Find where pvp is and rewrite the value for it.

    ^Is a horrible explanation for how it actually works,however its a glimpse of how it works. I was developing a plugin and I did the research and just decided to abandon the plugin due to how frustrating this flag setting is in world guard base on source code i viewed.

    So I will be waiting until a function is made to simplify this process of setting world guard flags.
  6. Offline


    Any one figured this out on how to use the setFlag ?
  7. Offline


  8. Offline


    flags.put(new StateFlag("use", false), State.DENY);
    flags.put(new StateFlag("ice-melt", true), State.ALLOW);
    xMrPoi likes this.
  9. Offline


    sk89q is one of the smartest people on bukkit. It is probably really hard to write the code that he does, so to figure this out you'll probably need him.
  10. Offline


    sk89q I am trying to figure this out because I need it for a minigame.
  11. Offline


    Sorry but I have not been able to set a single flag to a region. I searched and searched, over and over again, I read the API doc with no lucky.
    This is my code:
    1. StateFlag pvp;
    2. pvp = new StateFlag("pvp", false);
    3. pr.setFlag(pvp, StateFlag.State.DENY);
    4. pr.setPriority(priority);

    My region is correctly defined, the calculated priority is appropriately set but it have no flags.
    Thanks in advance for your help.
  12. Offline


    Try this:

    1. getWorldGuard().getRegionManager ( player.getWorld() ).getRegion("regionName").setFlag ( DefaultFlag.PVP, State.ALLOW );

    You will need this method to get WorldGuard Plugin Object:

    1. private WorldGuardPlugin getWorldGuard() {
    2. Plugin plugin = getServer().getPluginManager().getPlugin("WorldGuard");
    4. // WorldGuard may not be loaded
    5. if (plugin == null || !(plugin instanceof WorldGuardPlugin)) {
    6. log.severe ("*** ERROR Trying to attach GroupManager to GameOfThrones Plugin!");
    7. return null;
    8. }
    9. return (WorldGuardPlugin) plugin;
    10. }

    Don't forget to change the "regionName" string to your real region name. :) :) :)
Thread Status:
Not open for further replies.

Share This Page