Interface CenterAPI


  • public interface CenterAPI
    API for centering text in a component with various possibilities for complexity.
    Since:
    1.0.0
    • Method Summary

      All Methods Static Methods Deprecated Methods 
      Modifier and Type Method Description
      static net.kyori.adventure.text.Component center​(@NotNull net.kyori.adventure.text.Component component)
      Center a component with a padding used to add space on both sides of the component.
      static net.kyori.adventure.text.Component center​(@NotNull net.kyori.adventure.text.Component component, float componentWidth, @NotNull net.kyori.adventure.text.TextComponent padding, float paddingWidth, float goalWidth)
      Center a component with a padding used to add space on both sides of the component.
      static net.kyori.adventure.text.Component center​(@NotNull net.kyori.adventure.text.Component component, @NotNull net.kyori.adventure.text.TextComponent padding)
      Center a component with a padding used to add space on both sides of the component.
      static <CX> net.kyori.adventure.text.Component center​(@NotNull net.kyori.adventure.text.Component component, @NotNull solar.squares.pixelwidth.ContextualPixelWidthSource<CX> source, CX context)
      Center a component with a padding used to add space on both sides of the component.
      static <CX> net.kyori.adventure.text.Component center​(@NotNull net.kyori.adventure.text.Component component, @NotNull solar.squares.pixelwidth.ContextualPixelWidthSource<CX> source, CX context, @NotNull net.kyori.adventure.text.TextComponent padding, float chatWidth)
      Center a component with a padding used to add space on both sides of the component.
      static <CX> net.kyori.adventure.text.Component center​(@NotNull net.kyori.adventure.text.Component component, @NotNull solar.squares.pixelwidth.ContextualPixelWidthSource<CX> source, CX context, @NotNull net.kyori.adventure.text.TextComponent padding, @NotNull solar.squares.pixelwidth.function.ChatWidthFunction<CX> chatWidthFunction)
      Center a component with a padding used to add space on both sides of the component.
      static <CX> net.kyori.adventure.text.Component center​(@NotNull net.kyori.adventure.text.Component component, @NotNull solar.squares.pixelwidth.ContextualPixelWidthSource<CX> source, CX context, @NotNull net.kyori.adventure.text.TextComponent padding, Function<CX,​Float> contextToChatWidthFunction)
      static net.kyori.adventure.text.Component center​(@NotNull net.kyori.adventure.text.Component component, @NotNull solar.squares.pixelwidth.PixelWidthSource source, @NotNull net.kyori.adventure.text.TextComponent padding)
      Center a component with a padding used to add space on both sides of the component.
      static net.kyori.adventure.text.Component center​(@NotNull net.kyori.adventure.text.Component component, @NotNull solar.squares.pixelwidth.PixelWidthSource source, @NotNull net.kyori.adventure.text.TextComponent padding, float chatWidth)
      Center a component with a padding used to add space on both sides of the component.
      static net.kyori.adventure.text.Component center​(@NotNull net.kyori.adventure.text.Component component, solar.squares.pixelwidth.PixelWidthSource source)
      Center a component with a padding used to add space on both sides of the component.
    • Method Detail

      • center

        static net.kyori.adventure.text.Component center​(@NotNull
                                                         @NotNull net.kyori.adventure.text.Component component,
                                                         float componentWidth,
                                                         @NotNull
                                                         @NotNull net.kyori.adventure.text.TextComponent padding,
                                                         float paddingWidth,
                                                         float goalWidth)
        Center a component with a padding used to add space on both sides of the component. This is mostly internal
        Parameters:
        component - The component to center
        componentWidth - The width of the component
        padding - the text to use as padding
        paddingWidth - the width of the padding text
        goalWidth - the width of the chat this component is getting shown in
        Returns:
        a component with padding to hopefully center it
        Throws:
        IllegalArgumentException - if padding is too wide to fit on both sides of the center component at least once
        Since:
        1.0.0
      • center

        @Deprecated
        static <CX> net.kyori.adventure.text.Component center​(@NotNull
                                                              @NotNull net.kyori.adventure.text.Component component,
                                                              @NotNull
                                                              @NotNull solar.squares.pixelwidth.ContextualPixelWidthSource<CX> source,
                                                              @NotNull
                                                              CX context,
                                                              @NotNull
                                                              @NotNull net.kyori.adventure.text.TextComponent padding,
                                                              Function<CX,​Float> contextToChatWidthFunction)
        Center a component with a padding used to add space on both sides of the component.
        Parameters:
        component - the component to center
        source - the pixel width source used to calculate width of the component and the padding
        context - the context of the pixel width calculation
        padding - the text to use as padding
        contextToChatWidthFunction - function to find a chat width given the context
        Returns:
        a component with padding to hopefully center it
        Throws:
        IllegalArgumentException - if padding is too wide to fit on both sides of the center component at least once
        Since:
        1.0.0
      • center

        static <CX> net.kyori.adventure.text.Component center​(@NotNull
                                                              @NotNull net.kyori.adventure.text.Component component,
                                                              @NotNull
                                                              @NotNull solar.squares.pixelwidth.ContextualPixelWidthSource<CX> source,
                                                              @NotNull
                                                              CX context,
                                                              @NotNull
                                                              @NotNull net.kyori.adventure.text.TextComponent padding,
                                                              @NotNull
                                                              @NotNull solar.squares.pixelwidth.function.ChatWidthFunction<CX> chatWidthFunction)
        Center a component with a padding used to add space on both sides of the component.
        Parameters:
        component - the component to center
        source - the pixel width source used to calculate width of the component and the padding
        context - the context of the pixel width calculation
        padding - the text to use as padding
        chatWidthFunction - function to find a chat width given the context
        Returns:
        a component with padding to hopefully center it
        Throws:
        IllegalArgumentException - if padding is too wide to fit on both sides of the center component at least once
        Since:
        1.1.0
      • center

        static <CX> net.kyori.adventure.text.Component center​(@NotNull
                                                              @NotNull net.kyori.adventure.text.Component component,
                                                              @NotNull
                                                              @NotNull solar.squares.pixelwidth.ContextualPixelWidthSource<CX> source,
                                                              @NotNull
                                                              CX context,
                                                              @NotNull
                                                              @NotNull net.kyori.adventure.text.TextComponent padding,
                                                              float chatWidth)
        Center a component with a padding used to add space on both sides of the component.
        Parameters:
        component - the component to center
        source - the pixel width source used to calculate width of the component and the padding
        context - the context of the pixel width calculation
        padding - the text to use as padding
        chatWidth - the width of the chat this component is getting shown in
        Returns:
        a component with padding to hopefully center it
        Throws:
        IllegalArgumentException - if padding is too wide to fit on both sides of the center component at least once
        Since:
        1.0.0
      • center

        static <CX> net.kyori.adventure.text.Component center​(@NotNull
                                                              @NotNull net.kyori.adventure.text.Component component,
                                                              @NotNull
                                                              @NotNull solar.squares.pixelwidth.ContextualPixelWidthSource<CX> source,
                                                              @NotNull
                                                              CX context)
        Center a component with a padding used to add space on both sides of the component. Uses empty spaces for padding and the static chat width(320) for calculation.
        Parameters:
        component - the component to center
        source - the pixel width source used to calculate width of the component and the padding
        context - the context of the pixel width calculation
        Returns:
        a component with padding to hopefully center it
        Throws:
        IllegalArgumentException - if padding is too wide to fit on both sides of the center component at least once
        Since:
        1.0.0
      • center

        static net.kyori.adventure.text.Component center​(@NotNull
                                                         @NotNull net.kyori.adventure.text.Component component,
                                                         @NotNull
                                                         @NotNull solar.squares.pixelwidth.PixelWidthSource source,
                                                         @NotNull
                                                         @NotNull net.kyori.adventure.text.TextComponent padding,
                                                         float chatWidth)
        Center a component with a padding used to add space on both sides of the component.
        Parameters:
        component - the component to center
        source - the pixel width source used to calculate width of the component and the padding
        padding - the text to use as padding
        chatWidth - the width of the chat this component is getting shown in
        Returns:
        a component with padding to hopefully center it
        Throws:
        IllegalArgumentException - if padding is too wide to fit on both sides of the center component at least once
        Since:
        1.0.0
      • center

        static net.kyori.adventure.text.Component center​(@NotNull
                                                         @NotNull net.kyori.adventure.text.Component component,
                                                         @NotNull
                                                         @NotNull solar.squares.pixelwidth.PixelWidthSource source,
                                                         @NotNull
                                                         @NotNull net.kyori.adventure.text.TextComponent padding)
        Center a component with a padding used to add space on both sides of the component. Uses the static chat width(320) for calculation.
        Parameters:
        component - the component to center
        source - the pixel width source used to calculate width of the component and the padding
        padding - the text to use as padding
        Returns:
        a component with padding to hopefully center it
        Throws:
        IllegalArgumentException - if padding is too wide to fit on both sides of the center component at least once
        Since:
        1.0.0
      • center

        static net.kyori.adventure.text.Component center​(@NotNull
                                                         @NotNull net.kyori.adventure.text.Component component,
                                                         @NotNull
                                                         @NotNull net.kyori.adventure.text.TextComponent padding)
        Center a component with a padding used to add space on both sides of the component. Uses empty spaces for padding and the static chat width(320) for calculation. Uses the static pixel width source.
        Parameters:
        component - the component to center
        padding - the text to use as padding
        Returns:
        a component with padding to hopefully center it
        Throws:
        IllegalArgumentException - if padding is too wide to fit on both sides of the center component at least once
        Since:
        1.0.0
      • center

        static net.kyori.adventure.text.Component center​(@NotNull
                                                         @NotNull net.kyori.adventure.text.Component component,
                                                         solar.squares.pixelwidth.PixelWidthSource source)
        Center a component with a padding used to add space on both sides of the component. Uses empty spaces for padding and the static chat width(320) for calculation.
        Parameters:
        component - the component to center
        source - the pixel width source used to calculate width of the component and the padding
        Returns:
        a component with padding to hopefully center it
        Throws:
        IllegalArgumentException - if padding is too wide to fit on both sides of the center component at least once
        Since:
        1.0.0
      • center

        static net.kyori.adventure.text.Component center​(@NotNull
                                                         @NotNull net.kyori.adventure.text.Component component)
        Center a component with a padding used to add space on both sides of the component. Uses empty spaces for padding and the static chat width(320) for calculation. Uses the static pixel width source.
        Parameters:
        component - the component to center
        Returns:
        a component with padding to hopefully center it
        Throws:
        IllegalArgumentException - if padding is too wide to fit on both sides of the center component at least once
        Since:
        1.0.0