mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 20:21:51 +01:00
2f34301581
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: 7361a62e SPIGOT-5641: Add Block.getDrops(ItemStack, Entity) 1dc91b15 Add specific notes about what is not API 2b05ef88 #484: Allow statistics to be accessed for offline players CraftBukkit Changes:f7d6ad53
SPIGOT-5603: Use LootContext#lootingModifier in CraftLootTable5838285d
SPIGOT-5657: BlockPlaceEvent not cancelling for tripwire hooksf325b9be
SPIGOT-5641: Add Block.getDrops(ItemStack, Entity)e25a2272
Fix some formatting in CraftHumanEntity498540e0
Add Merchant slot delegateb2de47d5
SPIGOT-5621: Add missing container types for opening InventoryViewaa3a2f27
#645: Allow statistics to be accessed for offline players2122c0b1
#649: CraftBell should implement Bell
145 lines
6.9 KiB
Diff
145 lines
6.9 KiB
Diff
From cb49deb9821891dc3560fac122eed7e326d890b8 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 3fe13fe489..60dd8672b1 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
@@ -66,7 +66,7 @@ public abstract class EntityHuman extends EntityLiving {
|
|
protected int bO;
|
|
protected final float bP = 0.02F;
|
|
private int bS;
|
|
- private final GameProfile bT;
|
|
+ private GameProfile bT; public final void setProfile(final GameProfile profile) { this.bT = profile; } // Paper - OBFHELPER
|
|
private ItemStack bV;
|
|
private final ItemCooldown bW;
|
|
@Nullable
|
|
diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java
|
|
index 1b43f92164..1c4ac7bf7a 100644
|
|
--- a/src/main/java/net/minecraft/server/LoginListener.java
|
|
+++ b/src/main/java/net/minecraft/server/LoginListener.java
|
|
@@ -37,7 +37,7 @@ public class LoginListener implements PacketLoginInListener {
|
|
public final NetworkManager networkManager;
|
|
private LoginListener.EnumProtocolState g;
|
|
private int h;
|
|
- private GameProfile i;
|
|
+ private GameProfile i; private void setGameProfile(final GameProfile profile) { this.i = profile; } private GameProfile getGameProfile() { return this.i; } // Paper - OBFHELPER
|
|
private final String j;
|
|
private SecretKey loginKey;
|
|
private EntityPlayer l;
|
|
@@ -291,12 +291,12 @@ public class LoginListener implements PacketLoginInListener {
|
|
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 6d46fa23d2..ef7fff7545 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;
|
|
@@ -1176,8 +1178,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
hiddenPlayers.put(player.getUniqueId(), hidingPlugins);
|
|
|
|
// Remove this player from the hidden player's EntityTrackerEntry
|
|
- PlayerChunkMap tracker = ((WorldServer) entity.world).getChunkProvider().playerChunkMap;
|
|
+ // Paper start
|
|
EntityPlayer other = ((CraftPlayer) player).getHandle();
|
|
+ unregisterPlayer(other);
|
|
+ }
|
|
+ private void unregisterPlayer(EntityPlayer other) {
|
|
+ PlayerChunkMap tracker = ((WorldServer) entity.world).getChunkProvider().playerChunkMap;
|
|
+ // Paper end
|
|
PlayerChunkMap.EntityTracker entry = tracker.trackedEntities.get(other.getId());
|
|
if (entry != null) {
|
|
entry.clear(getHandle());
|
|
@@ -1218,8 +1225,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
}
|
|
hiddenPlayers.remove(player.getUniqueId());
|
|
|
|
- PlayerChunkMap tracker = ((WorldServer) entity.world).getChunkProvider().playerChunkMap;
|
|
+ // Paper start
|
|
EntityPlayer other = ((CraftPlayer) player).getHandle();
|
|
+ registerPlayer(other);
|
|
+ }
|
|
+ private void registerPlayer(EntityPlayer other) {
|
|
+ PlayerChunkMap tracker = ((WorldServer) entity.world).getChunkProvider().playerChunkMap;
|
|
+ // Paper end
|
|
|
|
getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, other));
|
|
|
|
@@ -1228,6 +1240,49 @@ 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));
|
|
+ if (!self.sentListPacket) {
|
|
+ return;
|
|
+ }
|
|
+ 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, net.minecraft.server.WorldData.c(handle.world.getWorldData().getSeed()), 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.25.1
|
|
|