mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 13:06:02 +01:00
01a13871de
Patch documentation to come Issues with the old system that are fixed now: - World generation does not scale with cpu cores effectively. - Relies on the main thread for scheduling and maintaining chunk state, dropping chunk load/generate rates at lower tps. - Unreliable prioritisation of chunk gen/load calls that block the main thread. - Shutdown logic is utterly unreliable, as it has to wait for all chunks to unload - is it guaranteed that the chunk system is in a state on shutdown that it can reliably do this? Watchdog shutdown also typically failed due to thread checks, which is now resolved. - Saving of data is not unified (i.e can save chunk data without saving entity data, poses problems for desync if shutdown is really abnormal. - Entities are not loaded with chunks. This caused quite a bit of headache for Chunk#getEntities API, but now the new chunk system loads entities with chunks so that they are ready whenever the chunk loads in. Effectively brings the behavior back to 1.16 era, but still storing entities in their own separate regionfiles. The above list is not complete. The patch documentation will complete it. New chunk system hard relies on starlight and dataconverter, and most importantly the new concurrent utilities in ConcurrentUtil. Some of the old async chunk i/o interface (i.e the old file io thread reroutes _some_ calls to the new file io thread) is kept for plugin compat reasons. It will be removed in the next major version of minecraft. The old legacy chunk system patches have been moved to the removed folder in case we need them again.
146 lines
7.5 KiB
Diff
146 lines
7.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 9a7fe61d7de80eaf044c202e1ed13d9e4b59622a..ef09f5f42a89f767060f015af27269ad496d08c7 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
@@ -370,11 +370,11 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
|
|
final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server;
|
|
|
|
// Paper start
|
|
- com.destroystokyo.paper.profile.PlayerProfile profile = org.bukkit.Bukkit.createProfile(uniqueId, playerName);
|
|
+ com.destroystokyo.paper.profile.PlayerProfile profile = com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitMirror(ServerLoginPacketListenerImpl.this.gameProfile);
|
|
AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId, profile);
|
|
server.getPluginManager().callEvent(asyncEvent);
|
|
profile = asyncEvent.getPlayerProfile();
|
|
- profile.complete();
|
|
+ profile.complete(true); // Paper - setPlayerProfileAPI
|
|
gameProfile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile);
|
|
playerName = gameProfile.getName();
|
|
uniqueId = gameProfile.getId();
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
index 9f959cbb6e8685dacccec1d8df68d4a8a94ab81e..aadc01662c07ab99466babc8f5ed5b3bef2c1a8e 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -79,6 +79,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.border.BorderChangeListener;
|
|
import net.minecraft.world.level.saveddata.maps.MapDecoration;
|
|
@@ -282,11 +283,6 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
return server.getPlayer(getUniqueId()) != null;
|
|
}
|
|
|
|
- @Override
|
|
- public PlayerProfile getPlayerProfile() {
|
|
- return new CraftPlayerProfile(this.getProfile());
|
|
- }
|
|
-
|
|
@Override
|
|
public InetSocketAddress getAddress() {
|
|
if (this.getHandle().connection == null) return null;
|
|
@@ -1577,8 +1573,15 @@ 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);
|
|
+
|
|
+ server.getPluginManager().callEvent(new PlayerHideEntityEvent(this, entity));
|
|
+ }
|
|
+ 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());
|
|
@@ -1591,8 +1594,6 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
this.getHandle().connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER, otherPlayer));
|
|
}
|
|
}
|
|
-
|
|
- server.getPluginManager().callEvent(new PlayerHideEntityEvent(this, entity));
|
|
}
|
|
|
|
@Override
|
|
@@ -1629,8 +1630,15 @@ 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);
|
|
+
|
|
+ server.getPluginManager().callEvent(new PlayerShowEntityEvent(this, entity));
|
|
+ }
|
|
+ private void registerEntity(Entity other) {
|
|
+ ChunkMap tracker = ((ServerLevel) this.getHandle().level).getChunkSource().chunkMap;
|
|
+ // Paper end
|
|
|
|
if (other instanceof ServerPlayer) {
|
|
ServerPlayer otherPlayer = (ServerPlayer) other;
|
|
@@ -1641,9 +1649,51 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
if (entry != null && !entry.seenBy.contains(this.getHandle().connection)) {
|
|
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();
|
|
+ }
|
|
|
|
- server.getPluginManager().callEvent(new PlayerShowEntityEvent(this, entity));
|
|
+ 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.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), handle.gameMode.getGameModeForPlayer(), handle.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true, this.getHandle().getLastDeathLocation()));
|
|
+ handle.onUpdateAbilities();
|
|
+ connection.internalTeleport(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch(), java.util.Collections.emptySet(), false);
|
|
+ net.minecraft.server.MinecraftServer.getServer().getPlayerList().sendAllPlayerInfo(handle);
|
|
+
|
|
+ if (this.isOp()) {
|
|
+ this.setOp(false);
|
|
+ this.setOp(true);
|
|
+ }
|
|
}
|
|
+ // Paper end
|
|
|
|
public void onEntityRemove(Entity entity) {
|
|
this.hiddenEntities.remove(entity.getUUID());
|