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

@@ -14,8 +14,8 @@ public class ChunkMap extends Long2ObjectOpenHashMap<Chunk> {
}
public Chunk put(long i, Chunk chunk) {
org.spigotmc.AsyncCatcher.catchOp("Async Chunk put"); // Paper
chunk.world.timings.syncChunkLoadPostTimer.startTiming(); // Paper
//org.spigotmc.AsyncCatcher.catchOp("Async Chunk put"); // Paper // Akarin - comment
lastChunkByPos = chunk; // Paper
// Paper start
Chunk chunk1;
@@ -81,7 +81,7 @@ public class ChunkMap extends Long2ObjectOpenHashMap<Chunk> {
public Chunk remove(long i) {
// Paper start
org.spigotmc.AsyncCatcher.catchOp("Async Chunk remove");
//org.spigotmc.AsyncCatcher.catchOp("Async Chunk remove"); // Akarin - comment
Chunk chunk;
synchronized (this) {
// synchronize so any async gets are safe

View File

@@ -5,6 +5,9 @@ import com.destroystokyo.paper.profile.CraftPlayerProfile;
import com.destroystokyo.paper.profile.PlayerProfile;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.mojang.authlib.GameProfile;
import co.aikar.timings.ThreadAssertion;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
@@ -115,7 +118,7 @@ public final class MCUtil {
* @return
*/
public static void ensureMain(String reason, Runnable run) {
if (AsyncCatcher.enabled && Thread.currentThread() != MinecraftServer.getServer().primaryThread) {
if (AsyncCatcher.enabled && !ThreadAssertion.isMainThread() && Thread.currentThread() != MinecraftServer.getServer().primaryThread) { // Akarin
if (reason != null) {
new IllegalStateException("Asynchronous " + reason + "!").printStackTrace();
}
@@ -140,7 +143,7 @@ public final class MCUtil {
* @return
*/
public static <T> T ensureMain(String reason, Supplier<T> run) {
if (AsyncCatcher.enabled && Thread.currentThread() != MinecraftServer.getServer().primaryThread) {
if (AsyncCatcher.enabled && !ThreadAssertion.isMainThread() && Thread.currentThread() != MinecraftServer.getServer().primaryThread) { // Akarin
if (reason != null) {
new IllegalStateException("Asynchronous " + reason + "! Blocking thread until it returns ").printStackTrace();
}

View File

@@ -16,6 +16,7 @@ import com.mojang.authlib.GameProfileRepository;
import com.mojang.authlib.minecraft.MinecraftSessionService;
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import com.mojang.datafixers.DataFixer;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufOutputStream;
import io.netty.buffer.Unpooled;
@@ -65,6 +66,7 @@ import org.bukkit.event.server.ServerLoadEvent;
// CraftBukkit end
import org.spigotmc.SlackActivityAccountant; // Spigot
import co.aikar.timings.MinecraftTimings; // Paper
import co.aikar.timings.ThreadAssertion;
public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStatistics, ICommandListener, Runnable {
@@ -1704,7 +1706,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
}
public boolean isMainThread() {
return Thread.currentThread() == this.serverThread;
return ThreadAssertion.isMainThread() || Thread.currentThread() == this.serverThread; // Akarin
}
public int aw() {

View File

@@ -69,6 +69,7 @@ import com.destroystokyo.paper.event.player.IllegalPacketEvent; // Paper
import com.destroystokyo.paper.event.player.PlayerJumpEvent; // Paper
import co.aikar.timings.MinecraftTimings; // Paper
// CraftBukkit end
import co.aikar.timings.ThreadAssertion;
public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@@ -1756,7 +1757,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
if (!async && s.startsWith("/")) {
// Paper Start
if (!org.spigotmc.AsyncCatcher.shuttingDown && !org.bukkit.Bukkit.isPrimaryThread()) {
if (!org.spigotmc.AsyncCatcher.shuttingDown && !ThreadAssertion.isMainThread() && !org.bukkit.Bukkit.isPrimaryThread()) {
final String fCommandLine = s;
MinecraftServer.LOGGER.log(org.apache.logging.log4j.Level.ERROR, "Command Dispatched Async: " + fCommandLine);
MinecraftServer.LOGGER.log(org.apache.logging.log4j.Level.ERROR, "Please notify author of plugin causing this execution to fix this bug! see: http://bit.ly/1oSiM6C", new Throwable());