This commit is contained in:
Jesse Boyd 2017-07-22 17:48:10 +10:00
parent 3964390832
commit b07d72808b
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F

View File

@ -4,6 +4,7 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.bukkit.BukkitPlayer; import com.boydti.fawe.bukkit.BukkitPlayer;
import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.bukkit.FaweBukkit;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.example.CharFaweChunk; import com.boydti.fawe.example.CharFaweChunk;
import com.boydti.fawe.example.NMSMappedFaweQueue; import com.boydti.fawe.example.NMSMappedFaweQueue;
import com.boydti.fawe.object.FaweChunk; import com.boydti.fawe.object.FaweChunk;
@ -216,6 +217,8 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
private volatile boolean timingsEnabled; private volatile boolean timingsEnabled;
private static boolean alertTimingsChange = true; private static boolean alertTimingsChange = true;
private volatile int parallelThreads;
private static Field fieldTimingsEnabled; private static Field fieldTimingsEnabled;
private static Field fieldAsyncCatcherEnabled; private static Field fieldAsyncCatcherEnabled;
private static Method methodCheck; private static Method methodCheck;
@ -236,6 +239,10 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
public void startSet(boolean parallel) { public void startSet(boolean parallel) {
ChunkListener.physicsFreeze = true; ChunkListener.physicsFreeze = true;
if (parallel) { if (parallel) {
if (Fawe.get().isMainThread()) {
parallelThreads = Settings.IMP.QUEUE.PARALLEL_THREADS;
Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
}
try { try {
if (fieldAsyncCatcherEnabled != null) { if (fieldAsyncCatcherEnabled != null) {
fieldAsyncCatcherEnabled.set(null, false); fieldAsyncCatcherEnabled.set(null, false);
@ -257,6 +264,28 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
} }
} }
@Override
public void endSet(boolean parallel) {
ChunkListener.physicsFreeze = false;
if (parallel) {
if (Fawe.get().isMainThread() && parallelThreads != 0) {
Settings.IMP.QUEUE.PARALLEL_THREADS = parallelThreads;
}
try {
if (fieldAsyncCatcherEnabled != null) {
fieldAsyncCatcherEnabled.set(null, true);
}
if (fieldTimingsEnabled != null && timingsEnabled) {
fieldTimingsEnabled.set(null, true);
methodCheck.invoke(null);
}
} catch (Throwable e) {
e.printStackTrace();
}
}
parallelThreads = 0;
}
@Override @Override
public void sendBlockUpdate(final FaweChunk chunk, FawePlayer... players) { public void sendBlockUpdate(final FaweChunk chunk, FawePlayer... players) {
if (players.length == 0) { if (players.length == 0) {
@ -294,22 +323,4 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
} }
}); });
} }
@Override
public void endSet(boolean parallel) {
ChunkListener.physicsFreeze = false;
if (parallel) {
try {
if (fieldAsyncCatcherEnabled != null) {
fieldAsyncCatcherEnabled.set(null, true);
}
if (fieldTimingsEnabled != null && timingsEnabled) {
fieldTimingsEnabled.set(null, true);
methodCheck.invoke(null);
}
} catch (Throwable e) {
e.printStackTrace();
}
}
}
} }