mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-07-03 07:30:02 +00:00
Javadoc and Formatting fixes. Also, extremely minor code changes which have been tested. This commit is only part one of two commits that aim to fix problems with formatting in our project. In part two I will modify the Google Java Style Guide (since it closely matches our code style) for our project so there is guidance on how to format and document. * Updated PlotSquared URL * Removed plugin acronyms * Fixed a typo * Fixed grammar * Use modern block id's * Update YouTube video URL
62 lines
1.9 KiB
Java
62 lines
1.9 KiB
Java
package com.boydti.fawe.bukkit.adapter;
|
|
|
|
import co.aikar.timings.Timings;
|
|
import com.boydti.fawe.beta.implementation.queue.QueueHandler;
|
|
import com.boydti.fawe.bukkit.listener.ChunkListener;
|
|
import org.spigotmc.AsyncCatcher;
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
import static org.slf4j.LoggerFactory.getLogger;
|
|
|
|
public class BukkitQueueHandler extends QueueHandler {
|
|
private volatile boolean timingsEnabled;
|
|
private static boolean alertTimingsChange = true;
|
|
|
|
private static Method methodCheck;
|
|
static {
|
|
try {
|
|
methodCheck = Class.forName("co.aikar.timings.TimingsManager").getDeclaredMethod("recheckEnabled");
|
|
methodCheck.setAccessible(true);
|
|
} catch (Throwable ignored) {
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void startSet(boolean parallel) {
|
|
ChunkListener.physicsFreeze = true;
|
|
if (parallel) {
|
|
try {
|
|
AsyncCatcher.enabled = false;
|
|
timingsEnabled = Timings.isTimingsEnabled();
|
|
if (timingsEnabled) {
|
|
if (alertTimingsChange) {
|
|
alertTimingsChange = false;
|
|
getLogger(BukkitQueueHandler.class).debug("Having `parallel-threads` > 1 interferes with the timings.");
|
|
}
|
|
Timings.setTimingsEnabled(false);
|
|
methodCheck.invoke(null);
|
|
}
|
|
} catch (Throwable e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void endSet(boolean parallel) {
|
|
ChunkListener.physicsFreeze = false;
|
|
if (parallel) {
|
|
try {
|
|
AsyncCatcher.enabled = true;
|
|
if (timingsEnabled) {
|
|
Timings.setTimingsEnabled(true);
|
|
methodCheck.invoke(null);
|
|
}
|
|
} catch (Throwable e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|