geforkt von Mirrors/Paper
ebb727e629
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: 810cb078 Add hideEntity / showEntity API CraftBukkit Changes: 04f8e7e2 SPIGOT-6814: (Chunk) PersistentData is lost after restart 37fd1917 Add hideEntity / showEntity API 7e2214da Move checkstyle to slightly later compile phase 45c3f826 SPIGOT-6816: Fix ChunkSnapshot#getBiome Spigot Changes: b11f318f Rebuild patches 622b2310 SPIGOT-6811: Fix mob spawning mismatch 2b2a3d56 Rebuild patches
121 Zeilen
6.5 KiB
Diff
121 Zeilen
6.5 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 00ef714294b6cce5fec7613eed4ba228a48e3e11..67b300574655854249c1f7440f56a6e8f0fad351 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
@@ -341,12 +341,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/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
index 853d6b7e329240b701854256419bea0d4fc4bd67..a440c8b56e21abab7774486d35dc64c454aa1a2b 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.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.saveddata.maps.MapDecoration;
|
|
import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
|
|
@@ -1357,8 +1358,13 @@ 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);
|
|
+ }
|
|
+ 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());
|
|
@@ -1407,8 +1413,13 @@ 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);
|
|
+ }
|
|
+ private void registerEntity(Entity other) {
|
|
+ ChunkMap tracker = ((ServerLevel) this.getHandle().level).getChunkSource().chunkMap;
|
|
+ // Paper end
|
|
|
|
if (other instanceof ServerPlayer) {
|
|
ServerPlayer otherPlayer = (ServerPlayer) other;
|
|
@@ -1420,6 +1431,50 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
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();
|
|
+ }
|
|
+
|
|
+ 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.hiddenEntities.remove(player.getUniqueId());
|