mirror of
https://github.com/ViaVersion/ViaLegacy.git
synced 2024-06-28 10:44:50 +02:00
Fixed NPE when channel of user is null
This commit is contained in:
parent
109ef52ec7
commit
97464ce3b0
|
@ -6,4 +6,4 @@ org.gradle.configureondemand=true
|
|||
# Project properties
|
||||
maven_name=ViaLegacy
|
||||
maven_group=net.raphimc
|
||||
maven_version=2.2.0
|
||||
maven_version=2.2.1
|
||||
|
|
|
@ -1189,19 +1189,21 @@ public class Protocol1_7_2_5to1_6_4 extends AbstractProtocol<ClientboundPackets1
|
|||
}
|
||||
userConnection.put(new ChunkTracker(userConnection));
|
||||
|
||||
userConnection.getChannel().pipeline().addFirst(new ChannelOutboundHandlerAdapter() {
|
||||
@Override
|
||||
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
|
||||
if (userConnection.getProtocolInfo().getState().equals(State.PLAY) && ctx.channel().isWritable() && userConnection.get(PlayerInfoStorage.class).entityId != -1) {
|
||||
final PacketWrapper disconnect = PacketWrapper.create(ServerboundPackets1_6_4.DISCONNECT, userConnection);
|
||||
disconnect.write(Types1_6_4.STRING, "Quitting"); // reason
|
||||
disconnect.sendToServer(Protocol1_7_2_5to1_6_4.class);
|
||||
Thread.sleep(50); // Wait for the packet to arrive at the server
|
||||
}
|
||||
if (userConnection.getChannel() != null) {
|
||||
userConnection.getChannel().pipeline().addFirst(new ChannelOutboundHandlerAdapter() {
|
||||
@Override
|
||||
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
|
||||
if (userConnection.getProtocolInfo().getState().equals(State.PLAY) && ctx.channel().isWritable() && userConnection.get(PlayerInfoStorage.class).entityId != -1) {
|
||||
final PacketWrapper disconnect = PacketWrapper.create(ServerboundPackets1_6_4.DISCONNECT, userConnection);
|
||||
disconnect.write(Types1_6_4.STRING, "Quitting"); // reason
|
||||
disconnect.sendToServer(Protocol1_7_2_5to1_6_4.class);
|
||||
Thread.sleep(50); // Wait for the packet to arrive at the server
|
||||
}
|
||||
|
||||
super.close(ctx, promise);
|
||||
}
|
||||
});
|
||||
super.close(ctx, promise);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user