2019-07-08 04:14:16 +02:00
|
|
|
--- a/net/minecraft/server/ChunkMapDistance.java
|
|
|
|
+++ b/net/minecraft/server/ChunkMapDistance.java
|
2019-12-10 23:00:00 +01:00
|
|
|
@@ -59,7 +59,7 @@
|
2019-07-08 04:14:16 +02:00
|
|
|
while (objectiterator.hasNext()) {
|
2019-12-10 23:00:00 +01:00
|
|
|
Entry<ArraySetSorted<Ticket<?>>> entry = (Entry) objectiterator.next();
|
2019-07-08 04:14:16 +02:00
|
|
|
|
2019-12-10 23:00:00 +01:00
|
|
|
- if (((ArraySetSorted) entry.getValue()).removeIf((ticket) -> {
|
|
|
|
+ if ((entry.getValue()).removeIf((ticket) -> { // CraftBukkit - decompile error
|
|
|
|
return ticket.b(this.currentTick);
|
2019-07-08 04:14:16 +02:00
|
|
|
})) {
|
2020-06-25 02:00:00 +02:00
|
|
|
this.ticketLevelTracker.update(entry.getLongKey(), getLowestTicketLevel((ArraySetSorted) entry.getValue()), false);
|
2019-12-10 23:00:00 +01:00
|
|
|
@@ -95,10 +95,25 @@
|
2019-07-13 20:23:41 +02:00
|
|
|
}
|
|
|
|
|
2019-07-20 01:00:00 +02:00
|
|
|
if (!this.pendingChunkUpdates.isEmpty()) {
|
|
|
|
- this.pendingChunkUpdates.forEach((playerchunk) -> {
|
2019-07-13 20:23:41 +02:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ // Iterate pending chunk updates with protection against concurrent modification exceptions
|
2019-07-20 01:00:00 +02:00
|
|
|
+ java.util.Iterator<PlayerChunk> iter = this.pendingChunkUpdates.iterator();
|
|
|
|
+ int expectedSize = this.pendingChunkUpdates.size();
|
2019-07-13 20:23:41 +02:00
|
|
|
+ do {
|
|
|
|
+ PlayerChunk playerchunk = iter.next();
|
|
|
|
+ iter.remove();
|
|
|
|
+ expectedSize--;
|
|
|
|
+
|
|
|
|
playerchunk.a(playerchunkmap);
|
|
|
|
- });
|
2019-07-20 01:00:00 +02:00
|
|
|
- this.pendingChunkUpdates.clear();
|
2019-07-13 20:23:41 +02:00
|
|
|
+
|
|
|
|
+ // Reset iterator if set was modified using add()
|
2019-07-20 01:00:00 +02:00
|
|
|
+ if (this.pendingChunkUpdates.size() != expectedSize) {
|
|
|
|
+ expectedSize = this.pendingChunkUpdates.size();
|
|
|
|
+ iter = this.pendingChunkUpdates.iterator();
|
2019-07-13 20:23:41 +02:00
|
|
|
+ }
|
|
|
|
+ } while (iter.hasNext());
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
if (!this.l.isEmpty()) {
|
2019-12-10 23:00:00 +01:00
|
|
|
@@ -134,23 +149,25 @@
|
2019-07-08 04:14:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-20 01:00:00 +02:00
|
|
|
- private void addTicket(long i, Ticket<?> ticket) {
|
|
|
|
+ private boolean addTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean
|
2019-12-10 23:00:00 +01:00
|
|
|
ArraySetSorted<Ticket<?>> arraysetsorted = this.e(i);
|
2020-06-25 02:00:00 +02:00
|
|
|
int j = getLowestTicketLevel(arraysetsorted);
|
2019-12-10 23:00:00 +01:00
|
|
|
- Ticket<?> ticket1 = (Ticket) arraysetsorted.a((Object) ticket);
|
|
|
|
+ Ticket<?> ticket1 = (Ticket) arraysetsorted.a(ticket); // CraftBukkit - decompile error
|
2019-07-08 04:14:16 +02:00
|
|
|
|
2019-12-10 23:00:00 +01:00
|
|
|
ticket1.a(this.currentTick);
|
2019-07-08 04:14:16 +02:00
|
|
|
if (ticket.b() < j) {
|
2020-06-25 02:00:00 +02:00
|
|
|
this.ticketLevelTracker.update(i, ticket.b(), 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
|
|
|
}
|
|
|
|
|
2019-07-20 01:00:00 +02:00
|
|
|
- private void removeTicket(long i, Ticket<?> ticket) {
|
|
|
|
+ private boolean removeTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean
|
2019-12-10 23:00:00 +01:00
|
|
|
ArraySetSorted<Ticket<?>> arraysetsorted = this.e(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()) {
|
|
|
|
@@ -158,16 +175,29 @@
|
2019-07-08 04:14:16 +02:00
|
|
|
}
|
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
this.ticketLevelTracker.update(i, getLowestTicketLevel(arraysetsorted), false);
|
2019-07-08 04:14:16 +02:00
|
|
|
+ return removed; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
public <T> void a(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
2019-12-10 23:00:00 +01:00
|
|
|
- this.addTicket(chunkcoordintpair.pair(), 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) {
|
2019-12-10 23:00:00 +01:00
|
|
|
+ return this.addTicket(chunkcoordintpair.pair(), new Ticket<>(ticketType, level, identifier));
|
2019-07-08 04:14:16 +02:00
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
public <T> void b(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);
|
|
|
|
+ }
|
|
|
|
|
2019-07-20 01:00:00 +02:00
|
|
|
- this.removeTicket(chunkcoordintpair.pair(), ticket);
|
|
|
|
+ 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
|
|
|
+
|
|
|
|
+ return this.removeTicket(chunkcoordintpair.pair(), ticket);
|
2019-07-08 04:14:16 +02:00
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
public <T> void addTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
2020-03-22 10:02:22 +01:00
|
|
|
@@ -251,6 +281,26 @@
|
2019-07-20 01:00:00 +02:00
|
|
|
return this.i.a();
|
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
|
2020-06-25 02:00:00 +02:00
|
|
|
+ this.ticketLevelTracker.update(entry.getLongKey(), getLowestTicketLevel(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
|
|
|
|
+
|
|
|
|
class a extends ChunkMap {
|
|
|
|
|
|
|
|
public a() {
|