Package solar.squares.pixelwidth.utils
Interface CenterAPI
-
public interface CenterAPIAPI for centering text in a component with various possibilities for complexity.- Since:
- 1.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_CHAT_WIDTH
-
Method Summary
All Methods Static Methods Deprecated Methods Modifier and Type Method Description static net.kyori.adventure.text.Componentcenter(@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.Componentcenter(@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.Componentcenter(@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.Componentcenter(@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.Componentcenter(@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.Componentcenter(@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.Componentcenter(@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)Deprecated.since 1.1.0, usecenter(Component, ContextualPixelWidthSource, Object, TextComponent, ChatWidthFunction)insteadstatic net.kyori.adventure.text.Componentcenter(@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.Componentcenter(@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.Componentcenter(@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.
-
-
-
Field Detail
-
DEFAULT_CHAT_WIDTH
static final int DEFAULT_CHAT_WIDTH
- See Also:
- Constant Field Values
-
-
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 centercomponentWidth- The width of the componentpadding- the text to use as paddingpaddingWidth- the width of the padding textgoalWidth- 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)
Deprecated.since 1.1.0, usecenter(Component, ContextualPixelWidthSource, Object, TextComponent, ChatWidthFunction)insteadCenter a component with a padding used to add space on both sides of the component.- Parameters:
component- the component to centersource- the pixel width source used to calculate width of the component and the paddingcontext- the context of the pixel width calculationpadding- the text to use as paddingcontextToChatWidthFunction- 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 centersource- the pixel width source used to calculate width of the component and the paddingcontext- the context of the pixel width calculationpadding- the text to use as paddingchatWidthFunction- 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 centersource- the pixel width source used to calculate width of the component and the paddingcontext- the context of the pixel width calculationpadding- the text to use as paddingchatWidth- 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 centersource- the pixel width source used to calculate width of the component and the paddingcontext- 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 centersource- the pixel width source used to calculate width of the component and the paddingpadding- the text to use as paddingchatWidth- 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 centersource- the pixel width source used to calculate width of the component and the paddingpadding- 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 centerpadding- 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 centersource- 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
-
-