mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 01:37:35 +01:00
eed041d629
By: md_5 <git@md-5.net>
109 lines
4.3 KiB
Diff
109 lines
4.3 KiB
Diff
--- a/net/minecraft/server/level/ChunkMapDistance.java
|
|
+++ b/net/minecraft/server/level/ChunkMapDistance.java
|
|
@@ -163,7 +163,7 @@
|
|
}
|
|
}
|
|
|
|
- void addTicket(long i, Ticket<?> ticket) {
|
|
+ boolean addTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean
|
|
ArraySetSorted<Ticket<?>> arraysetsorted = this.getTickets(i);
|
|
int j = getTicketLevelAt(arraysetsorted);
|
|
Ticket<?> ticket1 = (Ticket) arraysetsorted.addOrGet(ticket);
|
|
@@ -173,13 +173,15 @@
|
|
this.ticketTracker.update(i, ticket.getTicketLevel(), true);
|
|
}
|
|
|
|
+ return ticket == ticket1; // CraftBukkit
|
|
}
|
|
|
|
- void removeTicket(long i, Ticket<?> ticket) {
|
|
+ boolean removeTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean
|
|
ArraySetSorted<Ticket<?>> arraysetsorted = this.getTickets(i);
|
|
|
|
+ boolean removed = false; // CraftBukkit
|
|
if (arraysetsorted.remove(ticket)) {
|
|
- ;
|
|
+ removed = true; // CraftBukkit
|
|
}
|
|
|
|
if (arraysetsorted.isEmpty()) {
|
|
@@ -187,6 +189,7 @@
|
|
}
|
|
|
|
this.ticketTracker.update(i, getTicketLevelAt(arraysetsorted), false);
|
|
+ return removed; // CraftBukkit
|
|
}
|
|
|
|
public <T> void addTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
|
@@ -200,19 +203,33 @@
|
|
}
|
|
|
|
public <T> void addRegionTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
|
+ // CraftBukkit start
|
|
+ addRegionTicketAtDistance(tickettype, chunkcoordintpair, i, t0);
|
|
+ }
|
|
+
|
|
+ public <T> boolean addRegionTicketAtDistance(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
|
+ // CraftBukkit end
|
|
Ticket<T> ticket = new Ticket<>(tickettype, ChunkLevel.byStatus(FullChunkStatus.FULL) - i, t0);
|
|
long j = chunkcoordintpair.toLong();
|
|
|
|
- this.addTicket(j, ticket);
|
|
+ boolean added = this.addTicket(j, ticket); // CraftBukkit
|
|
this.tickingTicketsTracker.addTicket(j, ticket);
|
|
+ return added; // CraftBukkit
|
|
}
|
|
|
|
public <T> void removeRegionTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
|
+ // CraftBukkit start
|
|
+ removeRegionTicketAtDistance(tickettype, chunkcoordintpair, i, t0);
|
|
+ }
|
|
+
|
|
+ public <T> boolean removeRegionTicketAtDistance(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
|
+ // CraftBukkit end
|
|
Ticket<T> ticket = new Ticket<>(tickettype, ChunkLevel.byStatus(FullChunkStatus.FULL) - i, t0);
|
|
long j = chunkcoordintpair.toLong();
|
|
|
|
- this.removeTicket(j, ticket);
|
|
+ boolean removed = this.removeTicket(j, ticket); // CraftBukkit
|
|
this.tickingTicketsTracker.removeTicket(j, ticket);
|
|
+ return removed; // CraftBukkit
|
|
}
|
|
|
|
private ArraySetSorted<Ticket<?>> getTickets(long i) {
|
|
@@ -251,6 +268,7 @@
|
|
ChunkCoordIntPair chunkcoordintpair = sectionposition.chunk();
|
|
long i = chunkcoordintpair.toLong();
|
|
ObjectSet<EntityPlayer> objectset = (ObjectSet) this.playersPerChunk.get(i);
|
|
+ if (objectset == null) return; // CraftBukkit - SPIGOT-6208
|
|
|
|
objectset.remove(entityplayer);
|
|
if (objectset.isEmpty()) {
|
|
@@ -380,6 +398,26 @@
|
|
return !this.tickets.isEmpty();
|
|
}
|
|
|
|
+ // CraftBukkit start
|
|
+ public <T> void removeAllTicketsFor(TicketType<T> ticketType, int ticketLevel, T ticketIdentifier) {
|
|
+ Ticket<T> target = new Ticket<>(ticketType, ticketLevel, ticketIdentifier);
|
|
+
|
|
+ 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
|
|
+ this.ticketTracker.update(entry.getLongKey(), getTicketLevelAt(tickets), false);
|
|
+
|
|
+ // can't use entry after it's removed
|
|
+ if (tickets.isEmpty()) {
|
|
+ iterator.remove();
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
private class a extends ChunkMap {
|
|
|
|
private static final int MAX_LEVEL = ChunkLevel.MAX_LEVEL + 1;
|