mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-01 04:31:58 +01:00
b62dfa0bf9
Upstream has released updates that appears 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: 39ce5d3a SPIGOT-4399: ItemMeta.equals broken with AttributeModifiers CraftBukkit Changes:1cf8b5dc
SPIGOT-4400: Populators running on existing chunks116cb9a1
SPIGOT-4399: Add attribute modifier equality test5ee1c18a
SPIGOT-4398: Set ASM7_EXPERIMENTAL flag
143 lines
6.7 KiB
Diff
143 lines
6.7 KiB
Diff
From 9361263d0896b5fb7e856d7db593d8109a61f696 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/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
index a728507c54..5975578b38 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
@@ -67,7 +67,7 @@ public abstract class EntityHuman extends EntityLiving {
|
|
protected int bZ;
|
|
protected float ca = 0.02F;
|
|
private int g;
|
|
- private final GameProfile h;
|
|
+ private GameProfile h; public void setProfile(GameProfile profile) { this.h = profile; } // Paper - OBFHELPER
|
|
private ItemStack cd;
|
|
private final ItemCooldown ce;
|
|
@Nullable
|
|
diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java
|
|
index ab85fd9a6e..5778a5201d 100644
|
|
--- a/src/main/java/net/minecraft/server/LoginListener.java
|
|
+++ b/src/main/java/net/minecraft/server/LoginListener.java
|
|
@@ -38,7 +38,7 @@ public class LoginListener implements PacketLoginInListener, ITickable {
|
|
public final NetworkManager networkManager;
|
|
private LoginListener.EnumProtocolState g;
|
|
private int h;
|
|
- private GameProfile i;
|
|
+ private GameProfile i; private void setGameProfile(GameProfile profile) { i = profile; } private GameProfile getGameProfile() { return i; } // Paper - OBFHELPER
|
|
private final String j;
|
|
private SecretKey loginKey;
|
|
private EntityPlayer l;
|
|
@@ -284,12 +284,12 @@ public class LoginListener implements PacketLoginInListener, ITickable {
|
|
final org.bukkit.craftbukkit.CraftServer server = LoginListener.this.server.server;
|
|
|
|
// Paper start
|
|
- PlayerProfile profile = Bukkit.createProfile(uniqueId, playerName);
|
|
+ PlayerProfile profile = CraftPlayerProfile.asBukkitMirror(getGameProfile());
|
|
AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId, profile);
|
|
server.getPluginManager().callEvent(asyncEvent);
|
|
profile = asyncEvent.getPlayerProfile();
|
|
- profile.complete();
|
|
- i = CraftPlayerProfile.asAuthlibCopy(profile);
|
|
+ profile.complete(true);
|
|
+ setGameProfile(CraftPlayerProfile.asAuthlib(profile));
|
|
playerName = i.getName();
|
|
uniqueId = i.getId();
|
|
// Paper end
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
index 1c40f17ce9..ae28723ef2 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -1,6 +1,8 @@
|
|
package org.bukkit.craftbukkit.entity;
|
|
|
|
import com.destroystokyo.paper.Title;
|
|
+import com.destroystokyo.paper.profile.CraftPlayerProfile;
|
|
+import com.destroystokyo.paper.profile.PlayerProfile;
|
|
import com.google.common.base.Preconditions;
|
|
import com.google.common.collect.ImmutableSet;
|
|
import com.google.common.io.BaseEncoding;
|
|
@@ -1192,8 +1194,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
hiddenPlayers.put(player.getUniqueId(), hidingPlugins);
|
|
|
|
// Remove this player from the hidden player's EntityTrackerEntry
|
|
- EntityTracker tracker = ((WorldServer) entity.world).tracker;
|
|
EntityPlayer other = ((CraftPlayer) player).getHandle();
|
|
+ // Paper start
|
|
+ unregisterPlayer(other);
|
|
+ }
|
|
+ private void unregisterPlayer(EntityPlayer other) {
|
|
+ EntityTracker tracker = ((WorldServer) entity.world).tracker;
|
|
+ // Paper end
|
|
+
|
|
EntityTrackerEntry entry = tracker.trackedEntities.get(other.getId());
|
|
if (entry != null) {
|
|
entry.clear(getHandle());
|
|
@@ -1234,8 +1242,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
}
|
|
hiddenPlayers.remove(player.getUniqueId());
|
|
|
|
- EntityTracker tracker = ((WorldServer) entity.world).tracker;
|
|
+ // Paper start
|
|
EntityPlayer other = ((CraftPlayer) player).getHandle();
|
|
+ registerPlayer(other);
|
|
+ }
|
|
+ private void registerPlayer(EntityPlayer other) {
|
|
+ EntityTracker tracker = ((WorldServer) entity.world).tracker;
|
|
+ // Paper end
|
|
|
|
getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, other));
|
|
|
|
@@ -1244,6 +1257,46 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
entry.updatePlayer(getHandle());
|
|
}
|
|
}
|
|
+ // Paper start
|
|
+ private void reregisterPlayer(EntityPlayer player) {
|
|
+ if (!hiddenPlayers.containsKey(player.getUniqueID())) {
|
|
+ unregisterPlayer(player);
|
|
+ registerPlayer(player);
|
|
+ }
|
|
+ }
|
|
+ public void setPlayerProfile(PlayerProfile profile) {
|
|
+ EntityPlayer self = getHandle();
|
|
+ self.setProfile(CraftPlayerProfile.asAuthlibCopy(profile));
|
|
+ List<EntityPlayer> players = server.getServer().getPlayerList().players;
|
|
+ for (EntityPlayer player : players) {
|
|
+ player.getBukkitEntity().reregisterPlayer(self);
|
|
+ }
|
|
+ refreshPlayer();
|
|
+ }
|
|
+ public PlayerProfile getPlayerProfile() {
|
|
+ return new CraftPlayerProfile(this).clone();
|
|
+ }
|
|
+
|
|
+ private void refreshPlayer() {
|
|
+ EntityPlayer handle = getHandle();
|
|
+
|
|
+ Location loc = getLocation();
|
|
+
|
|
+ PlayerConnection connection = handle.playerConnection;
|
|
+ reregisterPlayer(handle);
|
|
+
|
|
+ //Respawn the player then update their position and selected slot
|
|
+ connection.sendPacket(new net.minecraft.server.PacketPlayOutRespawn(handle.dimension, handle.world.getDifficulty(), handle.world.getWorldData().getType(), handle.playerInteractManager.getGameMode()));
|
|
+ handle.updateAbilities();
|
|
+ connection.sendPacket(new net.minecraft.server.PacketPlayOutPosition(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch(), new HashSet<>(), 0));
|
|
+ net.minecraft.server.MinecraftServer.getServer().getPlayerList().updateClient(handle);
|
|
+
|
|
+ if (this.isOp()) {
|
|
+ this.setOp(false);
|
|
+ this.setOp(true);
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
|
|
public void removeDisconnectingPlayer(Player player) {
|
|
hiddenPlayers.remove(player.getUniqueId());
|
|
--
|
|
2.19.0
|
|
|