This commit is contained in:
NotMyFault 2021-08-05 15:55:20 +02:00
parent 3ccb5e0aed
commit c468d22120
No known key found for this signature in database
GPG Key ID: 158F5701A6AAD00C
3 changed files with 14 additions and 12 deletions

View File

@ -64,7 +64,6 @@ gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
#Platform expectations #Platform expectations
paper = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" } paper = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" }
spigot = { group = "org.spigotmc", name = "spigot", version.ref = "paper" }
# Plugins # Plugins
vault = { group = "com.github.MilkBowl", name = "VaultAPI", version.ref = "vault" } vault = { group = "com.github.MilkBowl", name = "VaultAPI", version.ref = "vault" }

View File

@ -62,9 +62,6 @@ dependencies {
isTransitive = false isTransitive = false
exclude(group = "org.slf4j", module = "slf4j-api") exclude(group = "org.slf4j", module = "slf4j-api")
} }
compileOnly(libs.spigot) {
because("Remove if #1208 has been addressed")
}
// Logging // Logging
implementation(libs.log4j) implementation(libs.log4j)

View File

@ -5,8 +5,8 @@ import com.fastasyncworldedit.bukkit.listener.ChunkListener;
import com.fastasyncworldedit.core.queue.implementation.QueueHandler; import com.fastasyncworldedit.core.queue.implementation.QueueHandler;
import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.internal.util.LogManagerCompat;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.spigotmc.AsyncCatcher;
import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
public class BukkitQueueHandler extends QueueHandler { public class BukkitQueueHandler extends QueueHandler {
@ -16,12 +16,18 @@ public class BukkitQueueHandler extends QueueHandler {
private volatile boolean timingsEnabled; private volatile boolean timingsEnabled;
private static boolean alertTimingsChange = true; private static boolean alertTimingsChange = true;
private static Method methodCheck; private static Method timingsCheck;
private static Field asyncCatcher;
static { static {
try { try {
methodCheck = Class.forName("co.aikar.timings.TimingsManager").getDeclaredMethod("recheckEnabled"); timingsCheck = Class.forName("co.aikar.timings.TimingsManager").getDeclaredMethod("recheckEnabled");
methodCheck.setAccessible(true); timingsCheck.setAccessible(true);
} catch (Throwable ignored) {
}
try {
asyncCatcher = Class.forName("org.spigotmc.AsyncCatcher").getDeclaredField("enabled");
asyncCatcher.setAccessible(true);
} catch (Throwable ignored) { } catch (Throwable ignored) {
} }
} }
@ -31,7 +37,7 @@ public class BukkitQueueHandler extends QueueHandler {
ChunkListener.physicsFreeze = true; ChunkListener.physicsFreeze = true;
if (parallel) { if (parallel) {
try { try {
AsyncCatcher.enabled = false; asyncCatcher.setBoolean(asyncCatcher, false);
timingsEnabled = Timings.isTimingsEnabled(); timingsEnabled = Timings.isTimingsEnabled();
if (timingsEnabled) { if (timingsEnabled) {
if (alertTimingsChange) { if (alertTimingsChange) {
@ -39,7 +45,7 @@ public class BukkitQueueHandler extends QueueHandler {
LOGGER.debug("Having `parallel-threads` > 1 interferes with the timings."); LOGGER.debug("Having `parallel-threads` > 1 interferes with the timings.");
} }
Timings.setTimingsEnabled(false); Timings.setTimingsEnabled(false);
methodCheck.invoke(null); timingsCheck.invoke(null);
} }
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
@ -52,10 +58,10 @@ public class BukkitQueueHandler extends QueueHandler {
ChunkListener.physicsFreeze = false; ChunkListener.physicsFreeze = false;
if (parallel) { if (parallel) {
try { try {
AsyncCatcher.enabled = true; asyncCatcher.setBoolean(asyncCatcher, true);
if (timingsEnabled) { if (timingsEnabled) {
Timings.setTimingsEnabled(true); Timings.setTimingsEnabled(true);
methodCheck.invoke(null); timingsCheck.invoke(null);
} }
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();