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