Output string as motd text

I’m not entirely sure what you mean. If you mean you want to be able to output a normal formatted string, that is kinda the point of Text.

Text.of(TextColors.GREEN, "Your IP is ", Text.of(TextStyles.BOLD, e.getClient().getAddress().getAddress()), "!");

If you’re asking what the default one would be, that can be gotten through getResponse().getDescription().
If for some reason you need to get it in a legacy format, you can do

TextSerializers.FORMATTING_CODE.deserialize("&e&lDon't be alarmbe, it's just Harambe");

This last one shouldn’t be necessary, since you can retrieve Texts directly from the config, in Minecraft’s JSON text structure. Also note that FORMATTING_CODE works with &, and LEGACY_FORMATTING_CODE works with § aka \u00a7.

And finally, if you’re asking how to get the line directly from server.properties, the answer is no, there’s not a method in the API. If you really really really need it, find the system property user.dir, get the server.properties file in it, and use the Properties class to parse it.

Edit: After reading your post, use Text.NEW_LINE within Text.of() or Text.Builder#append() in order to linebreak.

1 Like