This commit is contained in:
Sotr
2019-03-19 05:00:23 +08:00
parent 9ccbd91d78
commit dbfd5f4f2d
14 changed files with 346 additions and 20 deletions

View File

@@ -139,6 +139,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.LiteralCommandNode;
import co.aikar.timings.ThreadAssertion;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufOutputStream;
import io.netty.buffer.Unpooled;
@@ -709,7 +710,7 @@ public final class CraftServer implements Server {
org.spigotmc.AsyncCatcher.catchOp( "command dispatch" ); // Spigot
// Paper Start
if (!org.spigotmc.AsyncCatcher.shuttingDown && !Bukkit.isPrimaryThread()) {
if (!org.spigotmc.AsyncCatcher.shuttingDown && !ThreadAssertion.isMainThread() && !Bukkit.isPrimaryThread()) { // Akarin
final CommandSender fSender = sender;
final String fCommandLine = commandLine;
Bukkit.getLogger().log(Level.SEVERE, "Command Dispatched Async: " + commandLine);
@@ -1723,7 +1724,7 @@ public final class CraftServer implements Server {
@Override
public boolean isPrimaryThread() {
return Thread.currentThread().equals(console.primaryThread);
return ThreadAssertion.isMainThread() || Thread.currentThread().equals(console.primaryThread);
}
@Override

View File

@@ -40,7 +40,7 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider<QueuedChu
queuedChunk.provider.getChunkAt(queuedChunk.x, queuedChunk.z, true, true); // Paper - actually call original if it was already loaded
return;
}
try (Timing ignored = queuedChunk.provider.world.timings.chunkIOStage2.startTimingIfSync()) { // Paper
try (Timing ignored = queuedChunk.provider.world.timings.chunkIOStage2.startTimingIfSync(true)) { // Paper // Akarin
queuedChunk.loader.loadEntities(queuedChunk.compound.getCompound("Level"), chunk);
chunk.setLastSaved(queuedChunk.provider.world.getTime());

View File

@@ -1,5 +1,6 @@
package org.spigotmc;
import co.aikar.timings.ThreadAssertion;
import net.minecraft.server.MinecraftServer;
public class AsyncCatcher
@@ -10,7 +11,7 @@ public class AsyncCatcher
public static void catchOp(String reason)
{
if ( enabled && Thread.currentThread() != MinecraftServer.getServer().primaryThread )
if ( enabled && !ThreadAssertion.isMainThread() && Thread.currentThread() != MinecraftServer.getServer().primaryThread )
{
throw new IllegalStateException( "Asynchronous " + reason + "!" );
}