protected <T extends ITextComponent> T withStyle(final T component, final TextFormatting formatting, @Nullable final String command) { final Style style = new Style(); style.setColor(formatting); if (command != null) { style.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command)); } component.setStyle(style); return component; } }
private static void saveFile(List<String> list, String file) { File f = new File(Minecraft.getMinecraft().gameDir, "local/client/ftbjanitor/" + file); FileUtils.saveSafe(f, list); ITextComponent component = new TextComponentString(file + " saved! Click here to open."); try { component.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, f.getCanonicalFile().getAbsolutePath())); } catch (Exception ex) { component.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, f.getAbsolutePath())); } Minecraft.getMinecraft().player.sendMessage(component); } }
panoramaDirComponent.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, currentDir.getAbsolutePath())).setUnderlined(true); event.setResultMessage(new TextComponentTranslation("quarkmisc.panoramaSaved", panoramaDirComponent));
chatcomponenttranslation.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/cofh syntax " + commandList.get(i))); sender.sendMessage(chatcomponenttranslation);
chatcomponenttranslation.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/cofh " + commandList.get(i))); sender.sendMessage(chatcomponenttranslation);
@Override public void sendLink(String url) { TextComponentString msg = new TextComponentString(url); Style style = msg.getStyle(); style.setColor(TextFormatting.GRAY); style.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url)); msg.setStyle(style); broadcast(msg); }
ICommand icommand1 = list.get(l); TextComponentTranslation componentTranslation = new TextComponentTranslation(icommand1.getUsage(sender)); componentTranslation.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + icommand1.getName() + " ")); sender.sendMessage(componentTranslation);
/** * Draws the page switcher at the bottom. * * @param sender the sender. * @param page the page number. * @param count number of citizens. * @param halfPage the halfPage. * @param colonyId the colony id. */ private static void drawPageSwitcher(@NotNull final ICommandSender sender, final int page, final int count, final int halfPage, final int colonyId) { final int prevPage = Math.max(0, page - 1); final int nextPage = Math.min(page + 1, (count / CITIZENS_ON_PAGE) + halfPage); final ITextComponent prevButton = new TextComponentString(PREV_PAGE).setStyle(new Style().setBold(true).setColor(TextFormatting.GOLD).setClickEvent( new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format(LIST_COMMAND_SUGGESTED, colonyId, prevPage)) )); final ITextComponent nextButton = new TextComponentString(NEXT_PAGE).setStyle(new Style().setBold(true).setColor(TextFormatting.GOLD).setClickEvent( new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format(LIST_COMMAND_SUGGESTED, colonyId, nextPage)) )); final ITextComponent beginLine = new TextComponentString(PAGE_LINE); final ITextComponent endLine = new TextComponentString(PAGE_LINE); sender.sendMessage(beginLine.appendSibling(prevButton).appendSibling(new TextComponentString(PAGE_LINE_DIVIDER)).appendSibling(nextButton).appendSibling(endLine)); }
/** * On Button click teleport to the colony.. * * @param button the clicked button. */ private void teleportToColony(@NotNull final Button button) { final int row = alliesList.getListElementIndexByPane(button); final ColonyView ally = allies.get(row); final ITextComponent teleport = new TextComponentString(LanguageHandler.format(DO_REALLY_WANNA_TP, ally.getName())) .setStyle(new Style().setBold(true).setColor(TextFormatting.GOLD).setClickEvent( new ClickEvent(ClickEvent.Action.RUN_COMMAND, TELEPORT_COMMAND + ally.getID()) )); Minecraft.getMinecraft().player.sendMessage(teleport); }
link.getStyle().setColor(TextFormatting.GOLD); link.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(url))); link.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url)); Minecraft.getMinecraft().player.sendMessage(new TextComponentTranslation("ftbutilities.lang.uploaded_crash", link));
screenshotLink.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, screenshotFile.getAbsolutePath())); screenshotLink.getStyle().setUnderlined(true); ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("screenshot.success", screenshotLink));
final ITextComponent deleteButton = new TextComponentString("[DELETE]").setStyle(new Style().setBold(true).setColor(TextFormatting.GOLD).setClickEvent( new ClickEvent(ClickEvent.Action.RUN_COMMAND, COMMAND_CHECK_FOR_AUTODELETES) ));
link.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, curseURL)); Minecraft.getMinecraft().player.sendMessage(link); });
.setStyle(new Style().setBold(true).setColor(TextFormatting.GOLD).setClickEvent( new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format(DELETE_COLONY_CONFIRM_DELETE_COMMAND_SUGGESTED,
url.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://mrcrayfish.com/mods")); url.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentTranslation("cfm.message.login2.info"))); player.sendMessage(url); case 1: url = new TextComponentString(PREFIX + TextFormatting.RESET + "mrcrayfishs-furniture-mod.wikia.com"); url.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "http://mrcrayfishs-furniture-mod.wikia.com/")); url.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentTranslation("cfm.message.login2.info"))); player.sendMessage(url); case 2: url = new TextComponentString(PREFIX + TextFormatting.RESET + "youtube.com/user/MrCrayfishMinecraft"); url.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.youtube.com/user/MrCrayfishMinecraft")); url.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentTranslation("cfm.message.login2.info"))); player.sendMessage(url); case 3: url = new TextComponentString(PREFIX + TextFormatting.RESET + "mrcrayfish.com/furniture-comm-edition"); url.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://mrcrayfish.com/furniture-comm-edition")); url.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentTranslation("cfm.message.login2.info"))); player.sendMessage(url);
sender.sendMessage(chat); chat = new TextComponentTranslation("message.type.to.view"); chat.getStyle().setColor(TextFormatting.RED).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/mud")); sender.sendMessage(chat);
component.getStyle() .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(updateMessage))) .setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://minecraft.curseforge.com/projects/wizardry-mod/files"));
private static ITextComponent makeChat(boolean tag) { ITextComponent chat = new TextComponentString(tag ? "[test] " : ""); chat.getStyle().setBold(true); { ITextComponent colored = new TextComponentString("This should be green. "); colored.getStyle().setColor(TextFormatting.GREEN); chat.appendSibling(colored); } chat.appendText(" "); { ITextComponent link = new TextComponentString("This is a link."); link.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "http://google.com/")); chat.appendSibling(link); } return chat; } }
@SubscribeEvent public void load(EntityJoinWorldEvent event) { if(!displayed && event.getEntity() instanceof EntityPlayer && event.getWorld().isRemote) { Style style = new Style(); style.setClickEvent(new ClickEvent(Action.OPEN_URL, "https://www.patreon.com/mrcrayfish")); style.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(TextFormatting.AQUA + "Open MrCrayfish's Patreon"))); event.getEntity().sendMessage(new TextComponentString(TextFormatting.RED.toString() + TextFormatting.BOLD.toString() + "MrCrayfish's Device Mod:")); event.getEntity().sendMessage(new TextComponentString("You are using a development version of the Device Mod.")); event.getEntity().sendMessage(new TextComponentString("Please be aware that not all features are finished")); event.getEntity().sendMessage(new TextComponentString("and may be completely changed in a future update!")); event.getEntity().sendMessage(new TextComponentString(TextFormatting.GOLD.toString() + TextFormatting.BOLD.toString() + "> Support MrCrayfish On Patreon <").setStyle(style)); } }
accept.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tpaccept " + self.player.getName())); accept.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("/tpaccept " + self.player.getName())));