Support multi-line MOTDs natively via a string list in the config#1825
Support multi-line MOTDs natively via a string list in the config#1825WouterGritter wants to merge 1 commit into
Conversation
| } | ||
| final byte[] forwardingSecret = forwardingSecretString.getBytes(StandardCharsets.UTF_8); | ||
| final String motd = config.getOrElse("motd", "<#09add3>A Velocity Server"); | ||
| final List<String> motd = config.getOrElse("motd", ImmutableList.of("<#09add3>A Velocity Server")); |
There was a problem hiding this comment.
I think it would be a good idea to add a validation check in case someone tries to add more than 2 lines
| String motd = config.get("motd"); | ||
| config.set("motd", List.of(motd)); | ||
|
|
||
| config.set("config-version", "2.9"); |
There was a problem hiding this comment.
Since the migration will only happen once, it might be a good idea to migrate the use of \n or <newline>/<br> to a new line in the configuration
There was a problem hiding this comment.
I agree, though it'll be best-effort and we probably dont want to match every case. Splitting on those 3 delimiters seems reasonable (case insensitive) but afaik minimessage also supports self-closing tags (?), possibly spaces between the tag name and the self-closing /. Emulating the minimessage parsing engine seems out of scope, and deserializing+serializing would be too intrusive imo.
As the title says.
As a bonus, we get rid of the ugly FQDN instead of an import for
ComponentinProxyConfigandVelocityConfig, andProxyConfig#getMotd's javadoc is updated to correctly reflect where the MOTD is actually being used.I had first used a regex in
MotdMultilineMigrationto split onliteral newline,\n<newline>and<br>(MM's newline tags) when migrating, but this seemed too intrusive. In its current state, this PR just migrates the existing string to a string list of size 1 and leaves it up to the user to split out into multiple lines.