Skip to content

Commit

Permalink
better async packet warn handler
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jul 27, 2021
1 parent 8292147 commit ba0e107
Showing 1 changed file with 13 additions and 2 deletions.
Expand Up @@ -158,15 +158,26 @@ public void send(Packet<?> packet) {
send(packet, null);
}

private static boolean hasShownAsyncWarning = false;

@Override
public void send(Packet<?> packet, GenericFutureListener<? extends Future<? super Void>> genericfuturelistener) {
if (NMSHandler.debugPackets) {
Debug.log("Packet: " + packet.getClass().getCanonicalName() + " sent to " + player.getScoreboardName());
}
if (!Bukkit.isPrimaryThread()) {
if (Debug.verbose) {
Debug.log("Warning: packet sent off main thread! This is completely unsupported behavior! Denizen network inteceptor ignoring packet to avoid crash. Packet class: " + packet.getClass().getCanonicalName() + " sent to " + player.getScoreboardName());
if (Debug.verbose || !hasShownAsyncWarning) {
hasShownAsyncWarning = true;
Debug.echoError("Warning: packet sent off main thread! This is completely unsupported behavior! Denizen network interceptor ignoring packet to avoid crash. Packet class: "
+ packet.getClass().getCanonicalName() + " sent to " + player.getScoreboardName() + " identify the sender of the packet from the stack trace:");
try {
throw new RuntimeException("Trace");
}
catch (Exception ex) {
Debug.echoError(ex);
}
}
oldManager.send(packet, genericfuturelistener);
return;
}
packetsSent++;
Expand Down

0 comments on commit ba0e107

Please sign in to comment.