Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-16 13:00:06 +01:00
Fix issues with chunk saving. Fixes BUKKIT-2158, BUKKIT-2018 and BUKKIT-2229
Dieser Commit ist enthalten in:
Ursprung
cacfc71b46
Commit
5254993510
@ -70,6 +70,7 @@ public class Chunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public org.bukkit.Chunk bukkitChunk;
|
public org.bukkit.Chunk bukkitChunk;
|
||||||
|
public boolean mustSave;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
public Chunk(World world, byte[] abyte, int i, int j) {
|
public Chunk(World world, byte[] abyte, int i, int j) {
|
||||||
|
@ -37,7 +37,7 @@ public class ChunkProviderServer implements IChunkProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isChunkLoaded(int i, int j) {
|
public boolean isChunkLoaded(int i, int j) {
|
||||||
return !this.unloadQueue.containsKey(i, j) && this.chunks.containsKey(i, j); // CraftBukkit
|
return this.chunks.containsKey(i, j); // CraftBukkit
|
||||||
}
|
}
|
||||||
|
|
||||||
public void queueUnload(int i, int j) {
|
public void queueUnload(int i, int j) {
|
||||||
@ -47,11 +47,25 @@ public class ChunkProviderServer implements IChunkProvider {
|
|||||||
int l = j * 16 + 8 - chunkcoordinates.z;
|
int l = j * 16 + 8 - chunkcoordinates.z;
|
||||||
short short1 = 128;
|
short short1 = 128;
|
||||||
|
|
||||||
if (k < -short1 || k > short1 || l < -short1 || l > short1 || !(this.world.keepSpawnInMemory)) { // CraftBukkit - added 'this.world.keepSpawnInMemory'
|
// CraftBukkit start
|
||||||
this.unloadQueue.add(i, j); // CraftBukkit
|
if (k < -short1 || k > short1 || l < -short1 || l > short1 || !(this.world.keepSpawnInMemory)) { // Added 'this.world.keepSpawnInMemory'
|
||||||
|
this.unloadQueue.add(i, j);
|
||||||
|
|
||||||
|
Chunk c = this.chunks.get(i, j);
|
||||||
|
if (c != null) {
|
||||||
|
c.mustSave = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
} else {
|
} else {
|
||||||
this.unloadQueue.add(i, j); // CraftBukkit
|
// CraftBukkit start
|
||||||
|
this.unloadQueue.add(i, j);
|
||||||
|
|
||||||
|
Chunk c = this.chunks.get(i, j);
|
||||||
|
if (c != null) {
|
||||||
|
c.mustSave = true;
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +69,15 @@ public class PlayerManager {
|
|||||||
|
|
||||||
return playerinstance;
|
return playerinstance;
|
||||||
}
|
}
|
||||||
|
// CraftBukkit start
|
||||||
|
public final boolean isChunkInUse(int x, int z) {
|
||||||
|
PlayerInstance pi = a(x, z, false);
|
||||||
|
if (pi != null) {
|
||||||
|
return (PlayerInstance.b(pi).size() > 0);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
public void flagDirty(int i, int j, int k) {
|
public void flagDirty(int i, int j, int k) {
|
||||||
int l = i >> 4;
|
int l = i >> 4;
|
||||||
|
@ -161,9 +161,11 @@ public class CraftWorld implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
net.minecraft.server.Chunk chunk = world.chunkProviderServer.getOrCreateChunk(x, z);
|
net.minecraft.server.Chunk chunk = world.chunkProviderServer.getOrCreateChunk(x, z);
|
||||||
|
if (chunk.mustSave) { // If chunk had previously been queued to save, must do save to avoid loss of that data
|
||||||
|
save = true;
|
||||||
|
}
|
||||||
|
chunk.removeEntities(); // Always remove entities - even if discarding, need to get them out of world table
|
||||||
if (save && !(chunk instanceof EmptyChunk)) {
|
if (save && !(chunk instanceof EmptyChunk)) {
|
||||||
chunk.removeEntities();
|
|
||||||
world.chunkProviderServer.saveChunk(chunk);
|
world.chunkProviderServer.saveChunk(chunk);
|
||||||
world.chunkProviderServer.saveChunkNOP(chunk);
|
world.chunkProviderServer.saveChunkNOP(chunk);
|
||||||
}
|
}
|
||||||
@ -216,22 +218,7 @@ public class CraftWorld implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isChunkInUse(int x, int z) {
|
public boolean isChunkInUse(int x, int z) {
|
||||||
Player[] players = server.getOnlinePlayers();
|
return world.getPlayerManager().isChunkInUse(x, z);
|
||||||
|
|
||||||
for (Player player : players) {
|
|
||||||
Location loc = player.getLocation();
|
|
||||||
if (loc.getWorld() != world.chunkProviderServer.world.getWorld()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the chunk is within 256 blocks of a player, refuse to accept the unload request
|
|
||||||
// This is larger than the distance of loaded chunks that actually surround a player
|
|
||||||
// The player is the center of a 21x21 chunk grid, so the edge is 10 chunks (160 blocks) away from the player
|
|
||||||
if (Math.abs(loc.getBlockX() - (x << 4)) <= 256 && Math.abs(loc.getBlockZ() - (z << 4)) <= 256) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean loadChunk(int x, int z, boolean generate) {
|
public boolean loadChunk(int x, int z, boolean generate) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren