2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/server/level/ChunkMapDistance.java
|
|
|
|
+++ b/net/minecraft/server/level/ChunkMapDistance.java
|
2021-11-21 23:00:00 +01:00
|
|
|
@@ -125,10 +125,25 @@
|
2019-07-13 20:23:41 +02:00
|
|
|
}
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
if (!this.chunksToUpdateFutures.isEmpty()) {
|
|
|
|
- this.chunksToUpdateFutures.forEach((playerchunk) -> {
|
2019-07-13 20:23:41 +02:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ // Iterate pending chunk updates with protection against concurrent modification exceptions
|
2021-06-11 07:00:00 +02:00
|
|
|
+ java.util.Iterator<PlayerChunk> iter = this.chunksToUpdateFutures.iterator();
|
|
|
|
+ int expectedSize = this.chunksToUpdateFutures.size();
|
2019-07-13 20:23:41 +02:00
|
|
|
+ do {
|
|
|
|
+ PlayerChunk playerchunk = iter.next();
|
|
|
|
+ iter.remove();
|
|
|
|
+ expectedSize--;
|
|
|
|
+
|
2021-11-21 23:00:00 +01:00
|
|
|
playerchunk.updateFutures(playerchunkmap, this.mainThreadExecutor);
|
2019-07-13 20:23:41 +02:00
|
|
|
- });
|
2021-06-11 07:00:00 +02:00
|
|
|
- this.chunksToUpdateFutures.clear();
|
2019-07-13 20:23:41 +02:00
|
|
|
+
|
|
|
|
+ // Reset iterator if set was modified using add()
|
2021-06-11 07:00:00 +02:00
|
|
|
+ if (this.chunksToUpdateFutures.size() != expectedSize) {
|
|
|
|
+ expectedSize = this.chunksToUpdateFutures.size();
|
|
|
|
+ iter = this.chunksToUpdateFutures.iterator();
|
2019-07-13 20:23:41 +02:00
|
|
|
+ }
|
|
|
|
+ } while (iter.hasNext());
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
|
|
|
return true;
|
|
|
|
} else {
|
2021-06-11 07:00:00 +02:00
|
|
|
if (!this.ticketsToRelease.isEmpty()) {
|
2021-11-21 23:00:00 +01:00
|
|
|
@@ -164,7 +179,7 @@
|
2019-07-08 04:14:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
- void addTicket(long i, Ticket<?> ticket) {
|
|
|
|
+ boolean addTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean
|
2021-11-21 23:00:00 +01:00
|
|
|
ArraySetSorted<Ticket<?>> arraysetsorted = this.getTickets(i);
|
|
|
|
int j = getTicketLevelAt(arraysetsorted);
|
|
|
|
Ticket<?> ticket1 = (Ticket) arraysetsorted.addOrGet(ticket);
|
|
|
|
@@ -174,13 +189,15 @@
|
|
|
|
this.ticketTracker.update(i, ticket.getTicketLevel(), true);
|
2019-07-08 04:14:16 +02:00
|
|
|
}
|
|
|
|
|
2019-12-10 23:00:00 +01:00
|
|
|
+ return ticket == ticket1; // CraftBukkit
|
2019-07-08 04:14:16 +02:00
|
|
|
}
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
- void removeTicket(long i, Ticket<?> ticket) {
|
|
|
|
+ boolean removeTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean
|
2021-11-21 23:00:00 +01:00
|
|
|
ArraySetSorted<Ticket<?>> arraysetsorted = this.getTickets(i);
|
2019-07-08 04:14:16 +02:00
|
|
|
|
|
|
|
+ boolean removed = false; // CraftBukkit
|
2019-12-10 23:00:00 +01:00
|
|
|
if (arraysetsorted.remove(ticket)) {
|
2019-07-08 04:14:16 +02:00
|
|
|
- ;
|
|
|
|
+ removed = true; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
2019-12-10 23:00:00 +01:00
|
|
|
if (arraysetsorted.isEmpty()) {
|
2021-11-21 23:00:00 +01:00
|
|
|
@@ -188,16 +205,29 @@
|
2019-07-08 04:14:16 +02:00
|
|
|
}
|
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
this.ticketTracker.update(i, getTicketLevelAt(arraysetsorted), false);
|
2019-07-08 04:14:16 +02:00
|
|
|
+ return removed; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
public <T> void addTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
|
|
|
- this.addTicket(chunkcoordintpair.toLong(), new Ticket<>(tickettype, i, t0));
|
2019-07-08 04:14:16 +02:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ this.addTicketAtLevel(tickettype, chunkcoordintpair, i, t0);
|
|
|
|
+ }
|
2019-07-20 01:00:00 +02:00
|
|
|
+
|
|
|
|
+ public <T> boolean addTicketAtLevel(TicketType<T> ticketType, ChunkCoordIntPair chunkcoordintpair, int level, T identifier) {
|
2021-11-21 23:00:00 +01:00
|
|
|
+ return this.addTicket(chunkcoordintpair.toLong(), new Ticket<>(ticketType, level, identifier));
|
2019-07-08 04:14:16 +02:00
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
public <T> void removeTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
2019-12-10 23:00:00 +01:00
|
|
|
- Ticket<T> ticket = new Ticket<>(tickettype, i, t0);
|
2019-07-08 04:14:16 +02:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ this.removeTicketAtLevel(tickettype, chunkcoordintpair, i, t0);
|
|
|
|
+ }
|
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
- this.removeTicket(chunkcoordintpair.toLong(), ticket);
|
2019-07-20 01:00:00 +02:00
|
|
|
+ public <T> boolean removeTicketAtLevel(TicketType<T> ticketType, ChunkCoordIntPair chunkcoordintpair, int level, T identifier) {
|
2019-12-10 23:00:00 +01:00
|
|
|
+ Ticket<T> ticket = new Ticket<>(ticketType, level, identifier);
|
2019-07-20 01:00:00 +02:00
|
|
|
+
|
2021-11-21 23:00:00 +01:00
|
|
|
+ return this.removeTicket(chunkcoordintpair.toLong(), ticket);
|
2019-07-08 04:14:16 +02:00
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
public <T> void addRegionTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
|
|
|
@@ -252,6 +282,7 @@
|
|
|
|
ChunkCoordIntPair chunkcoordintpair = sectionposition.chunk();
|
|
|
|
long i = chunkcoordintpair.toLong();
|
2021-06-11 07:00:00 +02:00
|
|
|
ObjectSet<EntityPlayer> objectset = (ObjectSet) this.playersPerChunk.get(i);
|
2021-01-31 04:26:05 +01:00
|
|
|
+ if (objectset == null) return; // CraftBukkit - SPIGOT-6208
|
|
|
|
|
|
|
|
objectset.remove(entityplayer);
|
|
|
|
if (objectset.isEmpty()) {
|
2021-11-21 23:00:00 +01:00
|
|
|
@@ -347,6 +378,26 @@
|
|
|
|
return this.tickingTicketsTracker;
|
2019-07-08 04:14:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ public <T> void removeAllTicketsFor(TicketType<T> ticketType, int ticketLevel, T ticketIdentifier) {
|
2019-12-10 23:00:00 +01:00
|
|
|
+ Ticket<T> target = new Ticket<>(ticketType, ticketLevel, ticketIdentifier);
|
2019-07-08 04:14:16 +02:00
|
|
|
+
|
2020-03-22 10:02:22 +01:00
|
|
|
+ for (java.util.Iterator<Entry<ArraySetSorted<Ticket<?>>>> iterator = this.tickets.long2ObjectEntrySet().fastIterator(); iterator.hasNext();) {
|
|
|
|
+ Entry<ArraySetSorted<Ticket<?>>> entry = iterator.next();
|
|
|
|
+ ArraySetSorted<Ticket<?>> tickets = entry.getValue();
|
|
|
|
+ if (tickets.remove(target)) {
|
|
|
|
+ // copied from removeTicket
|
2021-11-21 23:00:00 +01:00
|
|
|
+ this.ticketTracker.update(entry.getLongKey(), getTicketLevelAt(tickets), false);
|
2019-07-08 04:14:16 +02:00
|
|
|
+
|
2020-03-22 10:02:22 +01:00
|
|
|
+ // can't use entry after it's removed
|
|
|
|
+ if (tickets.isEmpty()) {
|
|
|
|
+ iterator.remove();
|
|
|
|
+ }
|
2019-07-08 04:14:16 +02:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
2021-06-11 07:00:00 +02:00
|
|
|
private class a extends ChunkMap {
|
2019-07-08 04:14:16 +02:00
|
|
|
|
|
|
|
public a() {
|