mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-27 22:38:11 +01:00
Fix more null pointer issues around deleted worlds - Fixes #3660
This commit is contained in:
parent
8736217b0f
commit
58d7a7ae1d
5 changed files with 18 additions and 85 deletions
|
@ -61,9 +61,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
|
|
||||||
+ // Paper start - correctly register player BEFORE PlayerJoinEvent, so the entity is valid and doesn't require tick delay hacks
|
+ // Paper start - correctly register player BEFORE PlayerJoinEvent, so the entity is valid and doesn't require tick delay hacks
|
||||||
+ entityplayer.supressTrackerForLogin = true;
|
+ entityplayer.supressTrackerForLogin = true;
|
||||||
+ worldserver.addPlayerJoin(entityplayer);
|
+ worldserver1.addPlayerJoin(entityplayer);
|
||||||
+ this.server.getBossBattleCustomData().a(entityplayer); // see commented out section below worldserver.addPlayerJoin(entityplayer);
|
+ this.server.getBossBattleCustomData().a(entityplayer); // see commented out section below worldserver.addPlayerJoin(entityplayer);
|
||||||
+ mountSavedVehicle(entityplayer, worldserver, nbttagcompound);
|
+ mountSavedVehicle(entityplayer, worldserver1, nbttagcompound);
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(cserver.getPlayer(entityplayer), joinMessage);
|
PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(cserver.getPlayer(entityplayer), joinMessage);
|
||||||
|
@ -82,9 +82,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // Paper start - move vehicle into method so it can be called above - short circuit around that code
|
+ // Paper start - move vehicle into method so it can be called above - short circuit around that code
|
||||||
+ onPlayerJoinFinish(entityplayer, worldserver, s1);
|
+ onPlayerJoinFinish(entityplayer, worldserver1, s1);
|
||||||
+ }
|
+ }
|
||||||
+ private void mountSavedVehicle(EntityPlayer entityplayer, WorldServer worldserver, NBTTagCompound nbttagcompound) {
|
+ private void mountSavedVehicle(EntityPlayer entityplayer, WorldServer worldserver1, NBTTagCompound nbttagcompound) {
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
if (nbttagcompound != null && nbttagcompound.hasKeyOfType("RootVehicle", 10)) {
|
if (nbttagcompound != null && nbttagcompound.hasKeyOfType("RootVehicle", 10)) {
|
||||||
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle");
|
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle");
|
||||||
|
|
|
@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
playerconnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex));
|
playerconnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex));
|
||||||
playerconnection.sendPacket(new PacketPlayOutRecipeUpdate(this.server.getCraftingManager().b()));
|
playerconnection.sendPacket(new PacketPlayOutRecipeUpdate(this.server.getCraftingManager().b()));
|
||||||
playerconnection.sendPacket(new PacketPlayOutTags(this.server.getTagRegistry()));
|
playerconnection.sendPacket(new PacketPlayOutTags(this.server.getTagRegistry()));
|
||||||
+ playerconnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, (byte) (worldserver.getGameRules().getBoolean(GameRules.REDUCED_DEBUG_INFO) ? 22 : 23))); // Paper - fix this rule not being initialized on the client
|
+ playerconnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, (byte) (worldserver1.getGameRules().getBoolean(GameRules.REDUCED_DEBUG_INFO) ? 22 : 23))); // Paper - fix this rule not being initialized on the client
|
||||||
this.d(entityplayer);
|
this.d(entityplayer);
|
||||||
entityplayer.getStatisticManager().c();
|
entityplayer.getStatisticManager().c();
|
||||||
entityplayer.B().a(entityplayer);
|
entityplayer.B().a(entityplayer);
|
||||||
|
|
|
@ -1149,23 +1149,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
||||||
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
||||||
final ChunkCoordIntPair pos = new ChunkCoordIntPair(chunkX, chunkZ);
|
final ChunkCoordIntPair pos = new ChunkCoordIntPair(chunkX, chunkZ);
|
||||||
PlayerChunkMap playerChunkMap = finalWorldserver.getChunkProvider().playerChunkMap;
|
PlayerChunkMap playerChunkMap = worldserver1.getChunkProvider().playerChunkMap;
|
||||||
playerChunkMap.chunkDistanceManager.addTicketAtLevel(TicketType.LOGIN, pos, 31, pos.pair());
|
playerChunkMap.chunkDistanceManager.addTicketAtLevel(TicketType.LOGIN, pos, 31, pos.pair());
|
||||||
- worldserver.getChunkProvider().tickDistanceManager();
|
- worldserver1.getChunkProvider().tickDistanceManager();
|
||||||
- worldserver.getChunkProvider().getChunkAtAsynchronously(chunkX, chunkZ, true, true).thenApply(chunk -> {
|
- worldserver1.getChunkProvider().getChunkAtAsynchronously(chunkX, chunkZ, true, true).thenApply(chunk -> {
|
||||||
+ worldserver.getChunkProvider().markAreaHighPriority(pos, 28, 3);
|
+ worldserver1.getChunkProvider().markAreaHighPriority(pos, 28, 3);
|
||||||
+ worldserver.getChunkProvider().getChunkAtAsynchronously(chunkX, chunkZ, true, false).thenApply(chunk -> {
|
+ worldserver1.getChunkProvider().getChunkAtAsynchronously(chunkX, chunkZ, true, false).thenApply(chunk -> {
|
||||||
PlayerChunk updatingChunk = playerChunkMap.getUpdatingChunk(pos.pair());
|
PlayerChunk updatingChunk = playerChunkMap.getUpdatingChunk(pos.pair());
|
||||||
if (updatingChunk != null) {
|
if (updatingChunk != null) {
|
||||||
return updatingChunk.getEntityTickingFuture();
|
return updatingChunk.getEntityTickingFuture();
|
||||||
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
|
||||||
entityplayer, finalWorldserver, finalWorldserver1, networkmanager, playerconnection,
|
|
||||||
nbttagcompound, networkmanager.getSocketAddress().toString(), lastKnownName
|
|
||||||
);
|
|
||||||
- //playerChunkMap.chunkDistanceManager.removeTicketAtLevel(TicketType.LOGIN, pos, 31, pos.pair());
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
||||||
SocketAddress socketaddress = loginlistener.networkManager.getSocketAddress();
|
SocketAddress socketaddress = loginlistener.networkManager.getSocketAddress();
|
||||||
|
|
||||||
|
|
|
@ -113,14 +113,6 @@ diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/PlayerList.java
|
--- a/src/main/java/net/minecraft/server/PlayerList.java
|
||||||
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
||||||
@@ -0,0 +0,0 @@ import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
+import java.util.concurrent.CompletableFuture;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
||||||
private static final SimpleDateFormat g = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
|
private static final SimpleDateFormat g = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
|
||||||
private final MinecraftServer server;
|
private final MinecraftServer server;
|
||||||
|
@ -161,28 +153,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
this.sendScoreboard(worldserver1.getScoreboard(), entityplayer);
|
this.sendScoreboard(worldserver1.getScoreboard(), entityplayer);
|
||||||
this.server.invalidatePingSample();
|
this.server.invalidatePingSample();
|
||||||
+ // Paper start - async load spawn in chunk
|
+ // Paper start - async load spawn in chunk
|
||||||
+ WorldServer finalWorldserver = worldserver;
|
+ WorldServer finalWorldserver = worldserver1;
|
||||||
+ WorldServer finalWorldserver1 = worldserver1;
|
|
||||||
+ int chunkX = loc.getBlockX() >> 4;
|
+ int chunkX = loc.getBlockX() >> 4;
|
||||||
+ int chunkZ = loc.getBlockZ() >> 4;
|
+ int chunkZ = loc.getBlockZ() >> 4;
|
||||||
+ final ChunkCoordIntPair pos = new ChunkCoordIntPair(chunkX, chunkZ);
|
+ final ChunkCoordIntPair pos = new ChunkCoordIntPair(chunkX, chunkZ);
|
||||||
+ PlayerChunkMap playerChunkMap = finalWorldserver.getChunkProvider().playerChunkMap;
|
+ PlayerChunkMap playerChunkMap = worldserver1.getChunkProvider().playerChunkMap;
|
||||||
+ playerChunkMap.chunkDistanceManager.addTicketAtLevel(TicketType.LOGIN, pos, 31, pos.pair());
|
+ playerChunkMap.chunkDistanceManager.addTicketAtLevel(TicketType.LOGIN, pos, 31, pos.pair());
|
||||||
+ worldserver.getChunkProvider().tickDistanceManager();
|
+ worldserver1.getChunkProvider().tickDistanceManager();
|
||||||
+ worldserver.getChunkProvider().getChunkAtAsynchronously(chunkX, chunkZ, true, true).thenApply(chunk -> {
|
+ worldserver1.getChunkProvider().getChunkAtAsynchronously(chunkX, chunkZ, true, true).thenApply(chunk -> {
|
||||||
+ PlayerChunk updatingChunk = playerChunkMap.getUpdatingChunk(pos.pair());
|
+ PlayerChunk updatingChunk = playerChunkMap.getUpdatingChunk(pos.pair());
|
||||||
+ if (updatingChunk != null) {
|
+ if (updatingChunk != null) {
|
||||||
+ return updatingChunk.getEntityTickingFuture();
|
+ return updatingChunk.getEntityTickingFuture();
|
||||||
+ } else {
|
+ } else {
|
||||||
+ return CompletableFuture.completedFuture(chunk);
|
+ return java.util.concurrent.CompletableFuture.completedFuture(chunk);
|
||||||
+ }
|
+ }
|
||||||
+ }).thenAccept(chunk -> {
|
+ }).thenAccept(chunk -> {
|
||||||
+ playerconnection.playerJoinReady = () -> {
|
+ playerconnection.playerJoinReady = () -> {
|
||||||
+ postChunkLoadJoin(
|
+ postChunkLoadJoin(
|
||||||
+ entityplayer, finalWorldserver, finalWorldserver1, networkmanager, playerconnection,
|
+ entityplayer, finalWorldserver, networkmanager, playerconnection,
|
||||||
+ nbttagcompound, networkmanager.getSocketAddress().toString(), lastKnownName
|
+ nbttagcompound, networkmanager.getSocketAddress().toString(), lastKnownName
|
||||||
+ );
|
+ );
|
||||||
+ //playerChunkMap.chunkDistanceManager.removeTicketAtLevel(TicketType.LOGIN, pos, 31, pos.pair());
|
|
||||||
+ };
|
+ };
|
||||||
+ });
|
+ });
|
||||||
+ }
|
+ }
|
||||||
|
@ -200,7 +190,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ });
|
+ });
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private void postChunkLoadJoin(EntityPlayer entityplayer, WorldServer worldserver, WorldServer worldserver1, NetworkManager networkmanager, PlayerConnection playerconnection, NBTTagCompound nbttagcompound, String s1, String s) {
|
+ private void postChunkLoadJoin(EntityPlayer entityplayer, WorldServer worldserver1, NetworkManager networkmanager, PlayerConnection playerconnection, NBTTagCompound nbttagcompound, String s1, String s) {
|
||||||
+ pendingPlayers.remove(entityplayer.getUniqueID(), entityplayer);
|
+ pendingPlayers.remove(entityplayer.getUniqueID(), entityplayer);
|
||||||
+ if (!networkmanager.isConnected()) {
|
+ if (!networkmanager.isConnected()) {
|
||||||
+ return;
|
+ return;
|
||||||
|
@ -211,35 +201,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
|
|
||||||
if (entityplayer.getProfile().getName().equalsIgnoreCase(s)) {
|
if (entityplayer.getProfile().getName().equalsIgnoreCase(s)) {
|
||||||
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
||||||
entityplayer.supressTrackerForLogin = true;
|
|
||||||
worldserver.addPlayerJoin(entityplayer);
|
|
||||||
this.server.getBossBattleCustomData().a(entityplayer); // see commented out section below worldserver.addPlayerJoin(entityplayer);
|
|
||||||
- mountSavedVehicle(entityplayer, worldserver, nbttagcompound);
|
|
||||||
+ mountSavedVehicle(entityplayer, worldserver, worldserver1, nbttagcompound);
|
|
||||||
// Paper end
|
|
||||||
// CraftBukkit start
|
|
||||||
PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(cserver.getPlayer(entityplayer), joinMessage);
|
|
||||||
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
|
||||||
}
|
|
||||||
entityplayer.sentListPacket = true;
|
|
||||||
entityplayer.supressTrackerForLogin = false; // Paper
|
|
||||||
- ((WorldServer)entityplayer.world).getChunkProvider().playerChunkMap.addEntity(entityplayer); // Paper - track entity now
|
|
||||||
// CraftBukkit end
|
|
||||||
|
|
||||||
entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityplayer.getId(), entityplayer.datawatcher, true)); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn
|
|
||||||
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Paper start - move vehicle into method so it can be called above - short circuit around that code
|
|
||||||
+ ((WorldServer)entityplayer.world).getChunkProvider().playerChunkMap.addEntity(entityplayer); // track entity now
|
|
||||||
onPlayerJoinFinish(entityplayer, worldserver, s1);
|
|
||||||
}
|
|
||||||
- private void mountSavedVehicle(EntityPlayer entityplayer, WorldServer worldserver, NBTTagCompound nbttagcompound) {
|
|
||||||
+ private void mountSavedVehicle(EntityPlayer entityplayer, WorldServer worldserver, WorldServer worldserver1, NBTTagCompound nbttagcompound) {
|
|
||||||
// Paper end
|
|
||||||
if (nbttagcompound != null && nbttagcompound.hasKeyOfType("RootVehicle", 10)) {
|
|
||||||
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle");
|
|
||||||
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
|
||||||
|
|
||||||
protected void savePlayerFile(EntityPlayer entityplayer) {
|
protected void savePlayerFile(EntityPlayer entityplayer) {
|
||||||
if (!entityplayer.getBukkitEntity().isPersistent()) return; // CraftBukkit
|
if (!entityplayer.getBukkitEntity().isPersistent()) return; // CraftBukkit
|
||||||
|
|
|
@ -84,7 +84,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ private static boolean canSendImmediate(NetworkManager networkManager, Packet<?> packet) {
|
+ private static boolean canSendImmediate(NetworkManager networkManager, Packet<?> packet) {
|
||||||
+ return networkManager.isPending || networkManager.protocol != EnumProtocol.PLAY || networkManager.queueImmunity ||
|
+ return networkManager.isPending || networkManager.protocol != EnumProtocol.PLAY ||
|
||||||
+ packet instanceof PacketPlayOutKeepAlive ||
|
+ packet instanceof PacketPlayOutKeepAlive ||
|
||||||
+ packet instanceof PacketPlayOutChat ||
|
+ packet instanceof PacketPlayOutChat ||
|
||||||
+ packet instanceof PacketPlayOutTabComplete;
|
+ packet instanceof PacketPlayOutTabComplete;
|
||||||
|
@ -337,26 +337,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
default boolean packetTooLarge(NetworkManager manager) {
|
default boolean packetTooLarge(NetworkManager manager) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/PlayerList.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
|
||||||
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
|
||||||
entityplayer.playerInteractManager.a((WorldServer) entityplayer.world);
|
|
||||||
entityplayer.setPositionRaw(loc.getX(), loc.getY(), loc.getZ()); // Paper - set raw so we aren't fully joined to the world (not added to chunk or world)
|
|
||||||
entityplayer.setYawPitch(loc.getYaw(), loc.getPitch());
|
|
||||||
+ networkmanager.queueImmunity = true; // Paper
|
|
||||||
// Spigot end
|
|
||||||
|
|
||||||
// CraftBukkit - Moved message to after join
|
|
||||||
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
|
||||||
playerconnection.sendPacket(new PacketPlayOutRecipeUpdate(this.server.getCraftingManager().b()));
|
|
||||||
playerconnection.sendPacket(new PacketPlayOutTags(this.server.getTagRegistry()));
|
|
||||||
playerconnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, (byte) (worldserver.getGameRules().getBoolean(GameRules.REDUCED_DEBUG_INFO) ? 22 : 23))); // Paper - fix this rule not being initialized on the client
|
|
||||||
+ networkmanager.queueImmunity = false; // Paper
|
|
||||||
this.d(entityplayer);
|
|
||||||
entityplayer.getStatisticManager().c();
|
|
||||||
entityplayer.B().a(entityplayer);
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/ServerConnection.java b/src/main/java/net/minecraft/server/ServerConnection.java
|
diff --git a/src/main/java/net/minecraft/server/ServerConnection.java b/src/main/java/net/minecraft/server/ServerConnection.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/ServerConnection.java
|
--- a/src/main/java/net/minecraft/server/ServerConnection.java
|
||||||
|
|
Loading…
Add table
Reference in a new issue