public class TextComponent extends Component
Modifier and Type | Class and Description |
---|---|
static class |
TextComponent.Alignment |
Modifier and Type | Field and Description |
---|---|
protected TextComponent.Alignment |
alignment |
clickAction, hidden, id, interaction
Constructor and Description |
---|
TextComponent(String id,
Action clickAction,
boolean hidden,
Interaction interaction,
int x,
int y,
Font font,
String text,
Color color)
Instantiates a new TextComponent.
|
TextComponent(String id,
Action clickAction,
boolean hidden,
Interaction interaction,
int x,
int y,
Font font,
String text,
Color color,
@NotNull TextComponent.Alignment alignment)
Instantiates a new TextComponent.
|
Modifier and Type | Method and Description |
---|---|
void |
apply(Graphics graphic,
org.bukkit.entity.Player player,
GuiPoint cursor)
Render the component on the provided graphic context.
|
TextComponent |
clone(Interaction interaction)
Clone the component with the new interaction.
|
TextComponent |
copyWith(String id,
String newText)
Create a copy of this text component with a new text
|
protected Rectangle2D |
getBounds(org.bukkit.entity.Player player) |
Color |
getColor()
Gets color.
|
Font |
getFont()
Gets font.
|
String |
getState(org.bukkit.entity.Player player,
GuiPoint cursor)
Gets the current state of the component for the given parameters.
|
String |
getText()
Gets text.
|
protected String |
getText(org.bukkit.entity.Player player) |
int |
getX()
Gets x.
|
int |
getY()
Gets y.
|
boolean |
isInBounds(org.bukkit.entity.Player player,
GuiPoint cursor)
Checks whether the cursor is in bounds of the component.
|
TextComponent |
locateOn(Interaction interaction)
Locate the same component on a different interaction.
|
void |
setColor(Color color)
Sets color.
|
void |
setFont(Font font)
Sets font.
|
void |
setText(String text)
Sets text.
|
void |
setX(int x)
Sets x.
|
void |
setY(int y)
Sets y.
|
dispose, getClickAction, getId, getInteraction, isHidden, locate, locate, onClick, setClickAction, setHidden
protected final TextComponent.Alignment alignment
public TextComponent(String id, Action clickAction, boolean hidden, Interaction interaction, int x, int y, Font font, String text, Color color)
id
- the component idclickAction
- the click actionshidden
- the hiddeninteraction
- the interactionx
- the xy
- the yfont
- the fonttext
- the textcolor
- the colorpublic TextComponent(String id, Action clickAction, boolean hidden, Interaction interaction, int x, int y, Font font, String text, Color color, @NotNull @NotNull TextComponent.Alignment alignment)
id
- the component idclickAction
- the click actionshidden
- the hiddeninteraction
- the interactionx
- the xy
- the yfont
- the fonttext
- the textcolor
- the coloralignment
- the text alignmentpublic void apply(Graphics graphic, org.bukkit.entity.Player player, GuiPoint cursor)
Component
public String getState(org.bukkit.entity.Player player, GuiPoint cursor)
Component
Component.apply(Graphics, Player, GuiPoint)
renders different content, then the this method should
return different strings. If it renders the same the return value should be the same.
RectComponent
returns
x+"*"+y+"*"+width+"*"+height+"*"+color.getRGB()
)public TextComponent clone(Interaction interaction)
Component
public TextComponent locateOn(Interaction interaction)
Component
interaction.getComponentTree().locate(component.getId())
protected Rectangle2D getBounds(org.bukkit.entity.Player player)
protected String getText(org.bukkit.entity.Player player)
public boolean isInBounds(org.bukkit.entity.Player player, GuiPoint cursor)
Component
isInBounds
in class Component
player
- the playercursor
- the cursorpublic TextComponent copyWith(String id, String newText)
id
- the id of the copynewText
- the new textpublic int getX()
public void setX(int x)
x
- the xpublic int getY()
public void setY(int y)
y
- the ypublic Font getFont()
public void setFont(Font font)
font
- the fontpublic String getText()
public void setText(String text)
text
- the textpublic Color getColor()
public void setColor(Color color)
color
- the colorCopyright © 2021. All rights reserved.