Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Allow toggling announcing Forge support on and off
Dieser Commit ist enthalten in:
Ursprung
3eca6e9df1
Commit
a62238d073
@ -22,7 +22,7 @@ public class ServerPing {
|
|||||||
this(version, players, description, favicon, Modinfo.DEFAULT);
|
this(version, players, description, favicon, Modinfo.DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerPing(Version version, @Nullable Players players, Component description, @Nullable Favicon favicon, Modinfo modinfo) {
|
public ServerPing(Version version, @Nullable Players players, Component description, @Nullable Favicon favicon, @Nullable Modinfo modinfo) {
|
||||||
this.version = Preconditions.checkNotNull(version, "version");
|
this.version = Preconditions.checkNotNull(version, "version");
|
||||||
this.players = players;
|
this.players = players;
|
||||||
this.description = Preconditions.checkNotNull(description, "description");
|
this.description = Preconditions.checkNotNull(description, "description");
|
||||||
@ -46,6 +46,10 @@ public class ServerPing {
|
|||||||
return Optional.ofNullable(favicon);
|
return Optional.ofNullable(favicon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<Modinfo> getModinfo() {
|
||||||
|
return Optional.ofNullable(modinfo);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ServerPing{" +
|
return "ServerPing{" +
|
||||||
@ -59,11 +63,16 @@ public class ServerPing {
|
|||||||
public Builder asBuilder() {
|
public Builder asBuilder() {
|
||||||
Builder builder = new Builder();
|
Builder builder = new Builder();
|
||||||
builder.version = version;
|
builder.version = version;
|
||||||
builder.onlinePlayers = players.online;
|
if (players != null) {
|
||||||
builder.maximumPlayers = players.max;
|
builder.onlinePlayers = players.online;
|
||||||
builder.samplePlayers.addAll(players.sample);
|
builder.maximumPlayers = players.max;
|
||||||
|
builder.samplePlayers.addAll(players.sample);
|
||||||
|
} else {
|
||||||
|
builder.nullOutPlayers = true;
|
||||||
|
}
|
||||||
builder.description = description;
|
builder.description = description;
|
||||||
builder.favicon = favicon;
|
builder.favicon = favicon;
|
||||||
|
builder.nullOutModinfo = modinfo == null;
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,6 +92,7 @@ public class ServerPing {
|
|||||||
private Component description;
|
private Component description;
|
||||||
private Favicon favicon;
|
private Favicon favicon;
|
||||||
private boolean nullOutPlayers;
|
private boolean nullOutPlayers;
|
||||||
|
private boolean nullOutModinfo;
|
||||||
|
|
||||||
private Builder() {
|
private Builder() {
|
||||||
|
|
||||||
@ -123,6 +133,11 @@ public class ServerPing {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder notModCompatible() {
|
||||||
|
this.nullOutModinfo = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Builder nullPlayers() {
|
public Builder nullPlayers() {
|
||||||
this.nullOutPlayers = true;
|
this.nullOutPlayers = true;
|
||||||
return this;
|
return this;
|
||||||
@ -140,7 +155,7 @@ public class ServerPing {
|
|||||||
|
|
||||||
public ServerPing build() {
|
public ServerPing build() {
|
||||||
return new ServerPing(version, nullOutPlayers ? null : new Players(onlinePlayers, maximumPlayers, samplePlayers), description, favicon,
|
return new ServerPing(version, nullOutPlayers ? null : new Players(onlinePlayers, maximumPlayers, samplePlayers), description, favicon,
|
||||||
new Modinfo(mods));
|
nullOutModinfo ? null : new Modinfo(mods));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Version getVersion() {
|
public Version getVersion() {
|
||||||
@ -182,6 +197,7 @@ public class ServerPing {
|
|||||||
", description=" + description +
|
", description=" + description +
|
||||||
", favicon=" + favicon +
|
", favicon=" + favicon +
|
||||||
", nullOutPlayers=" + nullOutPlayers +
|
", nullOutPlayers=" + nullOutPlayers +
|
||||||
|
", nullOutModinfo=" + nullOutModinfo +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.velocitypowered.proxy.config;
|
package com.velocitypowered.proxy.config;
|
||||||
|
|
||||||
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.moandjiezana.toml.Toml;
|
import com.moandjiezana.toml.Toml;
|
||||||
import com.velocitypowered.api.util.Favicon;
|
import com.velocitypowered.api.util.Favicon;
|
||||||
@ -48,7 +49,7 @@ public class VelocityConfiguration extends AnnotatedConfig {
|
|||||||
@Comment({
|
@Comment({
|
||||||
"Should we forward IP addresses and other data to backend servers?",
|
"Should we forward IP addresses and other data to backend servers?",
|
||||||
"Available options:",
|
"Available options:",
|
||||||
"- \"none\": No forwarding will be done. All players will appear to be Should we forward IP addresses and other data to backend servers?connecting from the proxy",
|
"- \"none\": No forwarding will be done. All players will appear to be connecting from the proxy",
|
||||||
" and will have offline-mode UUIDs.",
|
" and will have offline-mode UUIDs.",
|
||||||
"- \"legacy\": Forward player IPs and UUIDs in BungeeCord-compatible fashion. Use this if you run",
|
"- \"legacy\": Forward player IPs and UUIDs in BungeeCord-compatible fashion. Use this if you run",
|
||||||
" servers using Minecraft 1.12 or lower.",
|
" servers using Minecraft 1.12 or lower.",
|
||||||
@ -62,6 +63,10 @@ public class VelocityConfiguration extends AnnotatedConfig {
|
|||||||
@ConfigKey("forwarding-secret")
|
@ConfigKey("forwarding-secret")
|
||||||
private byte[] forwardingSecret = generateRandomString(12).getBytes(StandardCharsets.UTF_8);
|
private byte[] forwardingSecret = generateRandomString(12).getBytes(StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
@Comment("Announce whether or not your server supports Forge/FML. If you run a modded server, we suggest turning this on.")
|
||||||
|
@ConfigKey("announce-forge")
|
||||||
|
private boolean announceForge = false;
|
||||||
|
|
||||||
@Table("[servers]")
|
@Table("[servers]")
|
||||||
private final Servers servers;
|
private final Servers servers;
|
||||||
|
|
||||||
@ -83,12 +88,13 @@ public class VelocityConfiguration extends AnnotatedConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private VelocityConfiguration(String bind, String motd, int showMaxPlayers, boolean onlineMode,
|
private VelocityConfiguration(String bind, String motd, int showMaxPlayers, boolean onlineMode,
|
||||||
PlayerInfoForwarding playerInfoForwardingMode, byte[] forwardingSecret, Servers servers,
|
boolean announceForge, PlayerInfoForwarding playerInfoForwardingMode, byte[] forwardingSecret,
|
||||||
Advanced advanced, Query query) {
|
Servers servers, Advanced advanced, Query query) {
|
||||||
this.bind = bind;
|
this.bind = bind;
|
||||||
this.motd = motd;
|
this.motd = motd;
|
||||||
this.showMaxPlayers = showMaxPlayers;
|
this.showMaxPlayers = showMaxPlayers;
|
||||||
this.onlineMode = onlineMode;
|
this.onlineMode = onlineMode;
|
||||||
|
this.announceForge = announceForge;
|
||||||
this.playerInfoForwardingMode = playerInfoForwardingMode;
|
this.playerInfoForwardingMode = playerInfoForwardingMode;
|
||||||
this.forwardingSecret = forwardingSecret;
|
this.forwardingSecret = forwardingSecret;
|
||||||
this.servers = servers;
|
this.servers = servers;
|
||||||
@ -263,54 +269,26 @@ public class VelocityConfiguration extends AnnotatedConfig {
|
|||||||
return favicon;
|
return favicon;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBind(String bind) {
|
public boolean isAnnounceForge() {
|
||||||
this.bind = bind;
|
return announceForge;
|
||||||
}
|
|
||||||
|
|
||||||
private void setMotd(String motd) {
|
|
||||||
this.motd = motd;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setShowMaxPlayers(int showMaxPlayers) {
|
|
||||||
this.showMaxPlayers = showMaxPlayers;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setOnlineMode(boolean onlineMode) {
|
|
||||||
this.onlineMode = onlineMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setPlayerInfoForwardingMode(PlayerInfoForwarding playerInfoForwardingMode) {
|
|
||||||
this.playerInfoForwardingMode = playerInfoForwardingMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setForwardingSecret(byte[] forwardingSecret) {
|
|
||||||
this.forwardingSecret = forwardingSecret;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setMotdAsComponent(Component motdAsComponent) {
|
|
||||||
this.motdAsComponent = motdAsComponent;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setFavicon(Favicon favicon) {
|
|
||||||
this.favicon = favicon;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
return MoreObjects.toStringHelper(this)
|
||||||
return "VelocityConfiguration{"
|
.add("configVersion", configVersion)
|
||||||
+ "bind='" + bind + '\''
|
.add("bind", bind)
|
||||||
+ ", motd='" + motd + '\''
|
.add("motd", motd)
|
||||||
+ ", showMaxPlayers=" + showMaxPlayers
|
.add("showMaxPlayers", showMaxPlayers)
|
||||||
+ ", onlineMode=" + onlineMode
|
.add("onlineMode", onlineMode)
|
||||||
+ ", playerInfoForwardingMode=" + playerInfoForwardingMode
|
.add("playerInfoForwardingMode", playerInfoForwardingMode)
|
||||||
+ ", forwardingSecret=" + ByteBufUtil.hexDump(forwardingSecret)
|
.add("forwardingSecret", forwardingSecret)
|
||||||
+ ", servers=" + servers
|
.add("announceForge", announceForge)
|
||||||
+ ", advanced=" + advanced
|
.add("servers", servers)
|
||||||
+ ", query=" + query
|
.add("advanced", advanced)
|
||||||
+ ", motdAsComponent=" + motdAsComponent
|
.add("query", query)
|
||||||
+ ", favicon=" + favicon
|
.add("favicon", favicon)
|
||||||
+ '}';
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VelocityConfiguration read(Path path) throws IOException {
|
public static VelocityConfiguration read(Path path) throws IOException {
|
||||||
@ -335,6 +313,7 @@ public class VelocityConfiguration extends AnnotatedConfig {
|
|||||||
toml.getString("motd", "&3A Velocity Server"),
|
toml.getString("motd", "&3A Velocity Server"),
|
||||||
toml.getLong("show-max-players", 500L).intValue(),
|
toml.getLong("show-max-players", 500L).intValue(),
|
||||||
toml.getBoolean("online-mode", true),
|
toml.getBoolean("online-mode", true),
|
||||||
|
toml.getBoolean("announce-forge", false),
|
||||||
PlayerInfoForwarding.valueOf(toml.getString("player-info-forwarding-mode", "MODERN").toUpperCase()),
|
PlayerInfoForwarding.valueOf(toml.getString("player-info-forwarding-mode", "MODERN").toUpperCase()),
|
||||||
forwardingSecret,
|
forwardingSecret,
|
||||||
servers,
|
servers,
|
||||||
|
@ -108,6 +108,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
|||||||
new ServerPing.Version(ProtocolConstants.MAXIMUM_GENERIC_VERSION, "Velocity " + ProtocolConstants.SUPPORTED_GENERIC_VERSION_STRING),
|
new ServerPing.Version(ProtocolConstants.MAXIMUM_GENERIC_VERSION, "Velocity " + ProtocolConstants.SUPPORTED_GENERIC_VERSION_STRING),
|
||||||
new ServerPing.Players(server.getPlayerCount(), configuration.getShowMaxPlayers(), ImmutableList.of()),
|
new ServerPing.Players(server.getPlayerCount(), configuration.getShowMaxPlayers(), ImmutableList.of()),
|
||||||
configuration.getMotdComponent(),
|
configuration.getMotdComponent(),
|
||||||
|
null,
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
ProxyPingEvent event = new ProxyPingEvent(new LegacyInboundConnection(connection), ping);
|
ProxyPingEvent event = new ProxyPingEvent(new LegacyInboundConnection(connection), ping);
|
||||||
|
@ -48,7 +48,8 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
|
|||||||
new ServerPing.Version(shownVersion, "Velocity " + ProtocolConstants.SUPPORTED_GENERIC_VERSION_STRING),
|
new ServerPing.Version(shownVersion, "Velocity " + ProtocolConstants.SUPPORTED_GENERIC_VERSION_STRING),
|
||||||
new ServerPing.Players(server.getPlayerCount(), configuration.getShowMaxPlayers(), ImmutableList.of()),
|
new ServerPing.Players(server.getPlayerCount(), configuration.getShowMaxPlayers(), ImmutableList.of()),
|
||||||
configuration.getMotdComponent(),
|
configuration.getMotdComponent(),
|
||||||
configuration.getFavicon()
|
configuration.getFavicon(),
|
||||||
|
configuration.isAnnounceForge() ? ServerPing.Modinfo.DEFAULT : null
|
||||||
);
|
);
|
||||||
|
|
||||||
ProxyPingEvent event = new ProxyPingEvent(inboundWrapper, initialPing);
|
ProxyPingEvent event = new ProxyPingEvent(inboundWrapper, initialPing);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren