diff --git a/patches/server/Player.setPlayerProfile-API.patch b/patches/server/Player.setPlayerProfile-API.patch index 03ca06025d..7cddd39ec9 100644 --- a/patches/server/Player.setPlayerProfile-API.patch +++ b/patches/server/Player.setPlayerProfile-API.patch @@ -114,40 +114,51 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } + } + // Paper start -+ private void reregisterPlayer(ServerPlayer player) { -+ if (!hiddenEntities.containsKey(player.getUUID())) { -+ unregisterEntity(player); -+ registerEntity(player); -+ } -+ } ++ @Override + public void setPlayerProfile(com.destroystokyo.paper.profile.PlayerProfile profile) { -+ ServerPlayer self = getHandle(); -+ self.gameProfile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile); ++ ServerPlayer self = this.getHandle(); ++ GameProfile gameProfile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile); + if (!self.sentListPacket) { ++ self.gameProfile = gameProfile; + return; + } -+ List players = server.getServer().getPlayerList().players; ++ List players = this.server.getServer().getPlayerList().players; ++ // First unregister the player for all players with the OLD game profile + for (ServerPlayer player : players) { -+ player.getBukkitEntity().reregisterPlayer(self); ++ CraftPlayer bukkitPlayer = player.getBukkitEntity(); ++ if (bukkitPlayer.canSee(this)) { ++ bukkitPlayer.unregisterEntity(self); ++ } + } -+ refreshPlayer(); -+ } + +- server.getPluginManager().callEvent(new PlayerShowEntityEvent(this, entity)); ++ // Set the game profile here, we should have unregistered the entity via iterating all player entities above. ++ self.gameProfile = gameProfile; ++ ++ // Re-register the game profile for all players ++ for (ServerPlayer player : players) { ++ CraftPlayer bukkitPlayer = player.getBukkitEntity(); ++ if (bukkitPlayer.canSee(this)) { ++ bukkitPlayer.registerEntity(self); ++ } ++ } ++ // Refresh misc player things AFTER sending game profile ++ this.refreshPlayer(); + } + + public com.destroystokyo.paper.profile.PlayerProfile getPlayerProfile() { + return new com.destroystokyo.paper.profile.CraftPlayerProfile(this).clone(); + } - -- server.getPluginManager().callEvent(new PlayerShowEntityEvent(this, entity)); -+ private void refreshPlayer() { -+ ServerPlayer handle = getHandle(); + -+ Location loc = getLocation(); ++ private void refreshPlayer() { ++ ServerPlayer handle = this.getHandle(); ++ Location loc = this.getLocation(); + + ServerGamePacketListenerImpl connection = handle.connection; -+ reregisterPlayer(handle); + + //Respawn the player then update their position and selected slot + ServerLevel worldserver = handle.getLevel(); -+ connection.send(new net.minecraft.network.protocol.game.ClientboundRespawnPacket(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), handle.gameMode.getGameModeForPlayer(), handle.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), net.minecraft.network.protocol.game.ClientboundRespawnPacket.KEEP_ALL_DATA, this.getHandle().getLastDeathLocation())); ++ connection.send(new net.minecraft.network.protocol.game.ClientboundRespawnPacket(worldserver.dimensionTypeId(), worldserver.dimension(), net.minecraft.world.level.biome.BiomeManager.obfuscateSeed(worldserver.getSeed()), handle.gameMode.getGameModeForPlayer(), handle.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), net.minecraft.network.protocol.game.ClientboundRespawnPacket.KEEP_ALL_DATA, this.getHandle().getLastDeathLocation())); + handle.onUpdateAbilities(); + connection.internalTeleport(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch(), java.util.Collections.emptySet(), false); + net.minecraft.server.MinecraftServer.getServer().getPlayerList().sendAllPlayerInfo(handle); @@ -156,11 +167,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.setOp(false); + this.setOp(true); + } - } ++ } + // Paper end - ++ public void onEntityRemove(Entity entity) { this.hiddenEntities.remove(entity.getUUID()); + } diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java