mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
fix: Add timeout for GeyserBungeePingPassthrough#getPingInformation
Signed-off-by: ByteExceptionM <git@byteexception.eu>
This commit is contained in:
parent
93b0a61265
commit
d2813eff97
2 changed files with 15 additions and 3 deletions
|
|
@ -43,6 +43,8 @@ import java.net.InetSocketAddress;
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class GeyserBungeePingPassthrough implements IGeyserPingPassthrough, Listener {
|
public class GeyserBungeePingPassthrough implements IGeyserPingPassthrough, Listener {
|
||||||
|
|
@ -59,7 +61,17 @@ public class GeyserBungeePingPassthrough implements IGeyserPingPassthrough, List
|
||||||
future.complete(event);
|
future.complete(event);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
ProxyPingEvent event = future.join();
|
|
||||||
|
ProxyPingEvent event;
|
||||||
|
|
||||||
|
try {
|
||||||
|
event = future.get(100, TimeUnit.MILLISECONDS);
|
||||||
|
} catch (Throwable cause) {
|
||||||
|
proxyServer.getLogger().log(Level.SEVERE, "Failed to get ping information for " + inetSocketAddress, cause);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
ServerPing response = event.getResponse();
|
ServerPing response = event.getResponse();
|
||||||
return new GeyserPingInfo(
|
return new GeyserPingInfo(
|
||||||
response.getDescriptionComponent().toLegacyText(),
|
response.getDescriptionComponent().toLegacyText(),
|
||||||
|
|
|
||||||
|
|
@ -35,10 +35,10 @@ import java.net.InetSocketAddress;
|
||||||
public interface IGeyserPingPassthrough {
|
public interface IGeyserPingPassthrough {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the MOTD of the server displayed on the multiplayer screen
|
* Get the ping information, including the MOTD and player count, from the server
|
||||||
*
|
*
|
||||||
* @param inetSocketAddress the ip address of the client pinging the server
|
* @param inetSocketAddress the ip address of the client pinging the server
|
||||||
* @return string of the MOTD
|
* @return the ping information
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress);
|
GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue