diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/implementation/RegionSettings.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/implementation/RegionSettings.java index d5551cb..84c05b5 100644 --- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/implementation/RegionSettings.java +++ b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/implementation/RegionSettings.java @@ -7,8 +7,8 @@ import java.util.List; public class RegionSettings extends OkaeriConfig { @Comment({ - "# List of regions where combat is restricted.", - "# Players in these regions will not be able to engage in combat." + "# Regions that combat-tagged players may not enter, even where the pvp flag allows PvP.", + "# A higher-priority region that explicitly allows PvP still wins over a listed region." }) public List blockedRegions = Collections.singletonList("your_region"); diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/region/worldguard/WorldGuardRegionProvider.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/region/worldguard/WorldGuardRegionProvider.java index 26c2e31..27fd121 100644 --- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/region/worldguard/WorldGuardRegionProvider.java +++ b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/region/worldguard/WorldGuardRegionProvider.java @@ -86,19 +86,27 @@ public class WorldGuardRegionProvider implements RegionProvider { return true; } - // A region in the blockedRegions list applies here, but never treat a spot as restricted when - // a higher-priority region explicitly allows PvP. Otherwise a large umbrella region (e.g. a - // world-spanning "spawn" listed in blockedRegions) would also block the warzone/arenas nested - // inside it. - if (pvpState != StateFlag.State.ALLOW) { - for (ProtectedRegion region : applicableRegions.getRegions()) { - if (this.regions.contains(region.getId())) { - return true; - } + // A listed region restricts this spot unless a higher-priority region explicitly allows + // PvP. A listed umbrella region (a world-spanning "spawn") therefore never blocks the + // warzone nested inside it, while a listed arena outranks the warzone it sits in. + int listedPriority = Integer.MIN_VALUE; + for (ProtectedRegion region : applicableRegions.getRegions()) { + if (this.regions.contains(region.getId())) { + listedPriority = Math.max(listedPriority, region.getPriority()); } } - return false; + if (listedPriority == Integer.MIN_VALUE) { + return false; + } + + for (ProtectedRegion region : applicableRegions.getRegions()) { + if (region.getPriority() > listedPriority && region.getFlag(Flags.PVP) == StateFlag.State.ALLOW) { + return false; + } + } + + return true; } // Per-region check used only for border rendering, where there is no single query point. diff --git a/eternalcombat-plugin/src/resources/config.yml b/eternalcombat-plugin/src/resources/config.yml index fbb377d..699c3ee 100644 --- a/eternalcombat-plugin/src/resources/config.yml +++ b/eternalcombat-plugin/src/resources/config.yml @@ -246,23 +246,23 @@ admin: # Settings related to regions. # Configure region-specific settings and behaviors for combat. regions: - # List of regions where combat is restricted. - # Players in these regions will not be able to engage in combat. + # Regions that combat-tagged players may not enter, even where the pvp flag allows PvP. + # A higher-priority region that explicitly allows PvP still wins over a listed region. blockedRegions: - spawn - market - - colosseum - - atlantis - - olympus - - ender - - cave - - blizzard - - fungi - - hell - - castle - - frozone - - sewer - - chasm + - arena-colosseum + - arena-atlantis + - arena-olympus + - arena-ender + - arena-cave + - arena-blizzard + - arena-fungi + - arena-hell + - arena-castle + - arena-frozone + - arena-sewer + - arena-chasm # Prevent players from entering regions where PVP is disabled by WorldGuard. # Set to 'true' to enforce this restriction, or 'false' to allow PVP in all regions. preventPvpInRegions: true