SPIGOT-2014: Respect the spectatorsGenerateChunks gamerule
Dieser Commit ist enthalten in:
Ursprung
b70058afa2
Commit
b5a4d07141
@ -103,7 +103,7 @@
|
||||
return chunk;
|
||||
}
|
||||
|
||||
@@ -61,20 +91,67 @@
|
||||
@@ -61,20 +91,71 @@
|
||||
Chunk chunk = this.getLoadedChunkAt(i, j);
|
||||
|
||||
if (chunk == null) {
|
||||
@ -137,6 +137,10 @@
|
||||
+ }
|
||||
+
|
||||
+ public Chunk getChunkAt(int i, int j, Runnable runnable) {
|
||||
+ return getChunkAt(i, j, runnable, true);
|
||||
+ }
|
||||
+
|
||||
+ public Chunk getChunkAt(int i, int j, Runnable runnable, boolean generate) {
|
||||
+ unloadQueue.remove(i, j);
|
||||
+ Chunk chunk = chunks.get(LongHash.toLong(i, j));
|
||||
+ ChunkRegionLoader loader = null;
|
||||
@ -153,7 +157,7 @@
|
||||
+ } else {
|
||||
+ chunk = ChunkIOExecutor.syncChunkLoad(world, loader, this, i, j);
|
||||
+ }
|
||||
+ } else if (chunk == null) {
|
||||
+ } else if (chunk == null && generate) {
|
||||
+ chunk = originalGetChunkAt(i, j);
|
||||
+ }
|
||||
+
|
||||
@ -173,7 +177,7 @@
|
||||
|
||||
if (chunk == null) {
|
||||
long k = ChunkCoordIntPair.a(i, j);
|
||||
@@ -92,11 +169,38 @@
|
||||
@@ -92,11 +173,38 @@
|
||||
crashreportsystemdetails.a("Generator", (Object) this.chunkGenerator);
|
||||
throw new ReportedException(crashreport);
|
||||
}
|
||||
@ -214,7 +218,7 @@
|
||||
chunk.loadNearby(this, this.chunkGenerator);
|
||||
}
|
||||
|
||||
@@ -142,10 +246,12 @@
|
||||
@@ -142,10 +250,12 @@
|
||||
|
||||
public boolean a(boolean flag) {
|
||||
int i = 0;
|
||||
@ -230,7 +234,7 @@
|
||||
|
||||
if (flag) {
|
||||
this.saveChunkNOP(chunk);
|
||||
@@ -170,22 +276,43 @@
|
||||
@@ -170,22 +280,43 @@
|
||||
|
||||
public boolean unloadChunks() {
|
||||
if (!this.world.savingDisabled) {
|
||||
@ -281,7 +285,7 @@
|
||||
|
||||
this.chunkLoader.a();
|
||||
}
|
||||
@@ -198,7 +325,8 @@
|
||||
@@ -198,7 +329,8 @@
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@ -291,7 +295,7 @@
|
||||
}
|
||||
|
||||
public List<BiomeBase.BiomeMeta> a(EnumCreatureType enumcreaturetype, BlockPosition blockposition) {
|
||||
@@ -210,10 +338,11 @@
|
||||
@@ -210,10 +342,11 @@
|
||||
}
|
||||
|
||||
public int g() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/PlayerChunk.java
|
||||
+++ b/net/minecraft/server/PlayerChunk.java
|
||||
@@ -4,35 +4,48 @@
|
||||
@@ -4,35 +4,50 @@
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.ArrayList;
|
||||
@ -27,9 +27,10 @@
|
||||
private boolean done;
|
||||
|
||||
+ // CraftBukkit start - add fields
|
||||
+ private final HashMap<EntityPlayer, Runnable> players = new HashMap<EntityPlayer, Runnable>();
|
||||
+ private boolean loadInProgress = false;
|
||||
+ private Runnable loadedRunnable = new Runnable() {
|
||||
+ public void run() {
|
||||
+ loadInProgress = false;
|
||||
+ PlayerChunk.this.chunk = PlayerChunk.this.playerChunkMap.getWorld().getChunkProviderServer().getOrLoadChunkAt(location.x, location.z);
|
||||
+ }
|
||||
+ };
|
||||
@ -40,7 +41,8 @@
|
||||
this.location = new ChunkCoordIntPair(i, j);
|
||||
- this.chunk = playerchunkmap.getWorld().getChunkProviderServer().getOrLoadChunkAt(i, j);
|
||||
+ // CraftBukkit start
|
||||
+ this.chunk = playerchunkmap.getWorld().getChunkProviderServer().getChunkAt(i, j, loadedRunnable);
|
||||
+ loadInProgress = true;
|
||||
+ this.chunk = playerchunkmap.getWorld().getChunkProviderServer().getChunkAt(i, j, loadedRunnable, false);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@ -53,31 +55,20 @@
|
||||
if (this.c.contains(entityplayer)) {
|
||||
PlayerChunk.a.debug("Failed to add player. {} already is in chunk {}, {}", new Object[] { entityplayer, Integer.valueOf(this.location.x), Integer.valueOf(this.location.z)});
|
||||
} else {
|
||||
@@ -41,19 +54,50 @@
|
||||
@@ -41,15 +56,32 @@
|
||||
}
|
||||
|
||||
this.c.add(entityplayer);
|
||||
+ // CraftBukkit start - use async chunk io
|
||||
+ // if (this.j) {
|
||||
+ // if (this.done) {
|
||||
+ // this.sendChunk(entityplayer);
|
||||
+ // }
|
||||
+ Runnable playerRunnable;
|
||||
if (this.done) {
|
||||
- this.sendChunk(entityplayer);
|
||||
+ playerRunnable = null;
|
||||
+ sendChunk(entityplayer);
|
||||
+ } else {
|
||||
+ playerRunnable = new Runnable() {
|
||||
+ public void run() {
|
||||
+ sendChunk(entityplayer);
|
||||
+ }
|
||||
+ };
|
||||
+ playerChunkMap.getWorld().getChunkProviderServer().getChunkAt(this.location.x, this.location.z, playerRunnable);
|
||||
}
|
||||
|
||||
+ this.players.put(entityplayer, playerRunnable);
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,9 +76,7 @@
|
||||
if (this.c.contains(entityplayer)) {
|
||||
+ // CraftBukkit start - If we haven't loaded yet don't load the chunk just so we can clean it up
|
||||
+ if (!this.done) {
|
||||
+ ChunkIOExecutor.dropQueuedChunkLoad(this.playerChunkMap.getWorld(), this.location.x, this.location.z, this.players.get(entityplayer));
|
||||
+ this.c.remove(entityplayer);
|
||||
+ this.players.remove(entityplayer);
|
||||
+
|
||||
+ if (this.c.isEmpty()) {
|
||||
+ ChunkIOExecutor.dropQueuedChunkLoad(this.playerChunkMap.getWorld(), this.location.x, this.location.z, this.loadedRunnable);
|
||||
@ -100,19 +89,22 @@
|
||||
if (this.done) {
|
||||
entityplayer.playerConnection.sendPacket(new PacketPlayOutUnloadChunk(this.location.x, this.location.z));
|
||||
}
|
||||
|
||||
+ this.players.remove(entityplayer); // CraftBukkit
|
||||
this.c.remove(entityplayer);
|
||||
if (this.c.isEmpty()) {
|
||||
this.playerChunkMap.b(this);
|
||||
@@ -63,8 +107,8 @@
|
||||
}
|
||||
|
||||
public boolean a(boolean flag) {
|
||||
- if (this.chunk != null) {
|
||||
- return true;
|
||||
+ if (this.chunk != null || true) { // CraftBukkit
|
||||
+ return done; // CraftBukkit
|
||||
@@ -66,11 +98,18 @@
|
||||
if (this.chunk != null) {
|
||||
return true;
|
||||
} else {
|
||||
+ /* CraftBukkit start
|
||||
if (flag) {
|
||||
this.chunk = this.playerChunkMap.getWorld().getChunkProviderServer().getChunkAt(this.location.x, this.location.z);
|
||||
} else {
|
||||
this.chunk = this.playerChunkMap.getWorld().getChunkProviderServer().getOrLoadChunkAt(this.location.x, this.location.z);
|
||||
}
|
||||
+ */
|
||||
+ if (!loadInProgress) {
|
||||
+ loadInProgress = true;
|
||||
+ this.chunk = playerChunkMap.getWorld().getChunkProviderServer().getChunkAt(this.location.x, this.location.z, loadedRunnable, flag);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
return this.chunk != null;
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren