You can convert any color-code based message to a JsonMsg using the constructor
JsonMsg(String text, boolean allowStyleFallthrough).
The
allowStyleFallthrough parameter specifies whether the styles should be reset at every new "segment" of the text, where the segments are separated by a continuous set of color codes.
Example:
Code (Java):
JsonMsg msg
=
new JsonMsg
(
"§aHello, §o§lworld!",
true
)
;
// The §a (green color) carries over to "§o§lworld!",
// since it does not specify a color itself and allowStyleFallthrough is true
To convert a JsonMsg back to a color-coded message, use the method
JsonMsg.toConsoleMessage(boolean insertResetCodes). The
insertResetCodes parameter specifies whether the message and each extra message should be prefixed with a reset code (§r).
Example:
Code (Java):
String codeBased
= msg.
toConsoleMessage
(
true
)
;
// codeBased is now "§r§r§aHello, §r§a§l§oworld!"