diff options
author | Jake Potrebic <[email protected]> | 2022-06-02 21:26:56 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2022-06-02 21:26:56 -0700 |
commit | a3ad72074951c5f2fd27f41f7cb9b8ae46241d30 (patch) | |
tree | fc581399172f25af5368022e36323f8ae4f57034 /patches/server/0180-Player.setPlayerProfile-API.patch | |
parent | 2033dba4fa16d2f9081c5c6aff54255b3b4717a8 (diff) | |
download | Paper-a3ad72074951c5f2fd27f41f7cb9b8ae46241d30.tar.gz Paper-a3ad72074951c5f2fd27f41f7cb9b8ae46241d30.zip |
Remove ChatColor usages (#7543)
Diffstat (limited to 'patches/server/0180-Player.setPlayerProfile-API.patch')
-rw-r--r-- | patches/server/0180-Player.setPlayerProfile-API.patch | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/patches/server/0180-Player.setPlayerProfile-API.patch b/patches/server/0180-Player.setPlayerProfile-API.patch new file mode 100644 index 0000000000..d77c6b52ab --- /dev/null +++ b/patches/server/0180-Player.setPlayerProfile-API.patch @@ -0,0 +1,145 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar <[email protected]> +Date: Sun, 18 Mar 2018 12:29:48 -0400 +Subject: [PATCH] Player.setPlayerProfile API + +This can be useful for changing name or skins after a player has logged in. + +diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +index d3462cdc5eee37cedbff80f35d5b9c51e8dcd1da..5ebc450432805d52457b9f8ff1e2b1981bdd78e6 100644 +--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java ++++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +@@ -344,11 +344,11 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener + final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server; + + // Paper start +- com.destroystokyo.paper.profile.PlayerProfile profile = org.bukkit.Bukkit.createProfile(uniqueId, playerName); ++ com.destroystokyo.paper.profile.PlayerProfile profile = com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitMirror(ServerLoginPacketListenerImpl.this.gameProfile); + AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId, profile); + server.getPluginManager().callEvent(asyncEvent); + profile = asyncEvent.getPlayerProfile(); +- profile.complete(); ++ profile.complete(true); // Paper - setPlayerProfileAPI + gameProfile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile); + playerName = gameProfile.getName(); + uniqueId = gameProfile.getId(); +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +index 19e8ec4baf0967693121b2e3443d436f85f518ec..9ab4897d5d0b25fbdcb4a9889b7e73acd993a786 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +@@ -77,6 +77,7 @@ import net.minecraft.world.entity.ai.attributes.Attributes; + import net.minecraft.world.inventory.AbstractContainerMenu; + import net.minecraft.world.level.GameType; + import net.minecraft.world.level.block.Blocks; ++import net.minecraft.world.level.biome.BiomeManager; + import net.minecraft.world.level.block.entity.SignBlockEntity; + import net.minecraft.world.level.border.BorderChangeListener; + import net.minecraft.world.level.saveddata.maps.MapDecoration; +@@ -204,11 +205,6 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + return server.getPlayer(getUniqueId()) != null; + } + +- @Override +- public PlayerProfile getPlayerProfile() { +- return new CraftPlayerProfile(this.getProfile()); +- } +- + @Override + public InetSocketAddress getAddress() { + if (this.getHandle().connection == null) return null; +@@ -1482,8 +1478,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + this.hiddenEntities.put(entity.getUniqueId(), hidingPlugins); + + // Remove this entity from the hidden player's EntityTrackerEntry +- ChunkMap tracker = ((ServerLevel) this.getHandle().level).getChunkSource().chunkMap; ++ // Paper start + Entity other = ((CraftEntity) entity).getHandle(); ++ unregisterEntity(other); ++ ++ server.getPluginManager().callEvent(new PlayerHideEntityEvent(this, entity)); ++ } ++ private void unregisterEntity(Entity other) { ++ // Paper end ++ ChunkMap tracker = ((ServerLevel) this.getHandle().level).getChunkSource().chunkMap; + ChunkMap.TrackedEntity entry = tracker.entityMap.get(other.getId()); + if (entry != null) { + entry.removePlayer(this.getHandle()); +@@ -1496,8 +1499,6 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + this.getHandle().connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER, otherPlayer)); + } + } +- +- server.getPluginManager().callEvent(new PlayerHideEntityEvent(this, entity)); + } + + @Override +@@ -1534,8 +1535,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + } + this.hiddenEntities.remove(entity.getUniqueId()); + +- ChunkMap tracker = ((ServerLevel) this.getHandle().level).getChunkSource().chunkMap; ++ // Paper start + Entity other = ((CraftEntity) entity).getHandle(); ++ registerEntity(other); ++ ++ server.getPluginManager().callEvent(new PlayerShowEntityEvent(this, entity)); ++ } ++ private void registerEntity(Entity other) { ++ ChunkMap tracker = ((ServerLevel) this.getHandle().level).getChunkSource().chunkMap; ++ // Paper end + + if (other instanceof ServerPlayer) { + ServerPlayer otherPlayer = (ServerPlayer) other; +@@ -1546,9 +1554,51 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + if (entry != null && !entry.seenBy.contains(this.getHandle().connection)) { + entry.updatePlayer(this.getHandle()); + } ++ } ++ // Paper start ++ private void reregisterPlayer(ServerPlayer player) { ++ if (!hiddenEntities.containsKey(player.getUUID())) { ++ unregisterEntity(player); ++ registerEntity(player); ++ } ++ } ++ public void setPlayerProfile(com.destroystokyo.paper.profile.PlayerProfile profile) { ++ ServerPlayer self = getHandle(); ++ self.gameProfile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile); ++ if (!self.sentListPacket) { ++ return; ++ } ++ List<ServerPlayer> players = server.getServer().getPlayerList().players; ++ for (ServerPlayer player : players) { ++ player.getBukkitEntity().reregisterPlayer(self); ++ } ++ 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(); ++ ++ 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.dimensionTypeRegistration(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), handle.gameMode.getGameModeForPlayer(), handle.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true)); ++ handle.onUpdateAbilities(); ++ connection.send(new net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch(), java.util.Collections.emptySet(), 0, false)); ++ net.minecraft.server.MinecraftServer.getServer().getPlayerList().sendAllPlayerInfo(handle); ++ ++ if (this.isOp()) { ++ this.setOp(false); ++ this.setOp(true); ++ } + } ++ // Paper end + + public void onEntityRemove(Entity entity) { + this.hiddenEntities.remove(entity.getUUID()); |