mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 13:57:35 +01:00
Fix Player#setPlayerProfile (#8939)
This commit is contained in:
parent
449be4e304
commit
03c2f3b9db
@ -114,40 +114,51 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
}
|
}
|
||||||
+ }
|
+ }
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ private void reregisterPlayer(ServerPlayer player) {
|
+ @Override
|
||||||
+ if (!hiddenEntities.containsKey(player.getUUID())) {
|
|
||||||
+ unregisterEntity(player);
|
|
||||||
+ registerEntity(player);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ public void setPlayerProfile(com.destroystokyo.paper.profile.PlayerProfile profile) {
|
+ public void setPlayerProfile(com.destroystokyo.paper.profile.PlayerProfile profile) {
|
||||||
+ ServerPlayer self = getHandle();
|
+ ServerPlayer self = this.getHandle();
|
||||||
+ self.gameProfile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile);
|
+ GameProfile gameProfile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile);
|
||||||
+ if (!self.sentListPacket) {
|
+ if (!self.sentListPacket) {
|
||||||
|
+ self.gameProfile = gameProfile;
|
||||||
+ return;
|
+ 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) {
|
+ 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() {
|
+ public com.destroystokyo.paper.profile.PlayerProfile getPlayerProfile() {
|
||||||
+ return new com.destroystokyo.paper.profile.CraftPlayerProfile(this).clone();
|
+ 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;
|
+ ServerGamePacketListenerImpl connection = handle.connection;
|
||||||
+ reregisterPlayer(handle);
|
|
||||||
+
|
+
|
||||||
+ //Respawn the player then update their position and selected slot
|
+ //Respawn the player then update their position and selected slot
|
||||||
+ ServerLevel worldserver = handle.getLevel();
|
+ 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();
|
+ handle.onUpdateAbilities();
|
||||||
+ connection.internalTeleport(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch(), java.util.Collections.emptySet(), false);
|
+ 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);
|
+ net.minecraft.server.MinecraftServer.getServer().getPlayerList().sendAllPlayerInfo(handle);
|
||||||
@ -156,11 +167,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ this.setOp(false);
|
+ this.setOp(false);
|
||||||
+ this.setOp(true);
|
+ this.setOp(true);
|
||||||
+ }
|
+ }
|
||||||
}
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
+
|
||||||
public void onEntityRemove(Entity entity) {
|
public void onEntityRemove(Entity entity) {
|
||||||
this.hiddenEntities.remove(entity.getUUID());
|
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
|
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
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
|
--- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
|
||||||
|
Loading…
Reference in New Issue
Block a user