mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Fix Player#setPlayerProfile (#8939)
This commit is contained in:
parent
449be4e304
commit
03c2f3b9db
1 changed files with 33 additions and 21 deletions
|
@ -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<ServerPlayer> players = server.getServer().getPlayerList().players;
|
||||
+ List<ServerPlayer> 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
|
||||
|
|
Loading…
Reference in a new issue