Create a config option to enable portal protection.

Protection is off by default. Third-party portal plugins such as MV-NP
may interfere with portal protection and cause problems.
Fixes WORLDGUARD-3498.
This commit is contained in:
wizjany 2015-06-19 17:01:30 -04:00
parent 2d28e8db6d
commit 5ff8b37ae8
2 changed files with 5 additions and 2 deletions

View File

@ -174,6 +174,7 @@ public class WorldConfiguration {
public boolean disableSoilDehydration;
public Set<Integer> allowedSnowFallOver;
public boolean regionInvinciblityRemovesMobs;
public boolean regionNetherPortalProtection;
public boolean fakePlayerBuildOverride;
public boolean explosionFlagCancellation;
public boolean disableDeathMessages;
@ -453,6 +454,7 @@ private void loadConfiguration() {
useRegions = getBoolean("regions.enable", true);
regionInvinciblityRemovesMobs = getBoolean("regions.invincibility-removes-mobs", false);
regionNetherPortalProtection = getBoolean("region.nether-portal-protection", false);
fakePlayerBuildOverride = getBoolean("regions.fake-player-build-override", true);
explosionFlagCancellation = getBoolean("regions.explosion-flags-block-entity-damage", true);
highFreqFlags = getBoolean("regions.high-frequency-flags", false);

View File

@ -372,6 +372,9 @@ public void onPlayerTeleport(PlayerTeleportEvent event) {
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerPortal(PlayerPortalEvent event) {
ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(event.getTo().getWorld());
if (!wcfg.regionNetherPortalProtection) return;
if (event.getCause() != TeleportCause.NETHER_PORTAL) {
return;
}
@ -398,8 +401,6 @@ public void onPlayerPortal(PlayerPortalEvent event) {
World world = event.getTo().getWorld();
ProtectedRegion check = new ProtectedCuboidRegion("__portalcheck__", BukkitUtil.toVector(min.getBlock()), BukkitUtil.toVector(max.getBlock()));
ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(world);
if (wcfg.useRegions && !plugin.getGlobalRegionManager().hasBypass(event.getPlayer(), world)) {
ApplicableRegionSet set = plugin.getRegionContainer().get(event.getTo().getWorld()).getApplicableRegions(check);