Skip to content

Commit

Permalink
Cleanup and implementation of all-possible placeholders for server brand
Browse files Browse the repository at this point in the history
  • Loading branch information
R00tB33rMan committed Oct 30, 2024
1 parent c61d133 commit 6f911f4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,10 @@ public boolean handle(final RemoveResourcePackPacket packet) {
public boolean handle(final FinishedUpdatePacket packet) {
final MinecraftConnection smc = serverConn.ensureConnected();
final ConnectedPlayer player = serverConn.getPlayer();

if (!(player.getConnection().getActiveSessionHandler() instanceof ClientConfigSessionHandler configHandler)) {
logger.error("Player hasn't established a full connection yet.");
return false;
}
final ClientConfigSessionHandler configHandler = (ClientConfigSessionHandler) player.getConnection().getActiveSessionHandler();

smc.getChannel().pipeline().get(MinecraftDecoder.class).setState(StateRegistry.PLAY);
//noinspection DataFlowIssue
configHandler.handleBackendFinishUpdate(serverConn).thenRunAsync(() -> {
smc.write(FinishedUpdatePacket.INSTANCE);
if (serverConn == player.getConnectedServer()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ private ServerPing constructLocalPing(ProtocolVersion version) {

private String formatVersionString(final String raw, final ProtocolVersion version) {
String minVersionIntroducedIn = ProtocolVersion.getVersionByName(this.server.getConfiguration().getMinimumVersion()).getVersionIntroducedIn();
return raw.replaceAll("\\{protocol-min}", minVersionIntroducedIn)
return raw
.replaceAll("\\{protocol-min}", minVersionIntroducedIn)
.replaceAll("\\{protocol-max}", ProtocolVersion.MAXIMUM_VERSION.getMostRecentSupportedVersion())
.replaceAll("\\{protocol}", version.getVersionIntroducedIn())
.replaceAll("\\{proxy-brand}", this.server.getVersion().getName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,15 @@ public static PluginMessagePacket rewriteMinecraftBrand(final PluginMessagePacke

String currentBrand = readBrandMessage(message.content());
String rewrittenBrand = serverBrand
.replaceAll("\\{protocol-min}", ProtocolVersion.MINIMUM_VERSION.getVersionIntroducedIn())
.replaceAll("\\{protocol-max}", ProtocolVersion.MAXIMUM_VERSION.getMostRecentSupportedVersion())
.replaceAll("\\{protocol}", ProtocolVersion.MAXIMUM_VERSION.getVersionIntroducedIn())
.replaceAll("\\{backend-brand}", currentBrand)
.replaceAll("\\{backend-brand-custom}", backendBrandCustom)
.replaceAll("\\{proxy-brand}", version.getName())
.replaceAll("\\{proxy-brand-custom}", proxyBrandCustom);
.replaceAll("\\{proxy-brand-custom}", proxyBrandCustom)
.replaceAll("\\{proxy-version}", version.getVersion())
.replaceAll("\\{proxy-vendor}", version.getVendor());

ByteBuf rewrittenBuf = Unpooled.buffer();
if (protocolVersion.noLessThan(ProtocolVersion.MINECRAFT_1_8)) {
Expand Down
13 changes: 13 additions & 0 deletions proxy/src/main/resources/default-velocity.toml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,14 @@ allow-illegal-characters-in-chat = false

# Modifies the server brand that displays in your debug menu
# Available options:
# - "{protocol-min}": Returns the lowest compatible version from the
# minimum-version key within this configuration.
# - "{protocol-max}": Returns the highest compatible version from the
# ProtocolVersion class within Velocity's code.
# - "{protocol}": Returns the lowest, highest compatible version from the
# ProtocolVersion class within Velocity's code.
# E.g., if a protocol shares two versions, it will output
# the lowest version from the list.
# - "{backend-brand}" Returns the brand of the server you are connected to. E.g.,
# "Paper," "Pufferfish," or "Purpur" would be valid brands.
# - "{backend-brand-custom}": Returns your custom proxy brand defined as "custom-brand-backend" in this
Expand All @@ -224,6 +232,11 @@ allow-illegal-characters-in-chat = false
# - "{proxy-brand-custom}": Returns your custom proxy brand defined as "custom-brand-proxy" in this
# configuration to maintain brand reformatting from external pingers. To use
# this configuration option, replace "{proxy-brand}" with "{proxy-brand-custom}."
# - "{proxy-version}": Returns the version of your proxy and git-hash that your
# proxy is currently on. Build numbers in regular Velocity
# would be shown with this specific assignment.
# - "{proxy-vendor}": Returns the group or association (vendor) of your proxy
# that by default would display "Velocity Contributors."
server-brand = "{backend-brand} ({proxy-brand})"

# Modifies the brand and server version that displays in the multiplayer menu and status pingers.
Expand Down

0 comments on commit 6f911f4

Please sign in to comment.