mirror of
https://github.com/PaperMC/Velocity.git
synced 2026-02-18 06:57:43 +01:00
Convert ClientboundLoginPluginMessagePacket encoding to PacketWriter
This commit is contained in:
@@ -42,27 +42,21 @@ public class ClientboundLoginPluginMessagePacket extends DefaultByteBufHolder im
|
|||||||
}
|
}
|
||||||
return new ClientboundLoginPluginMessagePacket(id, channel, data);
|
return new ClientboundLoginPluginMessagePacket(id, channel, data);
|
||||||
};
|
};
|
||||||
public static final PacketWriter<ClientboundLoginPluginMessagePacket> ENCODER = PacketWriter.deprecatedEncode();
|
public static final PacketWriter<ClientboundLoginPluginMessagePacket> ENCODER = (out, packet, version) -> {
|
||||||
|
ProtocolUtils.writeVarInt(out, packet.id);
|
||||||
|
ProtocolUtils.writeString(out, packet.channel);
|
||||||
|
out.writeBytes(packet.content());
|
||||||
|
};
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
private final @Nullable String channel;
|
private final String channel;
|
||||||
|
|
||||||
public ClientboundLoginPluginMessagePacket(int id, @Nullable String channel, ByteBuf data) {
|
public ClientboundLoginPluginMessagePacket(int id, String channel, ByteBuf data) {
|
||||||
super(data);
|
super(data);
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void encode(ByteBuf buf, ProtocolVersion version) {
|
|
||||||
ProtocolUtils.writeVarInt(buf, id);
|
|
||||||
if (channel == null) {
|
|
||||||
throw new IllegalStateException("Channel is not specified!");
|
|
||||||
}
|
|
||||||
ProtocolUtils.writeString(buf, channel);
|
|
||||||
buf.writeBytes(content());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(PacketHandler handler) {
|
public boolean handle(PacketHandler handler) {
|
||||||
return handler.handle(this);
|
return handler.handle(this);
|
||||||
@@ -73,9 +67,6 @@ public class ClientboundLoginPluginMessagePacket extends DefaultByteBufHolder im
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getChannel() {
|
public String getChannel() {
|
||||||
if (channel == null) {
|
|
||||||
throw new IllegalStateException("Channel is not specified!");
|
|
||||||
}
|
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user