mirror of
https://github.com/ViaVersion/VIAaaS.git
synced 2024-11-21 11:55:15 +01:00
fix possible NPE, fix message
This commit is contained in:
parent
89f8295e0a
commit
15e77588c9
@ -25,10 +25,12 @@ public class MinecraftCodec extends MessageToMessageCodec<ByteBuf, Packet> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
var handler = ctx.pipeline().get(MinecraftHandler.class);
|
var handler = ctx.pipeline().get(MinecraftHandler.class);
|
||||||
|
var version = handler.getData().getFrontVer();
|
||||||
|
if (version == null) version = ProtocolVersion.unknown;
|
||||||
PacketRegistry.INSTANCE.encode(
|
PacketRegistry.INSTANCE.encode(
|
||||||
msg,
|
msg,
|
||||||
buf,
|
buf,
|
||||||
handler.getData().getFrontVer(),
|
version,
|
||||||
handler.getFrontEnd() ? Direction.CLIENTBOUND : Direction.SERVERBOUND
|
handler.getFrontEnd() ? Direction.CLIENTBOUND : Direction.SERVERBOUND
|
||||||
);
|
);
|
||||||
out.add(buf.retain());
|
out.add(buf.retain());
|
||||||
|
@ -54,7 +54,7 @@ public class ConfigurationState implements ConnectionState {
|
|||||||
public void disconnect(@NotNull MinecraftHandler handler, @NotNull String msg) {
|
public void disconnect(@NotNull MinecraftHandler handler, @NotNull String msg) {
|
||||||
ConnectionState.DefaultImpls.disconnect(this, handler, msg);
|
ConnectionState.DefaultImpls.disconnect(this, handler, msg);
|
||||||
var packet = new ConfigurationDisconnect();
|
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);
|
UtilKt.writeFlushClose(handler.getData().getFrontChannel(), packet, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user