What is the easiest (or intended) way to get a plain text String from a Component?

Either with or without color/decoration?

The intended way to do this seems to have changed over past versions of the component api.

It would be really nice if there was a Component.asPlainText() or Component.asDecoratedText() - it seems like I have to go through an entire decoding process using ComponentSerializers (these no longer seem to be available in the latest version) or LegacyComponentSerializer and chain 6 different methods together just to get the text of a component…

Is there an easier way?

edit: This is what I’m doing now. It feels hacky but I can’t seem to find a more straightforward way to do what I want:

public static String decomponentalize(Component component) {
    if (component == null)
        return null;
    String string = LegacyComponentSerializer.legacyAmpersand().serialize(component);
    return ChatColor.translateAlternateColorCodes('&', string);
}
PlainTextComponentSerializer.plainText().serialize(component)

Do I need to add some dependency to use this? PlainTextComponentSerializer does not seem to be included in the native implementation in Paper, or at least IntelliJ doesn’t know about it

Oh, Forgive me. I think the class is called PlainComponentSerializer

perfect! thank you!