public class AdaptiveComponent extends Component implements org.bukkit.event.Listener
Interaction| Modifier and Type | Field and Description |
|---|---|
protected Component |
component
The component used when no adaption is present
|
clickAction, hidden, id, interaction| Constructor and Description |
|---|
AdaptiveComponent(String id,
Action clickAction,
boolean hidden,
Interaction interaction,
@NotNull Component defaultComponent)
Instantiates a new AdaptiveComponent.
|
| Modifier and Type | Method and Description |
|---|---|
void |
adapt(Component adaption)
Change which component will be displayed for an interaction.
|
void |
apply(Graphics graphic,
org.bukkit.entity.Player player,
GuiPoint cursor)
Render the component on the provided graphic context.
|
AdaptiveComponent |
clone(Interaction interaction)
Clone the component with the new interaction.
|
String |
getState(org.bukkit.entity.Player player,
GuiPoint cursor)
Gets the current state of the component for the given parameters.
|
boolean |
isInBounds(org.bukkit.entity.Player player,
GuiPoint cursor)
Checks whether the cursor is in bounds of the component.
|
AdaptiveComponent |
locateOn(Interaction interaction)
Locate the same component on a different interaction.
|
void |
onClick(org.bukkit.entity.Player player,
GuiPoint cursor,
boolean isPrimary)
Called when a player clicks on the component.
|
dispose, getClickAction, getId, getInteraction, isHidden, locate, locate, setClickAction, setHiddenprotected Component component
public AdaptiveComponent(String id, Action clickAction, boolean hidden, Interaction interaction, @NotNull @NotNull Component defaultComponent)
id - the component idclickAction - the click actionshidden - the hiddeninteraction - the interactiondefaultComponent - the default componentpublic void apply(Graphics graphic, org.bukkit.entity.Player player, GuiPoint cursor)
Componentpublic boolean isInBounds(org.bukkit.entity.Player player,
GuiPoint cursor)
ComponentisInBounds in class Componentplayer - the playercursor - the cursorpublic String getState(org.bukkit.entity.Player player, GuiPoint cursor)
ComponentComponent.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 AdaptiveComponent clone(Interaction interaction)
Componentpublic AdaptiveComponent locateOn(Interaction interaction)
Componentinteraction.getComponentTree().locate(component.getId())public void onClick(org.bukkit.entity.Player player,
GuiPoint cursor,
boolean isPrimary)
Componentpublic void adapt(Component adaption)
adaption - the adaptionCopyright © 2021. All rights reserved.