3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-06 00:00:47 +01:00

Allow ping passthrough for descriptions too

Dieser Commit ist enthalten in:
Andrew Steinborn 2020-02-21 18:36:10 -05:00
Ursprung c63bd4cd02
Commit 3e053d63b4
3 geänderte Dateien mit 30 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -3,5 +3,6 @@ package com.velocitypowered.proxy.config;
public enum PingPassthroughMode { public enum PingPassthroughMode {
DISABLED, DISABLED,
MODS, MODS,
DESCRIPTION,
ALL ALL
} }

Datei anzeigen

@ -90,14 +90,17 @@ public class VelocityConfiguration extends AnnotatedConfig implements ProxyConfi
@Comment({ @Comment({
"Should Velocity pass server list ping requests to a backend server?", "Should Velocity pass server list ping requests to a backend server?",
"Available options:", "Available options:",
"- \"disabled\": No pass-through will be done. The velocity.toml and server-icon.png", "- \"disabled\": No pass-through will be done. The velocity.toml and server-icon.png",
" will determine the initial server list ping response.", " will determine the initial server list ping response.",
"- \"mods\": Passes only the mod list from your backend server into the response.", "- \"mods\": Passes only the mod list from your backend server into the response.",
" The first server in your try list (or forced host) with a mod list will be", " The first server in your try list (or forced host) with a mod list will be",
" used. If no backend servers can be contacted, Velocity will not display any", " used. If no backend servers can be contacted, Velocity will not display any",
" mod information.", " mod information.",
"- \"all\": Passes everything from the backend server into the response. The Velocity", "- \"description\": Uses the description and mod list from the backend server. The first",
" configuration is used if no servers could be contacted." " server in the try (or forced host) list that responds is used for the",
" description and mod list.",
"- \"all\": Passes everything from the backend server into the response. The Velocity",
" configuration is used if no servers could be contacted."
}) })
@ConfigKey("ping-passthrough") @ConfigKey("ping-passthrough")
private PingPassthroughMode pingPassthrough = PingPassthroughMode.DISABLED; private PingPassthroughMode pingPassthrough = PingPassthroughMode.DISABLED;

Datei anzeigen

@ -97,6 +97,24 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
} }
return fallback; return fallback;
}); });
case DESCRIPTION:
return pingResponses.thenApply(responses -> {
// Find the first non-fallback. If it includes a modlist, add it too.
for (ServerPing response : responses) {
if (response == fallback) {
continue;
}
return new ServerPing(
fallback.getVersion(),
fallback.getPlayers().orElse(null),
response.getDescription(),
fallback.getFavicon().orElse(null),
response.getModinfo().orElse(null)
);
}
return fallback;
});
default: default:
// Not possible, but covered for completeness. // Not possible, but covered for completeness.
return CompletableFuture.completedFuture(fallback); return CompletableFuture.completedFuture(fallback);