mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-11-14 19:34:58 -05:00
Cleanup and fix nullabilities in custom payload/query packets (#759)
This commit is contained in:
parent
2151d360b1
commit
82ffc874b1
4 changed files with 7 additions and 6 deletions
|
@ -15,7 +15,7 @@ import java.io.IOException;
|
|||
@AllArgsConstructor
|
||||
public class ClientboundCustomPayloadPacket implements MinecraftPacket {
|
||||
private final @NonNull String channel;
|
||||
private final @NonNull byte[] data;
|
||||
private final byte @NonNull[] data;
|
||||
|
||||
public ClientboundCustomPayloadPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
||||
this.channel = helper.readString(in);
|
||||
|
|
|
@ -15,7 +15,7 @@ import java.io.IOException;
|
|||
@AllArgsConstructor
|
||||
public class ServerboundCustomPayloadPacket implements MinecraftPacket {
|
||||
private final @NonNull String channel;
|
||||
private final @NonNull byte data[];
|
||||
private final byte @NonNull[] data;
|
||||
|
||||
public ServerboundCustomPayloadPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
||||
this.channel = helper.readString(in);
|
||||
|
|
|
@ -16,7 +16,7 @@ import java.io.IOException;
|
|||
public class ClientboundCustomQueryPacket implements MinecraftPacket {
|
||||
private final int messageId;
|
||||
private final @NonNull String channel;
|
||||
private final @NonNull byte[] data;
|
||||
private final byte @NonNull[] data;
|
||||
|
||||
public ClientboundCustomQueryPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
||||
this.messageId = helper.readVarInt(in);
|
||||
|
|
|
@ -6,13 +6,14 @@ import io.netty.buffer.ByteBuf;
|
|||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.With;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@Data
|
||||
@With
|
||||
@AllArgsConstructor
|
||||
public class ServerboundCustomQueryAnswerPacket implements MinecraftPacket {
|
||||
private final int transactionId;
|
||||
private final byte[] data;
|
||||
private final byte @Nullable[] data;
|
||||
|
||||
public ServerboundCustomQueryAnswerPacket(int transactionId) {
|
||||
this(transactionId, new byte[0]);
|
||||
|
@ -20,12 +21,12 @@ public class ServerboundCustomQueryAnswerPacket implements MinecraftPacket {
|
|||
|
||||
public ServerboundCustomQueryAnswerPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||
this.transactionId = helper.readVarInt(in);
|
||||
this.data = helper.readByteArray(in, ByteBuf::readableBytes);
|
||||
this.data = helper.readNullable(in, buf -> helper.readByteArray(buf, ByteBuf::readableBytes));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||
helper.writeVarInt(out, this.transactionId);
|
||||
out.writeBytes(this.data);
|
||||
helper.writeNullable(out, this.data, ByteBuf::writeBytes);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue