Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 20:40:07 +01:00
06db5d08b0
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 44cfe143 SPIGOT-6249: Add Missing Effect Constants CraftBukkit Changes: 14928261 SPIGOT-6249: Add Missing Effect Constants 332335e1 SPIGOT-6731: "Nag author" message in CraftServer lists one author only 6cd975d0 SPIGOT-5732, SPIGOT-6387: Overhaul Hanging entities
134 Zeilen
7.3 KiB
Diff
134 Zeilen
7.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
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 261ebb134a5ff40406e74237f730aad1c78a8215..39bdda56aaa5503efc15207261634127b462c3e7 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
@@ -340,12 +340,12 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
|
|
final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server;
|
|
|
|
// Paper start
|
|
- PlayerProfile profile = Bukkit.createProfile(uniqueId, playerName);
|
|
+ PlayerProfile profile = CraftPlayerProfile.asBukkitMirror(ServerLoginPacketListenerImpl.this.gameProfile);
|
|
AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId, profile);
|
|
server.getPluginManager().callEvent(asyncEvent);
|
|
profile = asyncEvent.getPlayerProfile();
|
|
- profile.complete();
|
|
- gameProfile = CraftPlayerProfile.asAuthlibCopy(profile);
|
|
+ profile.complete(true);
|
|
+ ServerLoginPacketListenerImpl.this.gameProfile = CraftPlayerProfile.asAuthlib(profile);
|
|
playerName = gameProfile.getName();
|
|
uniqueId = gameProfile.getId();
|
|
// Paper end
|
|
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
index 3c8de1d70714a021dbd58894f3fd986bf5d6bde7..cc6f1f94c1a01992dfe29399b346c972f114a38d 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
@@ -173,7 +173,7 @@ public abstract class Player extends LivingEntity {
|
|
protected int enchantmentSeed;
|
|
protected final float defaultFlySpeed = 0.02F;
|
|
private int lastLevelUpTime;
|
|
- private final GameProfile gameProfile;
|
|
+ public GameProfile gameProfile; // Paper - private->public
|
|
private boolean reducedDebugInfo;
|
|
private ItemStack lastItemInMainHand;
|
|
private final ItemCooldowns cooldowns;
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
index da472b9881ab8f3699f75b3dd6a3115df4bb5a53..3426c1cfac6ad787891185bb1e8fa29edb682dd1 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -71,6 +71,7 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
|
import net.minecraft.world.item.enchantment.Enchantments;
|
|
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.saveddata.maps.MapDecoration;
|
|
import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
|
|
@@ -1340,8 +1341,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
this.hiddenPlayers.put(player.getUniqueId(), hidingPlugins);
|
|
|
|
// Remove this player from the hidden player's EntityTrackerEntry
|
|
- ChunkMap tracker = ((ServerLevel) entity.level).getChunkSource().chunkMap;
|
|
+ // Paper start
|
|
ServerPlayer other = ((CraftPlayer) player).getHandle();
|
|
+ unregisterPlayer(other);
|
|
+ }
|
|
+ private void unregisterPlayer(ServerPlayer other) {
|
|
+ ChunkMap tracker = ((ServerLevel) entity.level).getChunkSource().chunkMap;
|
|
+ // Paper end
|
|
ChunkMap.TrackedEntity entry = tracker.entityMap.get(other.getId());
|
|
if (entry != null) {
|
|
entry.removePlayer(this.getHandle());
|
|
@@ -1382,8 +1388,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
}
|
|
this.hiddenPlayers.remove(player.getUniqueId());
|
|
|
|
- ChunkMap tracker = ((ServerLevel) entity.level).getChunkSource().chunkMap;
|
|
+ // Paper start
|
|
ServerPlayer other = ((CraftPlayer) player).getHandle();
|
|
+ registerPlayer(other);
|
|
+ }
|
|
+ private void registerPlayer(ServerPlayer other) {
|
|
+ ChunkMap tracker = ((ServerLevel) entity.level).getChunkSource().chunkMap;
|
|
+ // Paper end
|
|
|
|
this.getHandle().connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, other));
|
|
|
|
@@ -1392,6 +1403,50 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
entry.updatePlayer(this.getHandle());
|
|
}
|
|
}
|
|
+ // Paper start
|
|
+ private void reregisterPlayer(ServerPlayer player) {
|
|
+ if (!hiddenPlayers.containsKey(player.getUUID())) {
|
|
+ unregisterPlayer(player);
|
|
+ registerPlayer(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();
|
|
+ }
|
|
+
|
|
+ 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.dimensionType(), 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 removeDisconnectingPlayer(Player player) {
|
|
this.hiddenPlayers.remove(player.getUniqueId());
|