use of org.spongepowered.common.interfaces.text.IMixinText in project SpongeCommon by SpongePowered.
the class MixinText method initializeComponent.
private ITextComponent initializeComponent() {
if (this.component == null) {
this.component = createComponent();
Style style = this.component.getStyle();
if (this.format.getColor() != TextColors.NONE) {
style.setColor(((SpongeTextColor) this.format.getColor()).getHandle());
}
if (!this.format.getStyle().isEmpty()) {
style.setBold(this.format.getStyle().isBold().orElse(null));
style.setItalic(this.format.getStyle().isItalic().orElse(null));
style.setUnderlined(this.format.getStyle().hasUnderline().orElse(null));
style.setStrikethrough(this.format.getStyle().hasStrikethrough().orElse(null));
style.setObfuscated(this.format.getStyle().isObfuscated().orElse(null));
}
if (this.clickAction.isPresent()) {
style.setClickEvent(SpongeClickAction.getHandle(this.clickAction.get()));
}
if (this.hoverAction.isPresent()) {
style.setHoverEvent(SpongeHoverAction.getHandle(this.hoverAction.get()));
}
if (this.shiftClickAction.isPresent()) {
ShiftClickAction.InsertText insertion = (ShiftClickAction.InsertText) this.shiftClickAction.get();
style.setInsertion(insertion.getResult());
}
for (Text child : this.children) {
this.component.appendSibling(((IMixinText) child).toComponent());
}
}
return this.component;
}
Aggregations