package net.t2code.t2codelib.SPIGOT.api.messages; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.TextComponent; public class T2CtextBuilder { private final String text; private String hover; private String click; private ClickEvent.Action action; public T2CtextBuilder(String text) { this.text = text; } public T2CtextBuilder addHover(String hover) { this.hover = hover; return this; } public T2CtextBuilder addClickEvent(ClickEvent.Action clickEventAction, String value) { this.action = clickEventAction; this.click = value; return this; } public TextComponent build() { if (this.text.contains("[empty]")) return null; TextComponent textComponent = new TextComponent(); textComponent.setText(this.text); if (this.hover != null) { textComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(this.hover).create())); } if (this.click != null && (this.action != null)) { textComponent.setClickEvent(new ClickEvent(action, this.click)); } return textComponent; } public enum ClickEventType { OPEN_URL, OPEN_FILE, RUN_COMMAND, SUGGEST_COMMAND, CHANGE_PAGE, COPY_TO_CLIPBOARD } }