Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 02:20:07 +01:00
Remove some reflection from QueueHandler
Dieser Commit ist enthalten in:
Ursprung
cb6359f010
Commit
7d4acbdcac
@ -2,26 +2,19 @@ package com.boydti.fawe.bukkit.adapter;
|
|||||||
|
|
||||||
import static org.slf4j.LoggerFactory.getLogger;
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
|
|
||||||
|
import co.aikar.timings.Timings;
|
||||||
import com.boydti.fawe.beta.implementation.queue.QueueHandler;
|
import com.boydti.fawe.beta.implementation.queue.QueueHandler;
|
||||||
import com.boydti.fawe.bukkit.listener.ChunkListener;
|
import com.boydti.fawe.bukkit.listener.ChunkListener;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import org.spigotmc.AsyncCatcher;
|
||||||
|
|
||||||
public class BukkitQueueHandler extends QueueHandler {
|
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 Field fieldTimingsEnabled;
|
|
||||||
private static Field fieldAsyncCatcherEnabled;
|
|
||||||
private static Method methodCheck;
|
private static Method methodCheck;
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
fieldAsyncCatcherEnabled = Class.forName("org.spigotmc.AsyncCatcher").getField("enabled");
|
|
||||||
fieldAsyncCatcherEnabled.setAccessible(true);
|
|
||||||
} catch (Throwable ignore) {}
|
|
||||||
try {
|
|
||||||
fieldTimingsEnabled = Class.forName("co.aikar.timings.Timings").getDeclaredField("timingsEnabled");
|
|
||||||
fieldTimingsEnabled.setAccessible(true);
|
|
||||||
methodCheck = Class.forName("co.aikar.timings.TimingsManager").getDeclaredMethod("recheckEnabled");
|
methodCheck = Class.forName("co.aikar.timings.TimingsManager").getDeclaredMethod("recheckEnabled");
|
||||||
methodCheck.setAccessible(true);
|
methodCheck.setAccessible(true);
|
||||||
} catch (Throwable ignore){}
|
} catch (Throwable ignore){}
|
||||||
@ -32,20 +25,16 @@ public class BukkitQueueHandler extends QueueHandler {
|
|||||||
ChunkListener.physicsFreeze = true;
|
ChunkListener.physicsFreeze = true;
|
||||||
if (parallel) {
|
if (parallel) {
|
||||||
try {
|
try {
|
||||||
if (fieldAsyncCatcherEnabled != null) {
|
AsyncCatcher.enabled = false;
|
||||||
fieldAsyncCatcherEnabled.set(null, false);
|
timingsEnabled = Timings.isTimingsEnabled();
|
||||||
}
|
|
||||||
if (fieldTimingsEnabled != null) {
|
|
||||||
timingsEnabled = (boolean) fieldTimingsEnabled.get(null);
|
|
||||||
if (timingsEnabled) {
|
if (timingsEnabled) {
|
||||||
if (alertTimingsChange) {
|
if (alertTimingsChange) {
|
||||||
alertTimingsChange = false;
|
alertTimingsChange = false;
|
||||||
getLogger(BukkitQueueHandler.class).debug("Having `parallel-threads` > 1 interferes with the timings.");
|
getLogger(BukkitQueueHandler.class).debug("Having `parallel-threads` > 1 interferes with the timings.");
|
||||||
}
|
}
|
||||||
fieldTimingsEnabled.set(null, false);
|
Timings.setTimingsEnabled(false);
|
||||||
methodCheck.invoke(null);
|
methodCheck.invoke(null);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -57,11 +46,9 @@ public class BukkitQueueHandler extends QueueHandler {
|
|||||||
ChunkListener.physicsFreeze = false;
|
ChunkListener.physicsFreeze = false;
|
||||||
if (parallel) {
|
if (parallel) {
|
||||||
try {
|
try {
|
||||||
if (fieldAsyncCatcherEnabled != null) {
|
AsyncCatcher.enabled = true;
|
||||||
fieldAsyncCatcherEnabled.set(null, true);
|
if (timingsEnabled) {
|
||||||
}
|
Timings.setTimingsEnabled(true);
|
||||||
if (fieldTimingsEnabled != null && timingsEnabled) {
|
|
||||||
fieldTimingsEnabled.set(null, true);
|
|
||||||
methodCheck.invoke(null);
|
methodCheck.invoke(null);
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren