mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-10-03 00:47:27 +02:00
c21eed1f7b
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing BungeeCord Changes: 70370faf Add checkstyle indentation checks 24a53a67 Show socketAddress in BungeeServerInfo.toString 503b4827 Fix bad formatting in EntityMap eeb37479 #2710: Store queue of pending keepalives 3f6aa033 Also check that things that should not be padded are so 78a84953 Add more checkstyle rules 636c0207 #2753: Add configurable remote ping caching a4512e50 Check Maven version in action build & don't print noisy transfer progress f510989c Add building of pull requests via GitHub Actions
114 lines
5.7 KiB
Diff
114 lines
5.7 KiB
Diff
From fb2ee4df44963c8232471e2cef7964144697a67e Mon Sep 17 00:00:00 2001
|
|
From: Ichbinjoe <joe@ibj.io>
|
|
Date: Sat, 16 Jul 2016 20:44:01 -0400
|
|
Subject: [PATCH] Add timeout variant to connect methods
|
|
|
|
Also added more connect methods to ProxiedPlayer, in addition to the new method
|
|
|
|
diff --git a/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java b/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java
|
|
index 867e4428..f7459860 100644
|
|
--- a/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java
|
|
+++ b/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java
|
|
@@ -111,6 +111,38 @@ public interface ProxiedPlayer extends Connection, CommandSender
|
|
*/
|
|
void connect(ServerInfo target, Callback<Boolean> callback);
|
|
|
|
+ // Waterfall start
|
|
+ /**
|
|
+ * Connects / transfers this user to the specified connection, gracefully
|
|
+ * closing the current one. Depending on the implementation, this method
|
|
+ * might return before the user has been connected.
|
|
+ *
|
|
+ * @param target the new server to connect to
|
|
+ * @param callback the method called when the connection is complete, or
|
|
+ * when an exception is encountered. The boolean parameter denotes success
|
|
+ * or failure.
|
|
+ * @param retry whether to retry the connection if the initial connection
|
|
+ * fails.
|
|
+ */
|
|
+ void connect(ServerInfo target, Callback<Boolean> callback, boolean retry);
|
|
+
|
|
+ /**
|
|
+ * Connects / transfers this user to the specified connection, gracefully
|
|
+ * closing the current one. Depending on the implementation, this method
|
|
+ * might return before the user has been connected.
|
|
+ *
|
|
+ * @param target the new server to connect to
|
|
+ * @param callback the method called when the connection is complete, or
|
|
+ * when an exception is encountered. The boolean parameter denotes success
|
|
+ * or failure.
|
|
+ * @param retry whether to retry the connection if the initial connection
|
|
+ * fails.
|
|
+ * @param timeout timeout in milliseconds of the connection created to the
|
|
+ * target server
|
|
+ */
|
|
+ void connect(ServerInfo target, Callback<Boolean> callback, boolean retry, int timeout);
|
|
+ // Waterfall end
|
|
+
|
|
/**
|
|
* Connects / transfers this user to the specified connection, gracefully
|
|
* closing the current one. Depending on the implementation, this method
|
|
@@ -124,6 +156,25 @@ public interface ProxiedPlayer extends Connection, CommandSender
|
|
*/
|
|
void connect(ServerInfo target, Callback<Boolean> callback, ServerConnectEvent.Reason reason);
|
|
|
|
+ // Waterfall start
|
|
+ /**
|
|
+ * Connects / transfers this user to the specified connection, gracefully
|
|
+ * closing the current one. Depending on the implementation, this method
|
|
+ * might return before the user has been connected.
|
|
+ *
|
|
+ * @param target the new server to connect to
|
|
+ * @param callback the method called when the connection is complete, or
|
|
+ * when an exception is encountered. The boolean parameter denotes success
|
|
+ * or failure.
|
|
+ * @param retry whether to retry the connection if the initial connection
|
|
+ * fails.
|
|
+ * @param reason the reason for connecting to the new server
|
|
+ * @param timeout timeout in milliseconds of the connection created to the
|
|
+ * target server
|
|
+ */
|
|
+ void connect(ServerInfo target, Callback<Boolean> callback, boolean retry, ServerConnectEvent.Reason reason, int timeout);
|
|
+ // Waterfall end
|
|
+
|
|
/**
|
|
* Connects / transfers this user to the specified connection, gracefully
|
|
* closing the current one. Depending on the implementation, this method
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
|
index 3c0c4189..3f9a91e3 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
|
@@ -254,9 +254,20 @@ public final class UserConnection implements ProxiedPlayer
|
|
|
|
public void connect(ServerInfo info, final Callback<Boolean> callback, final boolean retry, ServerConnectEvent.Reason reason)
|
|
{
|
|
+ // Waterfall start
|
|
+ connect(info, callback, retry, reason, 5000); // todo: configurable
|
|
+ }
|
|
+ public void connect(ServerInfo info, final Callback<Boolean> callback, final boolean retry, int timeout) {
|
|
+ connect(info, callback, retry, ServerConnectEvent.Reason.PLUGIN, timeout);
|
|
+ }
|
|
+
|
|
+ public void connect(ServerInfo info, final Callback<Boolean> callback, final boolean retry, ServerConnectEvent.Reason reason, final int timeout)
|
|
+ {
|
|
+ // Waterfall end
|
|
Preconditions.checkNotNull( info, "info" );
|
|
|
|
ServerConnectRequest.Builder builder = ServerConnectRequest.builder().retry( retry ).reason( reason ).target( info );
|
|
+ builder.connectTimeout(timeout); // Waterfall
|
|
if ( callback != null )
|
|
{
|
|
// Convert the Callback<Boolean> to be compatible with Callback<Result> from ServerConnectRequest.
|
|
@@ -350,7 +361,7 @@ public final class UserConnection implements ProxiedPlayer
|
|
if ( request.isRetry() && def != null && ( getServer() == null || def != getServer().getInfo() ) )
|
|
{
|
|
sendMessage( bungee.getTranslation( "fallback_lobby" ) );
|
|
- connect( def, null, true, ServerConnectEvent.Reason.LOBBY_FALLBACK );
|
|
+ connect( def, null, true, ServerConnectEvent.Reason.LOBBY_FALLBACK, request.getConnectTimeout() ); // Waterfall
|
|
} else if ( dimensionChange )
|
|
{
|
|
disconnect( bungee.getTranslation( "fallback_kick", future.cause().getClass().getName() ) );
|
|
--
|
|
2.25.0
|
|
|