#2396: Add way to select reset color when parsing legacy chat
This commit is contained in:
parent
7241eb37c9
commit
dce4ea193a
@ -28,6 +28,21 @@ public final class TextComponent extends BaseComponent
|
|||||||
* @return the components needed to print the message to the client
|
* @return the components needed to print the message to the client
|
||||||
*/
|
*/
|
||||||
public static BaseComponent[] fromLegacyText(String message)
|
public static BaseComponent[] fromLegacyText(String message)
|
||||||
|
{
|
||||||
|
return fromLegacyText( message, ChatColor.WHITE );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the old formatting system that used
|
||||||
|
* {@link net.md_5.bungee.api.ChatColor#COLOR_CHAR} into the new json based
|
||||||
|
* system.
|
||||||
|
*
|
||||||
|
* @param message the text to convert
|
||||||
|
* @param defaultColor color to use when no formatting is to be applied
|
||||||
|
* (i.e. after ChatColor.RESET).
|
||||||
|
* @return the components needed to print the message to the client
|
||||||
|
*/
|
||||||
|
public static BaseComponent[] fromLegacyText(String message, ChatColor defaultColor)
|
||||||
{
|
{
|
||||||
ArrayList<BaseComponent> components = new ArrayList<BaseComponent>();
|
ArrayList<BaseComponent> components = new ArrayList<BaseComponent>();
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
@ -79,7 +94,7 @@ public final class TextComponent extends BaseComponent
|
|||||||
component.setObfuscated( true );
|
component.setObfuscated( true );
|
||||||
break;
|
break;
|
||||||
case RESET:
|
case RESET:
|
||||||
format = ChatColor.WHITE;
|
format = defaultColor;
|
||||||
default:
|
default:
|
||||||
component = new TextComponent();
|
component = new TextComponent();
|
||||||
component.setColor( format );
|
component.setColor( format );
|
||||||
|
Loading…
Reference in New Issue
Block a user