WorldGuard

WorldGuard

8M Downloads

members only specific flags?

amkeyte opened this issue ยท 2 comments

commented

I'm looking at adding a flag that is PVP_UNFAIR which would allow a player who is a member of a region be immune to pvp attacks. Non-member players would still be attack-able. I realize that this is a fluke request and would not expect it to be added as a standard feature.

In member isFlagAllowed it seems that setting a flag to ALLOW or DENY will assume that the flag is meant to be applied to all players. (PVP, TNT, etc..) This makes perfect sense for the existing flags. The players' membership is only taken into account in a region when it's flag is set to NONE.

First question: Is this correct or did I miss something? Am I even making sense? lol

I wish to add this code to the entity listener (or something to this effect) and it would work similar to the build flag:

                //create bukkitplayer for compatability with takesPvpDamage (accepts LocalPlayer, as does isFlagAllowed)
                BukkitPlayer bukkitDefender = new BukkitPlayer(plugin, player);
                if (!plugin.regionManager.getApplicableRegions(pt).takesPvpDamage(bukkitDefender)) {
                    ((Player)attacker).sendMessage(ChatColor.DARK_RED + "That player cannot be attacked here!");
                    event.setCancelled(true);
                    return;
                }

Obviously a member would be added to ApplicableRegionSet to handle the call. The problem here is that it only works correctly with NONE set. Obviously I wouldn't want every region I set up to have default unfair pvp. Setting the flag to ALLOW or DENY effects both the attacker and defender because the ApplicableRegionSet.isFlagAllowed method is set up to check flags with respect to region as opposed to region membership. (by design, I realize)

And so here is question 2: In your opinion what is the best way to check a membership based flag without breaking the code for checking the other flags?

Thanks for this great plugin and thanks for taking the time to look at this.
Aaron

commented

Thanks for the info!
Well I can certainly understand the keep it simple / stupid philosophy! Sometimes it's easy to spend a lot of time on a feature that is rarely used.. lol

I'll look around in the code some more and see what I can come up with.
Thanks again!

commented

Flags don't take ownership or membership into account at all. I am aware of the potential problems of this, although it does make things simple. Sturmeh (who wrote Borderlands) volunteered to add per-flag permissions but he hasn't gotten around to it, and it may result in WorldGuard becoming quite complicated anyway.

If you want to check a membership-based flag, then your best course of action is to make a new method that calls isFlagAllowed but with a LocalPlayer for the player argument. If you pass in a player, it should check membership (that's what the canBuild does). Read the algorithm to make sure that it does what you want though.