#3129: Replace ConnectTimeoutException with a more user-friendly string.

This commit is contained in:
Janmm14 2021-06-26 10:05:27 +10:00 committed by md_5
parent cb738188de
commit f9583a7652
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
2 changed files with 15 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption; import io.netty.channel.ChannelOption;
import io.netty.channel.ConnectTimeoutException;
import io.netty.util.internal.PlatformDependent; import io.netty.util.internal.PlatformDependent;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.SocketAddress; import java.net.SocketAddress;
@ -351,10 +352,10 @@ public final class UserConnection implements ProxiedPlayer
connect( def, null, true, ServerConnectEvent.Reason.LOBBY_FALLBACK ); connect( def, null, true, ServerConnectEvent.Reason.LOBBY_FALLBACK );
} else if ( dimensionChange ) } else if ( dimensionChange )
{ {
disconnect( bungee.getTranslation( "fallback_kick", future.cause().getClass().getName() ) ); disconnect( bungee.getTranslation( "fallback_kick", connectionFailMessage( future.cause() ) ) );
} else } else
{ {
sendMessage( bungee.getTranslation( "fallback_kick", future.cause().getClass().getName() ) ); sendMessage( bungee.getTranslation( "fallback_kick", connectionFailMessage( future.cause() ) ) );
} }
} }
} }
@ -373,6 +374,17 @@ public final class UserConnection implements ProxiedPlayer
b.connect().addListener( listener ); b.connect().addListener( listener );
} }
private String connectionFailMessage(Throwable cause)
{
if ( cause instanceof ConnectTimeoutException )
{
return bungee.getTranslation( "timeout" );
} else
{
return cause.getClass().getName();
}
}
@Override @Override
public void disconnect(String reason) public void disconnect(String reason)
{ {

View File

@ -7,6 +7,7 @@ connect_kick=\u00a7cKicked whilst connecting to {0}: {1}
current_server=\u00a76You are currently connected to {0}. current_server=\u00a76You are currently connected to {0}.
fallback_kick=\u00a7cCould not connect to a default or fallback server, please try again later: {0} fallback_kick=\u00a7cCould not connect to a default or fallback server, please try again later: {0}
fallback_lobby=\u00a7cCould not connect to target server, you have been moved to a fallback server. fallback_lobby=\u00a7cCould not connect to target server, you have been moved to a fallback server.
timeout=Server not reachable (timeout). Offline? Incorrectly configured address/port/firewall?
lost_connection=[Proxy] Lost connection to server. lost_connection=[Proxy] Lost connection to server.
mojang_fail=Error occurred while contacting login servers, are they down? mojang_fail=Error occurred while contacting login servers, are they down?
no_permission=\u00a7cYou do not have permission to execute this command! no_permission=\u00a7cYou do not have permission to execute this command!