mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-27 16:12:23 -05:00
Account for packet potentially being null in the PacketErrorEvent
This commit is contained in:
parent
29f4e867de
commit
ba6b90c288
2 changed files with 4 additions and 4 deletions
|
@ -18,10 +18,10 @@ public class PacketErrorEvent implements SessionEvent {
|
||||||
* @param session Session that the error came from.
|
* @param session Session that the error came from.
|
||||||
* @param cause Cause of the error.
|
* @param cause Cause of the error.
|
||||||
*/
|
*/
|
||||||
public PacketErrorEvent(Session session, Throwable cause, @Nullable Class<? extends Packet> packetClass) {
|
public PacketErrorEvent(Session session, Throwable cause, @Nullable Packet packetClass) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
this.cause = cause;
|
this.cause = cause;
|
||||||
this.packetClass = packetClass;
|
this.packetClass = packetClass == null ? null : packetClass.getClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class TcpPacketCodec extends MessageToMessageCodec<ByteBuf, Packet> {
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
log.debug(marker, "Error encoding packet", t);
|
log.debug(marker, "Error encoding packet", t);
|
||||||
|
|
||||||
PacketErrorEvent e = new PacketErrorEvent(this.session, t, packet.getClass());
|
PacketErrorEvent e = new PacketErrorEvent(this.session, t, packet);
|
||||||
this.session.callEvent(e);
|
this.session.callEvent(e);
|
||||||
if (!e.shouldSuppress()) {
|
if (!e.shouldSuppress()) {
|
||||||
throw new EncoderException(t);
|
throw new EncoderException(t);
|
||||||
|
@ -104,7 +104,7 @@ public class TcpPacketCodec extends MessageToMessageCodec<ByteBuf, Packet> {
|
||||||
// Advance buffer to end to make sure remaining data in this packet is skipped.
|
// Advance buffer to end to make sure remaining data in this packet is skipped.
|
||||||
buf.readerIndex(buf.readerIndex() + buf.readableBytes());
|
buf.readerIndex(buf.readerIndex() + buf.readableBytes());
|
||||||
|
|
||||||
PacketErrorEvent e = new PacketErrorEvent(this.session, t, packet.getClass());
|
PacketErrorEvent e = new PacketErrorEvent(this.session, t, packet);
|
||||||
this.session.callEvent(e);
|
this.session.callEvent(e);
|
||||||
if (!e.shouldSuppress()) {
|
if (!e.shouldSuppress()) {
|
||||||
throw new DecoderException(t);
|
throw new DecoderException(t);
|
||||||
|
|
Loading…
Reference in a new issue