Skip to content
Permalink
Browse files

Portal bypass.

  • Loading branch information...
wizjany committed Jun 2, 2019
1 parent 14315bd commit 366e658935153ea6377fec2e71d3b708e96467c5
@@ -673,18 +673,22 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onCreatePortal(PortalCreateEvent event) {
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(event.getWorld()));
final com.sk89q.worldedit.world.World world = BukkitAdapter.adapt(event.getWorld());
WorldConfiguration wcfg = cfg.get(world);

if (wcfg.regionNetherPortalProtection
&& event.getReason() == PortalCreateEvent.CreateReason.NETHER_PAIR
&& !event.getBlocks().isEmpty()) {
final RegionManager regionManager = WorldGuard.getInstance().getPlatform().getRegionContainer()
.get(BukkitAdapter.adapt(event.getWorld()));
.get(world);
if (regionManager == null) return;
LocalPlayer associable = null;
if (event.getEntity() instanceof Player) {
associable = plugin.wrapPlayer(((Player) event.getEntity()));
}
if (WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(associable, world)) {
return;
}
BlockVector3 min = null;
BlockVector3 max = null;
for (BlockState block : event.getBlocks()) {
@@ -696,6 +700,8 @@ public void onCreatePortal(PortalCreateEvent event) {
final ApplicableRegionSet regions = regionManager.getApplicableRegions(target);
if (!regions.testState(associable, Flags.BUILD, Flags.BLOCK_PLACE)) {
if (associable != null) {
// NB there is no way to cancel the teleport without PTA (since PlayerPortal doesn't have block info)
// removing PTA was a mistake
associable.print("Destination is an a protected area.");
}
event.setCancelled(true);

0 comments on commit 366e658

Please sign in to comment.
You can’t perform that action at this time.