mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-22 23:58:02 -05:00
Fix errors not showing up in disconnect messages (#2266)
* Fix errors causing disconnects during server connection not showing up in the disconnect message * Replace unnecessary inject with the throwable provided in the redirect
This commit is contained in:
parent
0534af997f
commit
e6b169ebca
1 changed files with 5 additions and 4 deletions
|
@ -66,13 +66,14 @@ abstract class ClientConnectionMixin implements ChannelInfoHolder {
|
||||||
// Must be fully qualified due to mixin not working in production without it
|
// Must be fully qualified due to mixin not working in production without it
|
||||||
@SuppressWarnings("UnnecessaryQualifiedMemberReference")
|
@SuppressWarnings("UnnecessaryQualifiedMemberReference")
|
||||||
@Redirect(method = "Lnet/minecraft/network/ClientConnection;exceptionCaught(Lio/netty/channel/ChannelHandlerContext;Ljava/lang/Throwable;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;send(Lnet/minecraft/network/Packet;Lio/netty/util/concurrent/GenericFutureListener;)V"))
|
@Redirect(method = "Lnet/minecraft/network/ClientConnection;exceptionCaught(Lio/netty/channel/ChannelHandlerContext;Ljava/lang/Throwable;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;send(Lnet/minecraft/network/Packet;Lio/netty/util/concurrent/GenericFutureListener;)V"))
|
||||||
private void resendOnExceptionCaught(ClientConnection self, Packet<?> packet, GenericFutureListener<? extends Future<? super Void>> listener) {
|
private void resendOnExceptionCaught(ClientConnection self, Packet<?> packet, GenericFutureListener<? extends Future<? super Void>> listener, ChannelHandlerContext context, Throwable ex) {
|
||||||
PacketListener handler = this.packetListener;
|
PacketListener handler = this.packetListener;
|
||||||
|
Text disconnectMessage = new TranslatableText("disconnect.genericReason", "Internal Exception: " + ex);
|
||||||
|
|
||||||
if (handler instanceof DisconnectPacketSource) {
|
if (handler instanceof DisconnectPacketSource) {
|
||||||
this.send(((DisconnectPacketSource) handler).createDisconnectPacket(new TranslatableText("disconnect.genericReason")), listener);
|
this.send(((DisconnectPacketSource) handler).createDisconnectPacket(disconnectMessage), listener);
|
||||||
} else {
|
} else {
|
||||||
this.disconnect(new TranslatableText("disconnect.genericReason")); // Don't send packet if we cannot send proper packets
|
this.disconnect(disconnectMessage); // Don't send packet if we cannot send proper packets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +85,7 @@ abstract class ClientConnectionMixin implements ChannelInfoHolder {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "channelInactive", at = @At("HEAD"))
|
@Inject(method = "channelInactive", at = @At("HEAD"))
|
||||||
private void handleDisconnect(ChannelHandlerContext channelHandlerContext, CallbackInfo ci) throws Exception {
|
private void handleDisconnect(ChannelHandlerContext channelHandlerContext, CallbackInfo ci) {
|
||||||
if (packetListener instanceof NetworkHandlerExtensions) { // not the case for client/server query
|
if (packetListener instanceof NetworkHandlerExtensions) { // not the case for client/server query
|
||||||
((NetworkHandlerExtensions) packetListener).getAddon().handleDisconnect();
|
((NetworkHandlerExtensions) packetListener).getAddon().handleDisconnect();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue