SPIGOT-6157: Crash when PortalCreateEvent cancelled

This commit is contained in:
md_5 2020-09-29 18:10:57 +10:00
parent a339310c48
commit 1ee373fe28
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
2 changed files with 10 additions and 5 deletions

View File

@ -499,7 +499,7 @@
private void a(WorldServer worldserver, BlockPosition blockposition) {
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.i();
@@ -631,14 +886,14 @@
@@ -631,17 +886,17 @@
}
@Override
@ -517,7 +517,11 @@
+ Optional<BlockUtil.Rectangle> optional1 = worldserver.getTravelAgent().createPortal(blockposition, enumdirection_enumaxis, this, createRadius); // CraftBukkit
if (!optional1.isPresent()) {
EntityPlayer.LOGGER.error("Unable to create a portal, likely target out of worldborder");
- EntityPlayer.LOGGER.error("Unable to create a portal, likely target out of worldborder");
+ // EntityPlayer.LOGGER.error("Unable to create a portal, likely target out of worldborder"); // CraftBukkit
}
return optional1;
@@ -685,10 +940,8 @@
this.activeContainer.c();
}

View File

@ -70,7 +70,7 @@
}
}
}
@@ -136,10 +149,19 @@
@@ -136,10 +149,20 @@
for (j1 = 0; j1 < 2; ++j1) {
for (j = 0; j < 3; ++j) {
blockposition_mutableblockposition.a((BaseBlockPosition) blockposition1, j1 * enumdirection.getAdjacentX(), j, j1 * enumdirection.getAdjacentZ());
@ -84,9 +84,10 @@
+ org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent((java.util.List<org.bukkit.block.BlockState>) (java.util.List) blockList.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.NETHER_PAIR);
+
+ this.world.getServer().getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
+ blockList.updateList();
+ if (event.isCancelled()) {
+ return Optional.empty();
+ }
+ blockList.updateList();
+ // CraftBukkit end
return Optional.of(new BlockUtil.Rectangle(blockposition1.immutableCopy(), 2, 3));
}