Hey guys,
I know how to create a plugin which can load data from an external config file. My Problem is, that i want to use color Codes like &e … in my config file, because this is very uncomfortable:
Thats right. I don’t use a config file here (i use a mysql database), but i think, that this doesn’t make any difference when it comes to the color codes :).
Second question: How can I use line breaks in my “config” ?
Thanks,
Greets
The old color codes are supported still through player.sendMessage(Texts.legecy(message, "§e"));
but it will be removed from the API soon.
Better you use player.sendMessage(Texts.of(TextColors.Yellow + "Test Message"));
No, please do not do that. As far as I know, Texts.legacy(char) (and its overloads) are not likely to be removed soon. They are deprecated because Mojang is phasing out formatting characters, but still provided by Sponge because some existing (Bukkit) plugins still rely formatting characters and need a way to parse them.
For new plugins it is recommended to use the XML TextRepresentation that Sponge bundles: Texts.xml().from(String). As of writing, this way is not yet covered by the documentation. Still it should be pretty obvious from reading this commit. An official XSD file to validate the formatting XML is available here.
How is this used? I ran a simple test and I got an error
src.sendMessage(Texts.xml().from("&4test"));
org.spongepowered.api.util.TextMessageException: Error parsing TextXML message '<span>&4test</span>'
...
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 8; The entity name must immediately follow the '&' in the entity reference.