SPIGOT-7746: Server Crashing when Players Getting into End Portals

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2024-06-14 19:03:14 +10:00
parent 8a61d81e90
commit df2a17df77

View file

@ -27,7 +27,7 @@
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable();
for (int i = -2; i <= 2; ++i) {
@@ -29,16 +42,27 @@
@@ -29,16 +42,33 @@
BlockPosition.MutableBlockPosition blockposition_mutableblockposition1 = blockposition_mutableblockposition.set(blockposition).move(j, k, i);
Block block = k == -1 ? Blocks.OBSIDIAN : Blocks.AIR;
@ -47,8 +47,14 @@
}
}
+ // CraftBukkit start
+ if (entity == null) {
+ // SPIGOT-7746: Entity will only be null during world generation, which is async, so just generate without event
+ blockList.updateList();
+ return;
+ }
+
+ org.bukkit.World bworld = worldaccess.getLevel().getWorld();
+ PortalCreateEvent portalEvent = new PortalCreateEvent((List<BlockState>) (List) blockList.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM);
+ PortalCreateEvent portalEvent = new PortalCreateEvent((List<BlockState>) (List) blockList.getList(), bworld, entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM);
+
+ worldaccess.getLevel().getCraftServer().getPluginManager().callEvent(portalEvent);
+ if (!portalEvent.isCancelled()) {