geforkt von Mirrors/Paper
Remove legacy Chunk cache. Fixes BUKKIT-1400
Dieser Commit ist enthalten in:
Ursprung
119b5d18a5
Commit
0220c1ff74
@ -7,8 +7,11 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import org.bukkit.Bukkit; // CraftBukkit
|
|
||||||
import org.bukkit.craftbukkit.util.UnsafeList; // CraftBukkit
|
// CraftBukkit start
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.craftbukkit.util.UnsafeList;
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
public class Chunk {
|
public class Chunk {
|
||||||
|
|
||||||
@ -62,11 +65,7 @@ public class Chunk {
|
|||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
if (!(this instanceof EmptyChunk)) {
|
if (!(this instanceof EmptyChunk)) {
|
||||||
org.bukkit.craftbukkit.CraftWorld cworld = this.world.getWorld();
|
this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
|
||||||
this.bukkitChunk = (cworld == null) ? null : cworld.popPreservedChunk(i, j);
|
|
||||||
if (this.bukkitChunk == null) {
|
|
||||||
this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,8 +241,6 @@ public class ChunkProviderServer implements IChunkProvider {
|
|||||||
ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk);
|
ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk);
|
||||||
server.getPluginManager().callEvent(event);
|
server.getPluginManager().callEvent(event);
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
this.world.getWorld().preserveChunk((CraftChunk) chunk.bukkitChunk);
|
|
||||||
|
|
||||||
chunk.removeEntities();
|
chunk.removeEntities();
|
||||||
this.saveChunk(chunk);
|
this.saveChunk(chunk);
|
||||||
this.saveChunkNOP(chunk);
|
this.saveChunkNOP(chunk);
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
package org.bukkit.craftbukkit;
|
package org.bukkit.craftbukkit;
|
||||||
|
|
||||||
import com.google.common.collect.MapMaker;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.UUID;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
|
|
||||||
import org.bukkit.craftbukkit.entity.*;
|
import org.bukkit.craftbukkit.entity.*;
|
||||||
@ -10,14 +15,6 @@ import org.bukkit.craftbukkit.metadata.BlockMetadataStore;
|
|||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.concurrent.ConcurrentMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import net.minecraft.server.*;
|
import net.minecraft.server.*;
|
||||||
|
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
@ -52,7 +49,6 @@ public class CraftWorld implements World {
|
|||||||
private final WorldServer world;
|
private final WorldServer world;
|
||||||
private Environment environment;
|
private Environment environment;
|
||||||
private final CraftServer server = (CraftServer) Bukkit.getServer();
|
private final CraftServer server = (CraftServer) Bukkit.getServer();
|
||||||
private ConcurrentMap<Integer, CraftChunk> unloadedChunks = new MapMaker().weakValues().makeMap();
|
|
||||||
private final ChunkGenerator generator;
|
private final ChunkGenerator generator;
|
||||||
private final List<BlockPopulator> populators = new ArrayList<BlockPopulator>();
|
private final List<BlockPopulator> populators = new ArrayList<BlockPopulator>();
|
||||||
private final BlockMetadataStore blockMetadata = new BlockMetadataStore(this);
|
private final BlockMetadataStore blockMetadata = new BlockMetadataStore(this);
|
||||||
@ -69,15 +65,6 @@ public class CraftWorld implements World {
|
|||||||
environment = env;
|
environment = env;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void preserveChunk(CraftChunk chunk) {
|
|
||||||
chunk.breakLink();
|
|
||||||
unloadedChunks.put((chunk.getX() << 16) + chunk.getZ(), chunk);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Chunk popPreservedChunk(int x, int z) {
|
|
||||||
return unloadedChunks.remove((x << 16) + z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Block getBlockAt(int x, int y, int z) {
|
public Block getBlockAt(int x, int y, int z) {
|
||||||
return getChunkAt(x >> 4, z >> 4).getBlock(x & 0xF, y & 0xFF, z & 0xF);
|
return getChunkAt(x >> 4, z >> 4).getBlock(x & 0xF, y & 0xFF, z & 0xF);
|
||||||
}
|
}
|
||||||
@ -181,7 +168,6 @@ public class CraftWorld implements World {
|
|||||||
world.chunkProviderServer.saveChunkNOP(chunk);
|
world.chunkProviderServer.saveChunkNOP(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
preserveChunk((CraftChunk) chunk.bukkitChunk);
|
|
||||||
world.chunkProviderServer.unloadQueue.remove(x, z);
|
world.chunkProviderServer.unloadQueue.remove(x, z);
|
||||||
world.chunkProviderServer.chunks.remove(x, z);
|
world.chunkProviderServer.chunks.remove(x, z);
|
||||||
world.chunkProviderServer.chunkList.remove(chunk);
|
world.chunkProviderServer.chunkList.remove(chunk);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren