Set WorldGuard flag

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

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

    MrCreeper

    Hey :)
    How can I use ProtectedRegion.setFlag() to set PVP to true?
    My region:
    Code:
    ProtectedRegion region = worldguard.getRegionManager(user.getWorld()).getRegion("test")
    The documentation:
    Code:
    setFlag
    
    public <T extends Flag<V>,V> void setFlag(T flag,
                                              V val)
    
        Set a flag's value.
    
        Type Parameters:
            T -
            V -
        Parameters:
            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

    Timberman

    Want to kniow this too :(
     
  3. Offline

    xa19

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

    xa19

    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

    wow4201

    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

    r0w

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

    BenFR

  8. Offline

    ItsHarry

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

    Jnorr44

    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

    limdingwen

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

    ddonofrio

    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:
    Code:java
    1. StateFlag pvp;
    2. pvp = new StateFlag("pvp", false);
    3. pr.setFlag(pvp, StateFlag.State.DENY);
    4. pr.setPriority(priority);
    5.  

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

    davidtoledo

    Try this:

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

    You will need this method to get WorldGuard Plugin Object:

    Code:java
    1. private WorldGuardPlugin getWorldGuard() {
    2. Plugin plugin = getServer().getPluginManager().getPlugin("WorldGuard");
    3.  
    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