Archiviert
13
0

Add PluginTickets to API Chunk Methods

Like previous versions, plugins loading chunks kept them loaded until
they garbage collected to avoid constant spamming of chunk loads

This adds tickets to a few more places so that they can be unloaded.

Additionally, this drops their ticket level to BORDER so they wont be ticking
so they will just sit inactive instead.

Using .loadChunk to keep a chunk ticking was a horrible idea for upstream
when we have TWO methods that are able to do that already in the API.

Not adding it to .getType() though to keep behavior consistent with vanilla.
Dieser Commit ist enthalten in:
Aikar 2020-06-09 03:43:11 -04:00
Ursprung b2d81e21c5
Commit 531c4b3fd1
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 401ADFC9891FAAFE

Datei anzeigen

@ -0,0 +1,65 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 9 Jun 2020 03:33:03 -0400
Subject: [PATCH] Add PluginTickets to API Chunk Methods
Like previous versions, plugins loading chunks kept them loaded until
they garbage collected to avoid constant spamming of chunk loads
This adds tickets to a few more places so that they can be unloaded.
Additionally, this drops their ticket level to BORDER so they wont be ticking
so they will just sit inactive instead.
Using .loadChunk to keep a chunk ticking was a horrible idea for upstream
when we have TWO methods that are able to do that already in the API.
Not adding it to .getType() though to keep behavior consistent with vanilla.
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index d3c5b7d1904a6cbd65db406639ed2ba90ec9fd2a..314700041068c79898b555538e8f327693cf9898 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -399,6 +399,7 @@ public class CraftWorld implements World {
@Override
public Chunk getChunkAt(int x, int z) {
+ world.getChunkProvider().addTicket(TicketType.PLUGIN, new ChunkCoordIntPair(x, z), 0, Unit.INSTANCE); // Paper
return this.world.getChunkProvider().getChunkAt(x, z, true).bukkitChunk;
}
@@ -476,7 +477,7 @@ public class CraftWorld implements World {
org.spigotmc.AsyncCatcher.catchOp("chunk unload"); // Spigot
net.minecraft.server.IChunkAccess chunk = world.getChunkProvider().getChunkAtIfLoadedImmediately(x, z); // Paper
if (chunk != null) {
- world.getChunkProvider().removeTicket(TicketType.PLUGIN, chunk.getPos(), 1, Unit.INSTANCE);
+ world.getChunkProvider().removeTicket(TicketType.PLUGIN, chunk.getPos(), 0, Unit.INSTANCE); // Paper
}
return true;
@@ -564,7 +565,7 @@ public class CraftWorld implements World {
if (!(immediate instanceof ProtoChunkExtension) && !(immediate instanceof net.minecraft.server.Chunk)) {
return false; // not full status
}
- world.getChunkProvider().addTicket(TicketType.PLUGIN, chunkPos, 1, Unit.INSTANCE);
+ world.getChunkProvider().addTicket(TicketType.PLUGIN, chunkPos, 0, Unit.INSTANCE); // Paper
world.getChunkAt(x, z); // make sure we're at ticket level 32 or lower
return true;
}
@@ -591,7 +592,7 @@ public class CraftWorld implements World {
// we do this so we do not re-read the chunk data on disk
}
- world.getChunkProvider().addTicket(TicketType.PLUGIN, chunkPos, 1, Unit.INSTANCE);
+ world.getChunkProvider().addTicket(TicketType.PLUGIN, chunkPos, 0, Unit.INSTANCE); // Paper
world.getChunkProvider().getChunkAt(x, z, ChunkStatus.FULL, true);
return true;
// Paper end
@@ -2477,6 +2478,7 @@ public class CraftWorld implements World {
if (err != null) {
future.completeExceptionally(err);
} else {
+ world.getChunkProvider().addTicket(TicketType.PLUGIN, new ChunkCoordIntPair(x, z), 0, Unit.INSTANCE); // Paper
future.complete(chunk);
}
});