SPIGOT-7785: Teleporting a player at the right moment can mess up vanilla teleportation

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2024-06-22 10:08:46 +10:00
parent 97750e6387
commit 7e7632f81a

View file

@ -461,7 +461,7 @@
UUID uuid = gameprofile.getId();
Set<EntityPlayer> set = Sets.newIdentityHashSet();
Iterator iterator = this.players.iterator();
@@ -469,22 +651,41 @@
@@ -469,22 +651,42 @@
}
return !set.isEmpty();
@ -488,6 +488,7 @@
+ EntityPlayer entityplayer1 = entityplayer;
+ World fromWorld = entityplayer.level();
+ entityplayer.wonGame = false;
+ entityplayer.portalProcess = null; // CraftBukkit - SPIGOT-7785: there is no need to carry this over as it contains the old world/location
+ // CraftBukkit end
entityplayer1.connection = entityplayer.connection;
@ -504,7 +505,7 @@
Iterator iterator = entityplayer.getTags().iterator();
@@ -494,11 +695,26 @@
@@ -494,11 +696,26 @@
entityplayer1.addTag(s);
}
@ -532,7 +533,7 @@
}
int i = flag ? 1 : 0;
@@ -506,17 +722,19 @@
@@ -506,17 +723,19 @@
WorldData worlddata = worldserver1.getLevelData();
entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.createCommonSpawnInfo(worldserver1), (byte) i));
@ -557,7 +558,7 @@
entityplayer1.setHealth(entityplayer1.getHealth());
if (!flag) {
BlockPosition blockposition = BlockPosition.containing(dimensiontransition.pos());
@@ -526,6 +744,27 @@
@@ -526,6 +745,27 @@
entityplayer1.connection.send(new PacketPlayOutNamedSoundEffect(SoundEffects.RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F, worldserver.getRandom().nextLong()));
}
}
@ -585,7 +586,7 @@
return entityplayer1;
}
@@ -554,7 +793,18 @@
@@ -554,7 +794,18 @@
public void tick() {
if (++this.sendAllPlayerInfoIn > 600) {
@ -605,7 +606,7 @@
this.sendAllPlayerInfoIn = 0;
}
@@ -571,6 +821,25 @@
@@ -571,6 +822,25 @@
}
@ -631,7 +632,7 @@
public void broadcastAll(Packet<?> packet, ResourceKey<World> resourcekey) {
Iterator iterator = this.players.iterator();
@@ -649,7 +918,7 @@
@@ -649,7 +919,7 @@
}
public void deop(GameProfile gameprofile) {
@ -640,7 +641,7 @@
EntityPlayer entityplayer = this.getPlayer(gameprofile.getId());
if (entityplayer != null) {
@@ -673,6 +942,7 @@
@@ -673,6 +943,7 @@
entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, b0));
}
@ -648,7 +649,7 @@
this.server.getCommands().sendCommands(entityplayer);
}
@@ -703,6 +973,12 @@
@@ -703,6 +974,12 @@
for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
@ -661,7 +662,7 @@
if (entityplayer != entityhuman && entityplayer.level().dimension() == resourcekey) {
double d4 = d0 - entityplayer.getX();
double d5 = d1 - entityplayer.getY();
@@ -742,15 +1018,19 @@
@@ -742,15 +1019,19 @@
public void reloadWhiteList() {}
public void sendLevelInfo(EntityPlayer entityplayer, WorldServer worldserver) {
@ -685,7 +686,7 @@
}
entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.LEVEL_CHUNKS_LOAD_START, 0.0F));
@@ -759,8 +1039,16 @@
@@ -759,8 +1040,16 @@
public void sendAllPlayerInfo(EntityPlayer entityplayer) {
entityplayer.inventoryMenu.sendAllDataToRemote();
@ -703,7 +704,7 @@
}
public int getPlayerCount() {
@@ -816,12 +1104,22 @@
@@ -816,12 +1105,22 @@
}
public void removeAll() {
@ -728,7 +729,7 @@
public void broadcastSystemMessage(IChatBaseComponent ichatbasecomponent, boolean flag) {
this.broadcastSystemMessage(ichatbasecomponent, (entityplayer) -> {
return ichatbasecomponent;
@@ -879,16 +1177,23 @@
@@ -879,16 +1178,23 @@
return playerchatmessage.hasSignature() && !playerchatmessage.hasExpiredServer(Instant.now());
}
@ -756,7 +757,7 @@
Path path = file2.toPath();
if (FileUtils.isPathNormalized(path) && FileUtils.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) {
@@ -897,7 +1202,7 @@
@@ -897,7 +1203,7 @@
}
serverstatisticmanager = new ServerStatisticManager(this.server, file1);
@ -765,7 +766,7 @@
}
return serverstatisticmanager;
@@ -905,13 +1210,13 @@
@@ -905,13 +1211,13 @@
public AdvancementDataPlayer getPlayerAdvancements(EntityPlayer entityplayer) {
UUID uuid = entityplayer.getUUID();
@ -781,7 +782,7 @@
}
advancementdataplayer.setPlayer(entityplayer);
@@ -962,13 +1267,20 @@
@@ -962,13 +1268,20 @@
}
public void reloadResources() {