From 2b5f172cb857499e62fa7c4b6833d23171e93ecf Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 26 Jun 2020 08:30:47 +1000 Subject: [PATCH] SPIGOT-5816: PlayerTeleportEvent not called when using netherportals and allow-nether=false --- nms-patches/Entity.patch | 68 ++++++++++++++++++---------------- nms-patches/EntityPlayer.patch | 58 ++++++++++++++++------------- 2 files changed, 69 insertions(+), 57 deletions(-) diff --git a/nms-patches/Entity.patch b/nms-patches/Entity.patch index 4abdc4eccf..63a51f350d 100644 --- a/nms-patches/Entity.patch +++ b/nms-patches/Entity.patch @@ -1,12 +1,11 @@ --- a/net/minecraft/server/Entity.java +++ b/net/minecraft/server/Entity.java -@@ -21,8 +21,57 @@ +@@ -21,8 +21,56 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start +import org.bukkit.Bukkit; -+import org.bukkit.Location; +import org.bukkit.Server; +import org.bukkit.block.BlockFace; +import org.bukkit.command.CommandSender; @@ -58,7 +57,7 @@ protected static final Logger LOGGER = LogManager.getLogger(); private static final AtomicInteger entityCount = new AtomicInteger(); private static final List c = Collections.emptyList(); -@@ -111,6 +160,20 @@ +@@ -111,6 +159,20 @@ private long aG; private EntitySize size; private float headHeight; @@ -79,7 +78,7 @@ public Entity(EntityTypes entitytypes, World world) { this.id = Entity.entityCount.incrementAndGet(); -@@ -214,6 +277,12 @@ +@@ -214,6 +276,12 @@ } public void setPose(EntityPose entitypose) { @@ -92,7 +91,7 @@ this.datawatcher.set(Entity.POSE, entitypose); } -@@ -230,6 +299,33 @@ +@@ -230,6 +298,33 @@ } protected void setYawPitch(float f, float f1) { @@ -126,7 +125,7 @@ this.yaw = f % 360.0F; this.pitch = f1 % 360.0F; } -@@ -240,6 +336,7 @@ +@@ -240,6 +335,7 @@ float f1 = this.size.height; this.a(new AxisAlignedBB(d0 - (double) f, d1, d2 - (double) f, d0 + (double) f, d1 + (double) f1, d2 + (double) f)); @@ -134,7 +133,7 @@ } protected void ac() { -@@ -254,6 +351,15 @@ +@@ -254,6 +350,15 @@ this.entityBaseTick(); } @@ -150,7 +149,7 @@ public void entityBaseTick() { this.world.getMethodProfiler().enter("entityBaseTick"); if (this.isPassenger() && this.getVehicle().dead) { -@@ -267,7 +373,7 @@ +@@ -267,7 +372,7 @@ this.z = this.A; this.lastPitch = this.pitch; this.lastYaw = this.yaw; @@ -159,7 +158,7 @@ if (this.aK()) { this.aL(); } -@@ -322,12 +428,44 @@ +@@ -322,12 +427,44 @@ protected void burnFromLava() { if (!this.isFireProof()) { @@ -205,7 +204,7 @@ int j = i * 20; if (this instanceof EntityLiving) { -@@ -424,6 +562,28 @@ +@@ -424,6 +561,28 @@ block.a((IBlockAccess) this.world, this); } @@ -234,7 +233,7 @@ if (this.onGround && !this.br()) { block.stepOn(this.world, blockposition, this); } -@@ -698,6 +858,7 @@ +@@ -698,6 +857,7 @@ AxisAlignedBB axisalignedbb = this.getBoundingBox(); this.setPositionRaw((axisalignedbb.minX + axisalignedbb.maxX) / 2.0D, axisalignedbb.minY, (axisalignedbb.minZ + axisalignedbb.maxZ) / 2.0D); @@ -242,7 +241,7 @@ } protected SoundEffect getSoundSwim() { -@@ -1036,6 +1197,13 @@ +@@ -1036,6 +1196,13 @@ } public void spawnIn(World world) { @@ -256,7 +255,7 @@ this.world = world; } -@@ -1051,6 +1219,7 @@ +@@ -1051,6 +1218,7 @@ this.pitch = MathHelper.a(f1, -90.0F, 90.0F) % 360.0F; this.lastYaw = this.yaw; this.lastPitch = this.pitch; @@ -264,7 +263,7 @@ } public void c(Vec3D vec3d) { -@@ -1225,6 +1394,12 @@ +@@ -1225,6 +1393,12 @@ return false; } @@ -277,7 +276,7 @@ public void a(Entity entity, int i, DamageSource damagesource) { if (entity instanceof EntityPlayer) { CriterionTriggers.c.a((EntityPlayer) entity, this, damagesource); -@@ -1235,7 +1410,7 @@ +@@ -1235,7 +1409,7 @@ public boolean a_(NBTTagCompound nbttagcompound) { String s = this.getSaveID(); @@ -286,7 +285,7 @@ nbttagcompound.setString("id", s); this.save(nbttagcompound); return true; -@@ -1259,6 +1434,18 @@ +@@ -1259,6 +1433,18 @@ Vec3D vec3d = this.getMot(); nbttagcompound.set("Motion", this.a(vec3d.x, vec3d.y, vec3d.z)); @@ -305,7 +304,7 @@ nbttagcompound.set("Rotation", this.a(this.yaw, this.pitch)); nbttagcompound.setFloat("FallDistance", this.fallDistance); nbttagcompound.setShort("Fire", (short) this.fireTicks); -@@ -1267,6 +1454,12 @@ +@@ -1267,6 +1453,12 @@ nbttagcompound.setBoolean("Invulnerable", this.invulnerable); nbttagcompound.setInt("PortalCooldown", this.portalCooldown); nbttagcompound.a("UUID", this.getUniqueID()); @@ -318,7 +317,7 @@ IChatBaseComponent ichatbasecomponent = this.getCustomName(); if (ichatbasecomponent != null) { -@@ -1324,6 +1517,11 @@ +@@ -1324,6 +1516,11 @@ } } @@ -330,7 +329,7 @@ return nbttagcompound; } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Saving entity NBT"); -@@ -1401,6 +1599,43 @@ +@@ -1401,6 +1598,43 @@ } else { throw new IllegalStateException("Entity has invalid position"); } @@ -374,7 +373,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded"); -@@ -1476,9 +1711,22 @@ +@@ -1476,9 +1710,22 @@ } else if (this.world.isClientSide) { return null; } else { @@ -397,7 +396,7 @@ this.world.addEntity(entityitem); return entityitem; } -@@ -1559,7 +1807,7 @@ +@@ -1559,7 +1806,7 @@ this.setPose(EntityPose.STANDING); this.vehicle = entity; @@ -406,7 +405,7 @@ return true; } } -@@ -1584,7 +1832,7 @@ +@@ -1584,7 +1831,7 @@ Entity entity = this.vehicle; this.vehicle = null; @@ -415,7 +414,7 @@ } } -@@ -1593,10 +1841,31 @@ +@@ -1593,10 +1840,31 @@ this.bb(); } @@ -448,7 +447,7 @@ if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.getRidingPassenger() instanceof EntityHuman)) { this.passengers.add(0, entity); } else { -@@ -1604,15 +1873,33 @@ +@@ -1604,15 +1872,33 @@ } } @@ -483,7 +482,12 @@ } protected boolean q(Entity entity) { -@@ -1665,7 +1952,13 @@ +@@ -1661,11 +1947,17 @@ + ResourceKey resourcekey = this.world.getDimensionKey() == World.THE_NETHER ? World.OVERWORLD : World.THE_NETHER; + WorldServer worldserver1 = minecraftserver.getWorldServer(resourcekey); + +- if (worldserver1 != null && minecraftserver.getAllowNether() && !this.isPassenger() && this.portalTicks++ >= i) { ++ if (true && !this.isPassenger() && this.portalTicks++ >= i) { // CraftBukkit this.world.getMethodProfiler().enter("portal"); this.portalTicks = i; this.portalCooldown = this.getDefaultPortalCooldown(); @@ -498,7 +502,7 @@ this.world.getMethodProfiler().exit(); } -@@ -1765,6 +2058,13 @@ +@@ -1765,6 +2057,13 @@ } public void setSwimming(boolean flag) { @@ -512,7 +516,7 @@ this.setFlag(4, flag); } -@@ -1825,16 +2125,56 @@ +@@ -1825,16 +2124,56 @@ } public void setAirTicks(int i) { @@ -572,7 +576,7 @@ } public void k(boolean flag) { -@@ -1986,18 +2326,45 @@ +@@ -1986,18 +2325,45 @@ @Nullable public Entity a(WorldServer worldserver) { @@ -622,7 +626,7 @@ } else { double d0 = this.locX(); double d1 = this.locZ(); -@@ -2023,7 +2390,16 @@ +@@ -2023,7 +2389,16 @@ Vec3D vec3d1 = this.getPortalOffset(); blockposition = new BlockPosition(d0, this.locY(), d1); @@ -640,7 +644,7 @@ if (shapedetector_shape == null) { return null; -@@ -2033,6 +2409,11 @@ +@@ -2033,6 +2408,11 @@ vec3d = shapedetector_shape.velocity; f = (float) shapedetector_shape.yaw; } @@ -652,7 +656,7 @@ this.world.getMethodProfiler().exitEnter("reloading"); Entity entity = this.getEntityType().a((World) worldserver); -@@ -2043,8 +2424,16 @@ +@@ -2043,8 +2423,16 @@ entity.setMot(vec3d); worldserver.addEntityTeleport(entity); if (worldserver.getDimensionKey() == World.THE_END) { @@ -670,7 +674,7 @@ } this.bJ(); -@@ -2253,7 +2642,26 @@ +@@ -2253,7 +2641,26 @@ } public void a(AxisAlignedBB axisalignedbb) { diff --git a/nms-patches/EntityPlayer.patch b/nms-patches/EntityPlayer.patch index e75575647c..7017853687 100644 --- a/nms-patches/EntityPlayer.patch +++ b/nms-patches/EntityPlayer.patch @@ -397,7 +397,15 @@ double d0 = this.locX(); double d1 = this.locY(); double d2 = this.locZ(); -@@ -593,7 +803,26 @@ +@@ -567,6 +777,7 @@ + worldserver1.getMethodProfiler().enter("moving"); + double d3; + ++ if (worldserver == null) { } else // CraftBukkit - empty to fall through to null to event + if (worldserver.getDimensionKey() == World.THE_END) { + BlockPosition blockposition = WorldServer.a; + +@@ -593,7 +804,26 @@ } } @@ -425,7 +433,7 @@ worldserver1.getMethodProfiler().exit(); worldserver1.getMethodProfiler().enter("placing"); double d4 = Math.min(-2.9999872E7D, worldserver.getWorldBorder().e() + 16.0D); -@@ -604,25 +833,74 @@ +@@ -604,25 +834,74 @@ d0 = MathHelper.a(d0, d4, d5); d2 = MathHelper.a(d2, d3, d6); @@ -512,7 +520,7 @@ this.playerInteractManager.a(worldserver); this.playerConnection.sendPacket(new PacketPlayOutAbilities(this.abilities)); playerlist.a(this, worldserver); -@@ -639,6 +917,11 @@ +@@ -639,6 +918,11 @@ this.lastSentExp = -1; this.lastHealthSent = -1.0F; this.lastFoodSent = -1; @@ -524,7 +532,7 @@ return this; } } -@@ -680,10 +963,8 @@ +@@ -680,10 +964,8 @@ this.activeContainer.c(); } @@ -537,7 +545,7 @@ if (!this.isSleeping() && this.isAlive()) { if (!this.world.getDimensionManager().isNatural()) { return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE); -@@ -709,7 +990,36 @@ +@@ -709,7 +991,36 @@ } } @@ -575,7 +583,7 @@ this.a(StatisticList.SLEEP_IN_BED); CriterionTriggers.q.a(this); }); -@@ -718,9 +1028,8 @@ +@@ -718,9 +1029,8 @@ return either; } } @@ -586,7 +594,7 @@ } @Override -@@ -747,6 +1056,7 @@ +@@ -747,6 +1057,7 @@ @Override public void wakeup(boolean flag, boolean flag1) { @@ -594,7 +602,7 @@ if (this.isSleeping()) { this.getWorldServer().getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutAnimation(this, 2)); } -@@ -818,8 +1128,9 @@ +@@ -818,8 +1129,9 @@ this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition())); } @@ -605,7 +613,7 @@ } @Override -@@ -834,6 +1145,24 @@ +@@ -834,6 +1146,24 @@ this.nextContainerCounter(); Container container = itileinventory.createMenu(this.containerCounter, this.inventory, this); @@ -630,7 +638,7 @@ if (container == null) { if (this.isSpectator()) { this.a((IChatBaseComponent) (new ChatMessage("container.spectatorCantOpen")).a(EnumChatFormat.RED), true); -@@ -841,9 +1170,11 @@ +@@ -841,9 +1171,11 @@ return OptionalInt.empty(); } else { @@ -644,7 +652,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -856,13 +1187,24 @@ +@@ -856,13 +1188,24 @@ @Override public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { @@ -671,7 +679,7 @@ this.activeContainer.addSlotListener(this); } -@@ -907,6 +1249,11 @@ +@@ -907,6 +1250,11 @@ public void a(Container container, NonNullList nonnulllist) { this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, nonnulllist)); this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried())); @@ -683,7 +691,7 @@ } @Override -@@ -916,6 +1263,7 @@ +@@ -916,6 +1264,7 @@ @Override public void closeInventory() { @@ -691,7 +699,7 @@ this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId)); this.o(); } -@@ -950,7 +1298,7 @@ +@@ -950,7 +1299,7 @@ @Override public void a(Statistic statistic, int i) { this.serverStatisticManager.b(this, statistic, i); @@ -700,7 +708,7 @@ scoreboardscore.addScore(i); }); } -@@ -958,7 +1306,7 @@ +@@ -958,7 +1307,7 @@ @Override public void a(Statistic statistic) { this.serverStatisticManager.setStatistic(this, statistic, 0); @@ -709,7 +717,7 @@ } @Override -@@ -1007,7 +1355,16 @@ +@@ -1007,7 +1356,16 @@ public void triggerHealthUpdate() { this.lastHealthSent = -1.0E8F; @@ -726,7 +734,7 @@ @Override public void a(IChatBaseComponent ichatbasecomponent, boolean flag) { -@@ -1062,12 +1419,14 @@ +@@ -1062,12 +1420,14 @@ this.lastSentExp = -1; this.lastHealthSent = -1.0F; this.lastFoodSent = -1; @@ -742,7 +750,7 @@ } @Override -@@ -1135,6 +1494,18 @@ +@@ -1135,6 +1495,18 @@ @Override public void a(EnumGamemode enumgamemode) { @@ -761,7 +769,7 @@ this.playerInteractManager.setGameMode(enumgamemode); this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.d, (float) enumgamemode.getId())); if (enumgamemode == EnumGamemode.SPECTATOR) { -@@ -1184,7 +1555,20 @@ +@@ -1184,7 +1556,20 @@ return s; } @@ -782,7 +790,7 @@ this.cf = packetplayinsettings.d(); this.cg = packetplayinsettings.e(); this.getDataWatcher().set(EntityPlayer.bp, (byte) packetplayinsettings.f()); -@@ -1220,13 +1604,13 @@ +@@ -1220,13 +1605,13 @@ if (entity instanceof EntityHuman) { this.playerConnection.sendPacket(new PacketPlayOutEntityDestroy(new int[]{entity.getId()})); } else { @@ -798,7 +806,7 @@ } @Override -@@ -1250,7 +1634,7 @@ +@@ -1250,7 +1635,7 @@ this.spectatedEntity = (Entity) (entity == null ? this : entity); if (entity1 != this.spectatedEntity) { this.playerConnection.sendPacket(new PacketPlayOutCamera(this.spectatedEntity)); @@ -807,7 +815,7 @@ } } -@@ -1279,7 +1663,7 @@ +@@ -1279,7 +1664,7 @@ @Nullable public IChatBaseComponent getPlayerListName() { @@ -816,7 +824,7 @@ } @Override -@@ -1300,9 +1684,16 @@ +@@ -1300,9 +1685,16 @@ return this.advancementDataPlayer; } @@ -833,7 +841,7 @@ if (worldserver == this.world) { this.playerConnection.a(d0, d1, d2, f, f1); } else { -@@ -1323,6 +1714,9 @@ +@@ -1323,6 +1715,9 @@ this.server.getPlayerList().a(this, worldserver); this.server.getPlayerList().updateClient(this); } @@ -843,7 +851,7 @@ } -@@ -1409,4 +1803,144 @@ +@@ -1409,4 +1804,144 @@ return entityitem; } }