Interface ComponentFlattener


public sealed interface ComponentFlattener
A 'flattener' to convert a component tree to a linear string for display.
Since:
4.7.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    A builder for a component flattener.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    A constant representing a flattener with no limit on nested flatten calls.
  • Method Summary

    Modifier and Type
    Method
    Description
    A basic flattener that will print only information directly contained in components.
    Create a new builder for a flattener.
    void
    Perform a flattening on the component, providing output to the listener.
    A component flattener that will only handle text components.
    Create a new builder with the same configuration as this flattener.
  • Field Details

    • NO_NESTING_LIMIT

      static final int NO_NESTING_LIMIT
      A constant representing a flattener with no limit on nested flatten calls.
      Since:
      4.22.0
      See Also:
  • Method Details

    • builder

      static ComponentFlattener.Builder builder()
      Create a new builder for a flattener.
      Returns:
      a new builder
      Since:
      4.7.0
    • basic

      static ComponentFlattener basic()
      A basic flattener that will print only information directly contained in components.

      The output of this flattener aims to match what the vanilla Minecraft: Java Edition client will display when unable to resolve any game data.

      Returns:
      a basic flattener
      Since:
      4.7.0
    • textOnly

      static ComponentFlattener textOnly()
      A component flattener that will only handle text components.

      All other component types will not be included in the output.

      Returns:
      a text-only flattener
      Since:
      4.7.0
    • flatten

      void flatten(Component input, FlattenerListener listener)
      Perform a flattening on the component, providing output to the listener.
      Parameters:
      input - the component to be flattened
      listener - the listener that will receive flattened component state
      Since:
      4.7.0
    • toBuilder

      Create a new builder with the same configuration as this flattener.
      Returns:
      the builder
      Since:
      4.7.0