aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0180-Player.setPlayerProfile-API.patch
diff options
context:
space:
mode:
authorSpottedleaf <[email protected]>2023-06-07 22:21:04 -0700
committerSpottedleaf <[email protected]>2023-06-07 22:26:06 -0700
commit819facd7c4343f6783d1a4ee84345d5b99ef47ce (patch)
tree67933d38087dbc5713d3669c03ccb4d167521ca6 /patches/server/0180-Player.setPlayerProfile-API.patch
parent0c4a1c449662e842432f4458dbb2e26a0dbc66ff (diff)
downloadPaper-819facd7c4343f6783d1a4ee84345d5b99ef47ce.tar.gz
Paper-819facd7c4343f6783d1a4ee84345d5b99ef47ce.zip
rewrite chunk system checkpoint
Diffstat (limited to 'patches/server/0180-Player.setPlayerProfile-API.patch')
-rw-r--r--patches/server/0180-Player.setPlayerProfile-API.patch200
1 files changed, 0 insertions, 200 deletions
diff --git a/patches/server/0180-Player.setPlayerProfile-API.patch b/patches/server/0180-Player.setPlayerProfile-API.patch
deleted file mode 100644
index 3f171b5437..0000000000
--- a/patches/server/0180-Player.setPlayerProfile-API.patch
+++ /dev/null
@@ -1,200 +0,0 @@
-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.
-
-== AT ==
-public-f net.minecraft.world.entity.player.Player gameProfile
-
-diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
-index 528ef2cb78ece52e389578e5ed36287ac395b824..a72d0b6add00ba03bec76c1e22bfdb94730fe73e 100644
---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
-+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
-@@ -1528,7 +1528,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
- this.internalTeleport(dest.getX(), dest.getY(), dest.getZ(), dest.getYaw(), dest.getPitch(), Collections.emptySet());
- }
-
-- private void internalTeleport(double d0, double d1, double d2, float f, float f1, Set<RelativeMovement> set) {
-+ public void internalTeleport(double d0, double d1, double d2, float f, float f1, Set<RelativeMovement> set) { // Paper
- // CraftBukkit start
- if (Float.isNaN(f)) {
- f = 0;
-diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
-index 6b31b0894e52ad6fc397624e50587ec04e46c099..0c7f280bae81bbb492d5780a43e5ffda0f58756a 100644
---- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
-+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
-@@ -330,11 +330,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/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
-index e7442952ef1f03969949014492a7ddc6d0796ba5..69a1852905dd4724c30ac8ab88c14251eee2c371 100644
---- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
-+++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
-@@ -76,8 +76,8 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
- }
-
- @Override
-- public PlayerProfile getPlayerProfile() {
-- return new CraftPlayerProfile(this.profile);
-+ public com.destroystokyo.paper.profile.PlayerProfile getPlayerProfile() { // Paper
-+ return new com.destroystokyo.paper.profile.CraftPlayerProfile(this.profile); // Paper
- }
-
- public Server getServer() {
-diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
-index 1ce5ec09f6fe562dace89575e2a73f727e1eb951..dd81b001288c4a9144defb297a6a877b4464d0ab 100644
---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
-+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
-@@ -82,6 +82,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.block.entity.SignText;
- import net.minecraft.world.level.border.BorderChangeListener;
-@@ -216,11 +217,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;
-@@ -1617,8 +1613,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
-
- private void untrackAndHideEntity(org.bukkit.entity.Entity entity) {
- // 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());
-@@ -1631,8 +1634,6 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
- this.getHandle().connection.send(new ClientboundPlayerInfoRemovePacket(List.of(otherPlayer.getUUID())));
- }
- }
--
-- server.getPluginManager().callEvent(new PlayerHideEntityEvent(this, entity));
- }
-
- void resetAndHideEntity(org.bukkit.entity.Entity entity) {
-@@ -1709,8 +1710,38 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
- if (entry != null && !entry.seenBy.contains(this.getHandle().connection)) {
- entry.updatePlayer(this.getHandle());
- }
-+ server.getPluginManager().callEvent(new PlayerShowEntityEvent(this, entity)); // Paper
-+ }
-+ // Paper start
-+ @Override
-+ public void setPlayerProfile(com.destroystokyo.paper.profile.PlayerProfile profile) {
-+ ServerPlayer self = this.getHandle();
-+ GameProfile gameProfile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile);
-+ if (!self.sentListPacket) {
-+ self.gameProfile = gameProfile;
-+ return;
-+ }
-+ List<ServerPlayer> players = this.server.getServer().getPlayerList().players;
-+ // First unregister the player for all players with the OLD game profile
-+ for (ServerPlayer player : players) {
-+ CraftPlayer bukkitPlayer = player.getBukkitEntity();
-+ if (bukkitPlayer.canSee(this)) {
-+ bukkitPlayer.unregisterEntity(self);
-+ }
-+ }
-+
-+ // Set the game profile here, we should have unregistered the entity via iterating all player entities above.
-+ self.gameProfile = gameProfile;
-
-- server.getPluginManager().callEvent(new PlayerShowEntityEvent(this, entity));
-+ // Re-register the game profile for all players
-+ for (ServerPlayer player : players) {
-+ CraftPlayer bukkitPlayer = player.getBukkitEntity();
-+ if (bukkitPlayer.canSee(this)) {
-+ bukkitPlayer.trackAndShowEntity(self.getBukkitEntity());
-+ }
-+ }
-+ // Refresh misc player things AFTER sending game profile
-+ this.refreshPlayer();
- }
-
- void resetAndShowEntity(org.bukkit.entity.Entity entity) {
-@@ -1723,6 +1754,36 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
- this.trackAndShowEntity(entity);
- }
- }
-+ // Paper start
-+ public com.destroystokyo.paper.profile.PlayerProfile getPlayerProfile() {
-+ return new com.destroystokyo.paper.profile.CraftPlayerProfile(this).clone();
-+ }
-+
-+ private void refreshPlayer() {
-+ ServerPlayer handle = this.getHandle();
-+ Location loc = this.getLocation();
-+
-+ ServerGamePacketListenerImpl connection = handle.connection;
-+
-+ //Respawn the player then update their position and selected slot
-+ ServerLevel worldserver = handle.serverLevel();
-+ 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.getPortalCooldown()));
-+ handle.onUpdateAbilities();
-+ connection.internalTeleport(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch(), java.util.Collections.emptySet());
-+ net.minecraft.server.MinecraftServer.getServer().getPlayerList().sendAllPlayerInfo(handle);
-+
-+ // Resend their XP and effects because the respawn packet resets it
-+ connection.send(new net.minecraft.network.protocol.game.ClientboundSetExperiencePacket(handle.experienceProgress, handle.totalExperience, handle.experienceLevel));
-+ for (net.minecraft.world.effect.MobEffectInstance mobEffect : handle.getActiveEffects()) {
-+ connection.send(new net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket(handle.getId(), mobEffect));
-+ }
-+
-+ if (this.isOp()) {
-+ this.setOp(false);
-+ this.setOp(true);
-+ }
-+ }
-+ // Paper end
-
- public void onEntityRemove(Entity entity) {
- this.invertedVisibilityEntities.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 173a2832f029e3d568208a1b56419c1b8501483c..48cdd483c25825571043800f3cfa41a4d723f649 100644
---- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
-+++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
-@@ -329,6 +329,12 @@ public class Commodore
- return;
- }
-
-+ // Paper start - Rewrite plugins
-+ if ((owner.equals("org/bukkit/OfflinePlayer") || owner.equals("org/bukkit/entity/Player")) && name.equals("getPlayerProfile") && desc.equals("()Lorg/bukkit/profile/PlayerProfile;")) {
-+ super.visitMethodInsn(opcode, owner, name, "()Lcom/destroystokyo/paper/profile/PlayerProfile;", itf);
-+ return;
-+ }
-+ // Paper end
- if ( modern )
- {
- if ( owner.equals( "org/bukkit/Material" ) )