I’m trying to figure out how to set the server description with all format codes attached (\n, \u00A7d, etc…).
I used event.getResponse().setDescription(Text.of(newmotd));. I’m using a setter method for my class. So I’m wondering if the API has some sort of special method that would output the string as a string set in the server properties with all formatting code intact.
Sorry, I don’t get what you mean by this?
1 Like
When I try to use a format code (servername \nmoto) through Text.of(). It will only show as “server nmoto” on the server. It won’t read the “\n” as a format code. Along with everything here http://minecraft.gamepedia.com/Formatting_codes
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
TextSerializers.FORMATTING_CODE.deserialize("&e&lDon't be alarmbe, it's just Harambe");
I think that’s exactly what I’m looking for. Because I’m trying to set the motd through a command /setmotd.
Thank you 
p.s. java out for Harambe.
In your command, you might want to have a flags element that responds to --json, so you can also deserialize from JSON, depending on what the user wants. I always make a point of trying to accommodate the craziest setups possible in my plugins.
PS
scripts out for harambe
1 Like
I don’t think I understand by flags element responding to json. Do you mean to save the text through a json file for later use? I need to apologize in advance, I’m a little new to Java (I been learning stuff lately
).
No, I mean that while you would type /setmotd &9&lTrump&c&l2016, some would prefer to type /setmotd {"text":"","bold":true,"extra":[{"text":"Trump","color":"blue"},{"text":"2016","color":"red"}]}. It’s a personal thing, and better formatted in my opinion. So you could add an extra --json switch to the command. This can easily be done with
CommandSpec.builder()
//...
.arguments(GenericArguments.flags()
.flag("-json")
.buildWith(GenericArguments.seq(
//... stuff goes here
)
)
.build();
1 Like
Now I understand, that’s actually quite clever. I need to try that. 
You have been a great help for me, thank you. 