|
| 1 | +package com.github.sanctum.labyrinth.formatting.component; |
| 2 | + |
| 3 | +import com.github.sanctum.labyrinth.formatting.string.ColoredString; |
| 4 | +import net.md_5.bungee.api.chat.ClickEvent; |
| 5 | +import net.md_5.bungee.api.chat.HoverEvent; |
| 6 | +import net.md_5.bungee.api.chat.TextComponent; |
| 7 | +import org.bukkit.ChatColor; |
| 8 | + |
| 9 | +public class NewComponent { |
| 10 | + |
| 11 | + private static String color(String text) { |
| 12 | + return ChatColor.translateAlternateColorCodes('&', text); |
| 13 | + } |
| 14 | + |
| 15 | + public TextComponent textHoverable(String normalText, String hoverText, String hoverTextMessage) { |
| 16 | + TextComponent text = new ColoredString(normalText, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 17 | + TextComponent hover = new ColoredString(hoverText, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 18 | + text.addExtra(hover); |
| 19 | + hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(color(hoverTextMessage))))); |
| 20 | + return text; |
| 21 | + } |
| 22 | + |
| 23 | + public TextComponent textHoverable(String normalText, String hoverText, String normalText2, String hoverTextMessage) { |
| 24 | + TextComponent text = new ColoredString(normalText, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 25 | + TextComponent hover = new ColoredString(hoverText, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 26 | + TextComponent text2 = new ColoredString(normalText2, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 27 | + text.addExtra(hover); |
| 28 | + text.addExtra(text2); |
| 29 | + hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(color(hoverTextMessage))))); |
| 30 | + return text; |
| 31 | + } |
| 32 | + |
| 33 | + public TextComponent textHoverable(String normalText, String hoverText, String normalText2, String hoverText2, String hoverTextMessage, String hoverText2Message) { |
| 34 | + TextComponent text = new ColoredString(normalText, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 35 | + TextComponent hover = new ColoredString(hoverText, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 36 | + TextComponent text2 = new ColoredString(normalText2, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 37 | + TextComponent hover2 = new ColoredString(hoverText2, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 38 | + text.addExtra(hover); |
| 39 | + text.addExtra(text2); |
| 40 | + text.addExtra(hover2); |
| 41 | + hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(color(hoverTextMessage))))); |
| 42 | + hover2.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(color(hoverText2Message))))); |
| 43 | + return text; |
| 44 | + } |
| 45 | + // * |
| 46 | + // |
| 47 | + // SEND TEXT THE PLAYER CAN BE SUGGESTED TO EXECUTE COMMANDS WITH |
| 48 | + // |
| 49 | + |
| 50 | + public TextComponent textSuggestable(String normalText, String hoverText, String hoverTextMessage, String commandName) { |
| 51 | + TextComponent text = new ColoredString(normalText, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 52 | + TextComponent hover = new ColoredString(hoverText, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 53 | + text.addExtra(hover); |
| 54 | + hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(color(hoverTextMessage))))); |
| 55 | + hover.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + commandName)); |
| 56 | + return text; |
| 57 | + } |
| 58 | + // * |
| 59 | + // |
| 60 | + // SEND TEXT THE PLAYER CAN RUN COMMANDS WITH |
| 61 | + // |
| 62 | + |
| 63 | + public TextComponent textRunnable(String normalText, String hoverText, String hoverTextMessage, String commandName) { |
| 64 | + TextComponent text = new ColoredString(normalText, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 65 | + TextComponent hover = new ColoredString(hoverText, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 66 | + text.addExtra(hover); |
| 67 | + hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(new ColoredString(hoverTextMessage, ColoredString.ColorType.HEX).toString())))); |
| 68 | + hover.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + commandName)); |
| 69 | + return text; |
| 70 | + } |
| 71 | + |
| 72 | + public TextComponent textRunnable(String normalText, String hoverText, String normalText2, String hoverTextMessage, String commandName) { |
| 73 | + TextComponent text = new ColoredString(normalText, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 74 | + TextComponent hover = new ColoredString(hoverText, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 75 | + TextComponent text2 = new ColoredString(normalText2, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 76 | + text.addExtra(hover); |
| 77 | + text.addExtra(text2); |
| 78 | + hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(new ColoredString(hoverTextMessage, ColoredString.ColorType.HEX).toString())))); |
| 79 | + hover.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + commandName)); |
| 80 | + return text; |
| 81 | + } |
| 82 | + |
| 83 | + public TextComponent textRunnable(String normalText, String hoverText, String normalText2, String hoverText2, String hoverTextMessage, String hoverText2Message, String commandName, String commandName2) { |
| 84 | + TextComponent text = new ColoredString(normalText, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 85 | + TextComponent hover = new ColoredString(hoverText, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 86 | + TextComponent text2 = new ColoredString(normalText2, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 87 | + TextComponent hover2 = new ColoredString(hoverText2, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 88 | + text.addExtra(hover); |
| 89 | + text.addExtra(text2); |
| 90 | + text.addExtra(hover2); |
| 91 | + hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(new ColoredString(hoverTextMessage, ColoredString.ColorType.HEX).toString())))); |
| 92 | + hover.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + commandName)); |
| 93 | + hover2.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(new ColoredString(hoverText2Message, ColoredString.ColorType.HEX).toString())))); |
| 94 | + hover2.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + commandName2)); |
| 95 | + return text; |
| 96 | + } |
| 97 | + |
| 98 | + public TextComponent textRunnable(String hoverText, String hoverText2, String hoverTextBody3, String hoverTextMessage, String hoverText2Message, String hoverMessage3, String commandName, String commandName2, String commandName3) { |
| 99 | + TextComponent hover = new ColoredString(hoverText, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 100 | + TextComponent hover2 = new ColoredString(hoverText2, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 101 | + TextComponent hover3 = new ColoredString(hoverTextBody3, ColoredString.ColorType.MC_COMPONENT).toComponent(); |
| 102 | + hover.addExtra(hover2); |
| 103 | + hover.addExtra(hover3); |
| 104 | + hover.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(new ColoredString(hoverTextMessage, ColoredString.ColorType.HEX).toString())))); |
| 105 | + hover.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + commandName)); |
| 106 | + hover2.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(new ColoredString(hoverText2Message, ColoredString.ColorType.HEX).toString())))); |
| 107 | + hover2.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + commandName2)); |
| 108 | + hover3.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new net.md_5.bungee.api.chat.hover.content.Text(new ColoredString(hoverMessage3, ColoredString.ColorType.HEX).toString())))); |
| 109 | + hover3.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + commandName3)); |
| 110 | + return hover; |
| 111 | + } |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | +} |
0 commit comments