summaryrefslogtreecommitdiffstats
path: root/src/main/java/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net')
-rw-r--r--src/main/java/net/minecraft/server/PlayerChunk.java50
1 files changed, 40 insertions, 10 deletions
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
index 93153028..db688eca 100644
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
@@ -3,6 +3,11 @@ package net.minecraft.server;
import java.util.ArrayList;
import java.util.List;
+// CraftBukkit start
+import org.bukkit.craftbukkit.chunkio.ChunkIOExecutor;
+import java.util.HashMap;
+// CraftBukkit end
+
class PlayerChunk {
private final List b;
@@ -12,20 +17,22 @@ class PlayerChunk {
private int f;
private long g;
final PlayerChunkMap playerChunkMap;
- private boolean loaded = false; // CraftBukkit
+ // CraftBukkit start
+ private final HashMap<EntityPlayer, Runnable> players = new HashMap<EntityPlayer, Runnable>();
+ private boolean loaded = false;
+ private Runnable loadedRunnable = new Runnable() {
+ public void run() {
+ PlayerChunk.this.loaded = true;
+ }
+ };
+ // CraftBukkit end
public PlayerChunk(PlayerChunkMap playerchunkmap, int i, int j) {
this.playerChunkMap = playerchunkmap;
this.b = new ArrayList();
this.dirtyBlocks = new short[64];
this.location = new ChunkCoordIntPair(i, j);
- // CraftBukkit start
- playerchunkmap.a().chunkProviderServer.getChunkAt(i, j, new Runnable() {
- public void run() {
- PlayerChunk.this.loaded = true;
- }
- });
- // CraftBukkit end
+ playerchunkmap.a().chunkProviderServer.getChunkAt(i, j, this.loadedRunnable); // CraftBukkit
}
public void a(final EntityPlayer entityplayer) { // CraftBukkit - added final to argument
@@ -38,27 +45,50 @@ class PlayerChunk {
this.b.add(entityplayer);
// CraftBukkit start
+ Runnable playerRunnable;
if (this.loaded) {
+ playerRunnable = null;
entityplayer.chunkCoordIntPairQueue.add(this.location);
} else {
- this.playerChunkMap.a().chunkProviderServer.getChunkAt(this.location.x, this.location.z, new Runnable() {
+ playerRunnable = new Runnable() {
public void run() {
entityplayer.chunkCoordIntPairQueue.add(PlayerChunk.this.location);
}
- });
+ };
+ this.playerChunkMap.a().chunkProviderServer.getChunkAt(this.location.x, this.location.z, playerRunnable);
}
+
+ this.players.put(entityplayer, playerRunnable);
// CraftBukkit end
}
}
public void b(EntityPlayer entityplayer) {
if (this.b.contains(entityplayer)) {
+ // CraftBukkit start - If we haven't loaded yet don't load the chunk just so we can clean it up
+ if (!this.loaded) {
+ ChunkIOExecutor.dropQueuedChunkLoad(this.playerChunkMap.a(), this.location.x, this.location.z, this.players.get(entityplayer));
+ this.b.remove(entityplayer);
+ this.players.remove(entityplayer);
+
+ if (this.b.isEmpty()) {
+ ChunkIOExecutor.dropQueuedChunkLoad(this.playerChunkMap.a(), this.location.x, this.location.z, this.loadedRunnable);
+ long i = (long) this.location.x + 2147483647L | (long) this.location.z + 2147483647L << 32;
+ PlayerChunkMap.b(this.playerChunkMap).remove(i);
+ PlayerChunkMap.c(this.playerChunkMap).remove(this);
+ }
+
+ return;
+ }
+ // CraftBukkit end
+
Chunk chunk = PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z);
if (chunk.k()) {
entityplayer.playerConnection.sendPacket(new PacketPlayOutMapChunk(chunk, true, 0));
}
+ this.players.remove(entityplayer); // CraftBukkit
this.b.remove(entityplayer);
entityplayer.chunkCoordIntPairQueue.remove(this.location);
if (this.b.isEmpty()) {