Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
ChunkPos spawnChunk = ChunkPos.containing(BlockPos.containing(spawnPosition));
this.chunkLoadCounter
.track(
@@ -172,14 +_,47 @@
@@ -172,14 +_,48 @@
public ServerPlayer spawn(final Connection connection, final CommonListenerCookie cookie) {
ChunkPos spawnChunk = ChunkPos.containing(BlockPos.containing(this.spawnPosition));
this.spawnLevel.waitForEntities(spawnChunk, 3);
Expand All @@ -174,6 +174,7 @@
+ player = new ServerPlayer(PrepareSpawnTask.this.server, this.spawnLevel, cookie.gameProfile(), cookie.clientInformation());
+ }
+ // Paper end - configuration api - possibly use legacy saved server player instance
+ PrepareSpawnTask.this.listener.paperConnection.applyPendingEntityId(player); // Paper - internal entity id api - possibly override player network id if plugins used internal API to configure it.

try (ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(player.problemPath(), PrepareSpawnTask.LOGGER)) {
Optional<ValueInput> input = PrepareSpawnTask.this.server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import net.minecraft.network.protocol.configuration.ClientboundResetChatPacket;
import net.minecraft.resources.Identifier;
import net.minecraft.server.level.ClientInformation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ConfigurationTask;
import net.minecraft.server.network.ServerConfigurationPacketListenerImpl;
import org.bukkit.plugin.Plugin;
Expand All @@ -40,11 +41,33 @@
public class PaperPlayerConfigurationConnection extends PaperCommonConnection<ServerConfigurationPacketListenerImpl> implements PlayerConfigurationConnection, Audience, PluginMessageBridgeImpl {

private @Nullable Pointers adventurePointers;
private @Nullable Integer internalPluginDefinedEntityId;

public PaperPlayerConfigurationConnection(final ServerConfigurationPacketListenerImpl packetListener) {
super(packetListener);
}

/**
* Internal only API that allows plugins to assign a specific entity network id to the player instance once
* configuration phase finishes.
* <p>
* It is fully up to the calling plugin to ensure that no other entity has or will have the passed entity id.
* Additionally, as with any other internal API, no backwards compatibility is guaranteed across versions or builds.
* Use at own risk.
*
* @param entityId the network entity id to assign to the player.
*/
public void setInternalPluginDefinedEntityId(final int entityId) {
this.internalPluginDefinedEntityId = entityId;
}

// Part of the above internal API.
public void applyPendingEntityId(final ServerPlayer player) {
if (this.internalPluginDefinedEntityId != null) {
player.setId(this.internalPluginDefinedEntityId);
}
}

@Override
public ClientInformation getClientInformation() {
return this.packetListener.clientInformation;
Expand Down
Loading