geforkt von Mirrors/Paper
de04cbced5
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: f29cb801 Separate checkstyle-suppressions file is not required 86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack 9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode() 994a6163 Attempt upgrade of resolver libraries CraftBukkit Changes: b3b43a6ad Add Checkstyle check for unused imports 13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names 3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API 2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor 1dbdbbed4 PR-1238: Remove unnecessary sign ticking 659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper e37e29ce0 Increase outdated build delay c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack 492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode() e11fbb9d7 Upgrade MySQL driver 9f3a0bd2a Attempt upgrade of resolver libraries 60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion Spigot Changes: 06d602e7 Rebuild patches
127 Zeilen
7.3 KiB
Diff
127 Zeilen
7.3 KiB
Diff
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 Plugin Tickets 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.
|
|
|
|
Also reduce their collection count down to a maximum of 1 second. Barely
|
|
anyone knows what chunk-gc is in bukkit.yml as its less relevant now, and
|
|
since this wasn't spigot behavior, this is safe to mostly ignore (unless someone
|
|
wants it to collect even faster, they can restore that setting back to 1 instead of 20+)
|
|
|
|
Not adding it to .getType() though to keep behavior consistent with vanilla for performance reasons.
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index 1b43d61f3464218bdf5221ffbf87a7280fa8028c..84ff901c4805516bbe438b4ad808e75cd2e15a9d 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -377,7 +377,7 @@ public final class CraftServer implements Server {
|
|
this.overrideSpawnLimits();
|
|
console.autosavePeriod = this.configuration.getInt("ticks-per.autosave");
|
|
this.warningState = WarningState.value(this.configuration.getString("settings.deprecated-verbose"));
|
|
- TicketType.PLUGIN.timeout = this.configuration.getInt("chunk-gc.period-in-ticks");
|
|
+ TicketType.PLUGIN.timeout = Math.min(20, this.configuration.getInt("chunk-gc.period-in-ticks")); // Paper - cap plugin loads to 1 second
|
|
this.minimumAPI = this.configuration.getString("settings.minimum-api");
|
|
this.loadIcon();
|
|
|
|
@@ -935,7 +935,7 @@ public final class CraftServer implements Server {
|
|
this.console.setMotd(config.motd);
|
|
this.overrideSpawnLimits();
|
|
this.warningState = WarningState.value(this.configuration.getString("settings.deprecated-verbose"));
|
|
- TicketType.PLUGIN.timeout = this.configuration.getInt("chunk-gc.period-in-ticks");
|
|
+ TicketType.PLUGIN.timeout = Math.min(20, configuration.getInt("chunk-gc.period-in-ticks")); // Paper - cap plugin loads to 1 second
|
|
this.minimumAPI = this.configuration.getString("settings.minimum-api");
|
|
this.printSaveWarning = false;
|
|
this.console.autosavePeriod = this.configuration.getInt("ticks-per.autosave");
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
index b57554333fd90da1f1ebc006cb1d0ebbfca9a499..2d90be2537faf281adc50f856daf3b4e8b842568 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -283,7 +283,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
@Override
|
|
public Chunk getChunkAt(int x, int z) {
|
|
- net.minecraft.world.level.chunk.LevelChunk chunk = (net.minecraft.world.level.chunk.LevelChunk) this.world.getChunk(x, z, ChunkStatus.FULL, true);
|
|
+ // Paper start - add ticket to hold chunk for a little while longer if plugin accesses it
|
|
+ net.minecraft.world.level.chunk.LevelChunk chunk = this.world.getChunkSource().getChunkAtIfLoadedImmediately(x, z);
|
|
+ if (chunk == null) {
|
|
+ this.addTicket(x, z);
|
|
+ chunk = this.world.getChunkSource().getChunk(x, z, true);
|
|
+ }
|
|
+ // Paper end
|
|
return new CraftChunk(chunk);
|
|
}
|
|
|
|
@@ -297,6 +303,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
return new CraftChunk(this.getHandle(), x, z);
|
|
}
|
|
|
|
+ // Paper start
|
|
+ private void addTicket(int x, int z) {
|
|
+ io.papermc.paper.util.MCUtil.MAIN_EXECUTOR.execute(() -> this.world.getChunkSource().addRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 0, Unit.INSTANCE)); // Paper
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
@Override
|
|
public Chunk getChunkAt(Block block) {
|
|
Preconditions.checkArgument(block != null, "null block");
|
|
@@ -362,7 +374,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
public boolean unloadChunkRequest(int x, int z) {
|
|
org.spigotmc.AsyncCatcher.catchOp("chunk unload"); // Spigot
|
|
if (this.isChunkLoaded(x, z)) {
|
|
- this.world.getChunkSource().removeRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 1, Unit.INSTANCE);
|
|
+ this.world.getChunkSource().removeRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 0, Unit.INSTANCE); // Paper
|
|
}
|
|
|
|
return true;
|
|
@@ -448,9 +460,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
org.spigotmc.AsyncCatcher.catchOp("chunk load"); // Spigot
|
|
// Paper start - Optimize this method
|
|
ChunkPos chunkPos = new ChunkPos(x, z);
|
|
+ ChunkAccess immediate = world.getChunkSource().getChunkAtIfLoadedImmediately(x, z); // Paper
|
|
+ if (immediate != null) return true; // Paper
|
|
|
|
if (!generate) {
|
|
- ChunkAccess immediate = world.getChunkSource().getChunkAtImmediately(x, z);
|
|
+
|
|
+ //IChunkAccess immediate = world.getChunkProvider().getChunkAtImmediately(x, z); // Paper
|
|
if (immediate == null) {
|
|
immediate = world.getChunkSource().chunkMap.getUnloadingChunk(x, z);
|
|
}
|
|
@@ -458,7 +473,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
if (!(immediate instanceof ImposterProtoChunk) && !(immediate instanceof net.minecraft.world.level.chunk.LevelChunk)) {
|
|
return false; // not full status
|
|
}
|
|
- world.getChunkSource().addRegionTicket(TicketType.PLUGIN, chunkPos, 1, Unit.INSTANCE);
|
|
+ world.getChunkSource().addRegionTicket(TicketType.PLUGIN, chunkPos, 0, Unit.INSTANCE); // Paper
|
|
world.getChunk(x, z); // make sure we're at ticket level 32 or lower
|
|
return true;
|
|
}
|
|
@@ -484,7 +499,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
// we do this so we do not re-read the chunk data on disk
|
|
}
|
|
|
|
- world.getChunkSource().addRegionTicket(TicketType.PLUGIN, chunkPos, 1, Unit.INSTANCE);
|
|
+ world.getChunkSource().addRegionTicket(TicketType.PLUGIN, chunkPos, 0, Unit.INSTANCE); // Paper
|
|
world.getChunkSource().getChunk(x, z, ChunkStatus.FULL, true);
|
|
return true;
|
|
// Paper end
|
|
@@ -2269,6 +2284,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
io.papermc.paper.chunk.system.ChunkSystem.scheduleChunkLoad(this.getHandle(), x, z, gen, ChunkStatus.FULL, true, priority, (c) -> {
|
|
net.minecraft.server.MinecraftServer.getServer().scheduleOnMain(() -> {
|
|
net.minecraft.world.level.chunk.LevelChunk chunk = (net.minecraft.world.level.chunk.LevelChunk)c;
|
|
+ if (chunk != null) this.addTicket(x, z); // Paper
|
|
ret.complete(chunk == null ? null : new CraftChunk(chunk));
|
|
});
|
|
});
|