Add missing nullability annotation

This commit is contained in:
Andrew Steinborn
2021-05-14 09:28:57 -04:00
parent 0af9d9d77b
commit e65c4102a6
2 changed files with 8 additions and 9 deletions

View File

@@ -42,7 +42,12 @@ public class ServerboundLoginPluginResponsePacket extends DefaultByteBufHolder i
}
return new ServerboundLoginPluginResponsePacket(id, success, data);
};
public static final PacketWriter<ServerboundLoginPluginResponsePacket> ENCODER = PacketWriter.deprecatedEncode();
public static final PacketWriter<ServerboundLoginPluginResponsePacket> ENCODER =
(out, packet, version) -> {
ProtocolUtils.writeVarInt(out, packet.id);
out.writeBoolean(packet.success);
out.writeBytes(packet.content());
};
private final int id;
private final boolean success;
@@ -53,13 +58,6 @@ public class ServerboundLoginPluginResponsePacket extends DefaultByteBufHolder i
this.success = success;
}
@Override
public void encode(ByteBuf buf, ProtocolVersion version) {
ProtocolUtils.writeVarInt(buf, id);
buf.writeBoolean(success);
buf.writeBytes(content());
}
@Override
public boolean handle(PacketHandler handler) {
return handler.handle(this);

View File

@@ -31,6 +31,7 @@ import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.codec.CorruptedFrameException;
import org.checkerframework.checker.nullness.qual.Nullable;
public class MinecraftDecoder extends ChannelInboundHandlerAdapter {
@@ -96,7 +97,7 @@ public class MinecraftDecoder extends ChannelInboundHandlerAdapter {
}
}
private Packet readPacket(int packetId, ByteBuf buf) throws Exception {
private @Nullable Packet readPacket(int packetId, ByteBuf buf) throws Exception {
PacketReader<? extends Packet> reader = this.registry.lookupReader(packetId, this.version);
if (reader == null) {
return null;