net.minecraft.text.ClickEvent Java Examples
The following examples show how to use
net.minecraft.text.ClickEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Contributors.java From the-hallow with MIT License | 6 votes |
private static Text makeDesc(Person person, Formatting formatting) { ContactInformation contact = person.getContact(); Text ret = new LiteralText(person.getName()).formatted(formatting); contact.get("github").ifPresent(gh -> ret.append(Texts.bracketed(new TranslatableText("social.thehallow.github") .styled(style -> style.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, gh)))) .formatted(Formatting.BLACK) ) ); contact.get("minecraft").ifPresent(mc -> ret.append(Texts.bracketed(new TranslatableText("social.thehallow.minecraft") .styled(style -> style.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://mcuuid.net/?q=" + mc)))) .formatted(Formatting.GREEN) ) ); return ret; }
Example #2
Source File: HallowedCommand.java From the-hallow with MIT License | 5 votes |
public static int run(CommandContext<ServerCommandSource> ctx) { ctx.getSource().sendFeedback(Texts.bracketed(new TranslatableText("thehallow.about.name").formatted(Formatting.GOLD)), false); ctx.getSource().sendFeedback(new TranslatableText("thehallow.about.description").formatted(Formatting.LIGHT_PURPLE), false); ctx.getSource().sendFeedback(new TranslatableText("thehallow.about.github").formatted(Formatting.YELLOW) .append(new TranslatableText("thehallow.github").formatted(Formatting.GREEN) .styled(style -> style.setClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/fabric-community/the-hallow")))), false); return SINGLE_SUCCESS; }
Example #3
Source File: WurstUpdater.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
private void showLink(String text, String url) { component = new LiteralText(text); ClickEvent event = new ClickEvent(ClickEvent.Action.OPEN_URL, url); component.getStyle().withClickEvent(event); }
Example #4
Source File: Messenger.java From fabric-carpet with MIT License | 4 votes |
private static BaseText _getChatComponentFromDesc(String message, BaseText previous_message) { if (message.equalsIgnoreCase("")) { return new LiteralText(""); } if (Character.isWhitespace(message.charAt(0))) { message = "w"+message; } int limit = message.indexOf(' '); String desc = message; String str = ""; if (limit >= 0) { desc = message.substring(0, limit); str = message.substring(limit+1); } if (desc.charAt(0) == '/') // deprecated { if (previous_message != null) previous_message.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, message)); return previous_message; } if (desc.charAt(0) == '?') { if (previous_message != null) previous_message.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, message.substring(1))); return previous_message; } if (desc.charAt(0) == '!') { if (previous_message != null) previous_message.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, message.substring(1))); return previous_message; } if (desc.charAt(0) == '^') { if (previous_message != null) previous_message.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, c(message.substring(1)))); return previous_message; } BaseText txt = new LiteralText(str); txt.setStyle(parseStyle(desc)); return txt; }