fix possible NPE, fix message

This commit is contained in:
creeper123123321 2024-03-07 10:37:48 -03:00
parent 89f8295e0a
commit 15e77588c9
2 changed files with 4 additions and 2 deletions

View File

@ -25,10 +25,12 @@ public class MinecraftCodec extends MessageToMessageCodec<ByteBuf, Packet> {
try {
var handler = ctx.pipeline().get(MinecraftHandler.class);
var version = handler.getData().getFrontVer();
if (version == null) version = ProtocolVersion.unknown;
PacketRegistry.INSTANCE.encode(
msg,
buf,
handler.getData().getFrontVer(),
version,
handler.getFrontEnd() ? Direction.CLIENTBOUND : Direction.SERVERBOUND
);
out.add(buf.retain());

View File

@ -54,7 +54,7 @@ public class ConfigurationState implements ConnectionState {
public void disconnect(@NotNull MinecraftHandler handler, @NotNull String msg) {
ConnectionState.DefaultImpls.disconnect(this, handler, msg);
var packet = new ConfigurationDisconnect();
packet.setMsgForVersion(new JsonPrimitive("[VIAaaS] §c$msg"), handler.getData().getFrontVer());
packet.setMsgForVersion(new JsonPrimitive("[VIAaaS] §c" + msg), handler.getData().getFrontVer());
UtilKt.writeFlushClose(handler.getData().getFrontChannel(), packet, false);
}