Add ServerConnectRequest#sendFeedback

This commit is contained in:
Shane Freeder 2021-04-16 06:34:54 +01:00
parent 539846d9ab
commit 3f86a428c9
No known key found for this signature in database
GPG Key ID: A3F61EA5A085289C
1 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,74 @@
From 8e2bdaf9cb2da6becb7065bd7a9ef94c18665f66 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Fri, 16 Apr 2021 06:29:28 +0100
Subject: [PATCH] ServerConnectRequest#sendFeedback
diff --git a/api/src/main/java/net/md_5/bungee/api/ServerConnectRequest.java b/api/src/main/java/net/md_5/bungee/api/ServerConnectRequest.java
index c81b0a4e..d21370be 100644
--- a/api/src/main/java/net/md_5/bungee/api/ServerConnectRequest.java
+++ b/api/src/main/java/net/md_5/bungee/api/ServerConnectRequest.java
@@ -68,6 +68,14 @@ public class ServerConnectRequest
*/
@Setter
private boolean retry;
+ // Waterfall start
+ /**
+ * Should feedback from the request be sent to players, allows plugins
+ * to silently deal with the outcome on their own
+ */
+ @Setter
+ private boolean sendFeedback;
+ // Waterfall end
/**
* Class that sets default properties/adds methods to the lombok builder
@@ -77,5 +85,6 @@ public class ServerConnectRequest
{
private int connectTimeout = ProxyServer.getInstance().getConfig().getServerConnectTimeout();
+ private boolean isSendFeedback = true; // Waterfall # God. f##king. lombok.
}
}
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 871a2990..8e274169 100644
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
@@ -321,7 +321,7 @@ public final class UserConnection implements ProxiedPlayer
callback.done( ServerConnectRequest.Result.ALREADY_CONNECTED, null );
}
- sendMessage( bungee.getTranslation( "already_connected" ) );
+ if (request.isSendFeedback()) sendMessage( bungee.getTranslation( "already_connected" ) ); // Waterfall
return;
}
if ( pendingConnects.contains( target ) )
@@ -331,7 +331,7 @@ public final class UserConnection implements ProxiedPlayer
callback.done( ServerConnectRequest.Result.ALREADY_CONNECTING, null );
}
- sendMessage( bungee.getTranslation( "already_connecting" ) );
+ if (request.isSendFeedback()) sendMessage( bungee.getTranslation( "already_connecting" ) ); // Waterfall
return;
}
@@ -367,14 +367,14 @@ public final class UserConnection implements ProxiedPlayer
ServerInfo def = updateAndGetNextServer( target );
if ( request.isRetry() && def != null && ( getServer() == null || def != getServer().getInfo() ) )
{
- sendMessage( bungee.getTranslation( "fallback_lobby" ) );
+ if (request.isSendFeedback()) sendMessage( bungee.getTranslation( "fallback_lobby" ) ); // Waterfall
connect( def, null, true, ServerConnectEvent.Reason.LOBBY_FALLBACK, request.getConnectTimeout() ); // Waterfall
} else if ( dimensionChange )
{
disconnect( bungee.getTranslation( "fallback_kick", connectionFailMessage( future.cause() ) ) );
} else
{
- sendMessage( bungee.getTranslation( "fallback_kick", connectionFailMessage( future.cause() ) ) );
+ if (request.isSendFeedback()) sendMessage( bungee.getTranslation( "fallback_kick", connectionFailMessage( future.cause() ) ) );
}
}
}
--
2.35.0