Properly iterate through parents

This commit is contained in:
AlexProgrammerDE 2024-09-12 11:28:04 +02:00
parent 6507e77bbe
commit 4e2b64d983
2 changed files with 17 additions and 1 deletions

View file

@ -0,0 +1,15 @@
package org.geysermc.mcprotocollib.network.helper;
public class PipelineHelper {
public static boolean containsCause(Throwable t, Class<?> c) {
do {
if (c.isAssignableFrom(t.getClass())) {
return true;
}
t = t.getCause();
} while (t != null);
return false;
}
}

View file

@ -21,6 +21,7 @@ import org.geysermc.mcprotocollib.network.event.session.DisconnectingEvent;
import org.geysermc.mcprotocollib.network.event.session.PacketSendingEvent;
import org.geysermc.mcprotocollib.network.event.session.SessionEvent;
import org.geysermc.mcprotocollib.network.event.session.SessionListener;
import org.geysermc.mcprotocollib.network.helper.PipelineHelper;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.network.packet.PacketCancelException;
import org.geysermc.mcprotocollib.network.packet.PacketProtocol;
@ -316,7 +317,7 @@ public abstract class TcpSession extends SimpleChannelInboundHandler<Packet> imp
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
if (cause instanceof PacketCancelException) {
if (PipelineHelper.containsCause(cause, PacketCancelException.class)) {
return;
}