RankNone(Ranks r, String id) { super(r, id); displayName.getStyle().setColor(TextFormatting.DARK_GRAY); }
public Rank(Ranks r, String id) { super(id); displayName = new TextComponentString(getID()); displayName.getStyle().setColor(TextFormatting.DARK_GREEN); ranks = r; parent = ranks.none; tags = new LinkedHashSet<>(); permissions = new ArrayList<>(); cachedPermissions = new HashMap<>(); cachedConfig = new HashMap<>(); }
private static void sendChatMessage(EntityPlayerSP sender, String chatMessage) { if (chatMessage.length() <= 256) { sender.sendChatMessage(chatMessage); } else { ITextComponent errorMessage = new TextComponentTranslation("jei.chat.error.command.too.long"); errorMessage.getStyle().setColor(TextFormatting.RED); sender.sendStatusMessage(errorMessage, false); ITextComponent chatMessageComponent = new TextComponentString(chatMessage); chatMessageComponent.getStyle().setColor(TextFormatting.RED); sender.sendStatusMessage(chatMessageComponent, false); } }
private ITextComponent getRequestMessage(@NotNull final IRequest request) { final ITextComponent component = new NonSiblingFormattingTextComponent(); component.appendSibling(request.getShortDisplayString()); component.getStyle().setColor(TextFormatting.WHITE); return component; }
public static ITextComponent translateToIChatComponent(TextFormatting colour, boolean plural, String id, Object... args) { ITextComponent iChatComponent = new TextComponentString(Translator.translate(plural, id, args)); iChatComponent.getStyle().setColor(colour); return iChatComponent; }
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); } }
public void notifyAll(MinecraftServer server, Function<ICommandSender, ITextComponent> function, boolean error) { for (EntityPlayerMP player : server.getPlayerList().getPlayers()) { ITextComponent component = function.apply(player); component.getStyle().setColor(error ? TextFormatting.DARK_RED : TextFormatting.LIGHT_PURPLE); Notification.of(NOTIFICATION_ID, component).setImportant(true).send(server, null); } FTBUtilities.LOGGER.info(function.apply(null).getUnformattedText()); }
@Override public ITextComponent getDisplayName() { ITextComponent name = super.getDisplayName(); name.getStyle().setColor(getFaction().getChatColor()); return name; }
private void syncTextboxesToSign() { for (GuiTextField txtNew : txtBoxes) { int id = txtNew.getId() - 700; Style style = this.sign.signText[id].getStyle(); TextComponentString text = new TextComponentString(txtNew.getText()); text.setStyle(style); this.sign.signText[id] = text; } }
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { final IWhitespaceSplitter splitArgs = WhitespaceSplitters.fromSplitArray(args); try { commandComponent.execute(sender, splitArgs); } catch (NestedCommandException e) { e.pushCommandName(name); final ITextComponent message = e.getChatComponent(); message.getStyle().setColor(TextFormatting.RED); sender.sendMessage(message); } catch (Exception e) { Log.info(e, "Failed to execute command"); final List<String> causes = Lists.newArrayList(); Throwable current = e; while (current != null) { causes.add(Strings.nullToEmpty(current.getMessage())); current = current.getCause(); } throw new CommandException("openmodslib.command.calc_error", Joiner.on("', caused by '").join(causes)); } if (!splitArgs.isFinished()) throw new CommandException("openmodslib.command.calc_extra_args", splitArgs.getTail()); } }
public static ITextComponent getGroupComponent(String group) { if (group.equals(level0)) { ITextComponent nameComponent = new TextComponentString("[") .appendSibling(new TextComponentTranslation("psimisc.fakeLevel.psidust")) .appendText("]"); nameComponent.getStyle().setColor(TextFormatting.AQUA); nameComponent.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentTranslation("psimisc.levelDisplay", 0))); return nameComponent; } PieceGroup pieceGroup = PsiAPI.groupsForName.get(group); if (pieceGroup == null) { ITextComponent errorComponent = new TextComponentString("ERROR"); errorComponent.getStyle().setColor(TextFormatting.RED); return errorComponent; } ITextComponent nameComponent = new TextComponentString("[") .appendSibling(new TextComponentTranslation(pieceGroup.getUnlocalizedName())) .appendText("]"); nameComponent.getStyle().setColor(TextFormatting.AQUA); nameComponent.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentTranslation("psimisc.levelDisplay", pieceGroup.levelRequirement))); return nameComponent; }
public ITextComponent getNameForChat() { if (cachedNameForChat != null) { return cachedNameForChat; } String text = player.getRankConfig(FTBUtilitiesPermissions.CHAT_NAME_FORMAT).getString(); try { cachedNameForChat = TextComponentParser.parse(text, FTBLibCommon.chatFormattingSubstituteFunction(player)); } catch (Exception ex) { String s = "Error parsing " + text + ": " + ex.getLocalizedMessage(); FTBUtilities.LOGGER.error(s); cachedNameForChat = new TextComponentString("BrokenFormatting"); cachedNameForChat.getStyle().setColor(TextFormatting.RED); cachedNameForChat.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(s))); } cachedNameForChat.appendText(" "); return cachedNameForChat; } }
/** * Send a message to chat regardless of chatDebug (should only be used for critically important messages, or as a direct response to a chat command) * * @param message The message to display in chat */ default void logDirect(String message) { ITextComponent component = MESSAGE_PREFIX.createCopy(); component.getStyle().setColor(TextFormatting.GRAY); component.appendSibling(new TextComponentString(" " + message)); Minecraft.getMinecraft().addScheduledTask(() -> Baritone.settings().logger.get().accept(component)); } }
@Override public void dump(Collection<NoteEntry> notes, ICommandSender sender) { int count = 0; for (NoteEntry note : notes) { ITextComponent level = new TextComponentTranslation(note.category.translated); level.getStyle().setColor(note.category.color); sender.sendMessage(new TextComponentTranslation("openeye.chat.note", count++, level)); ITextComponent title = note.title(); title.getStyle().setBold(true); sender.sendMessage(title); sender.sendMessage(note.content()); String url = note.url(); if (!Strings.isNullOrEmpty(url)) sender.sendMessage(new TextComponentString(note.url())); } } }
@NotNull @Override public ITextComponent getShortDisplayString() { final ITextComponent combined = new NonSiblingFormattingTextComponent(); combined.appendSibling(new TextComponentString(getRequest().getCount() + " ")); combined.appendSibling(getRequest().getStack().getTextComponent()); combined.getStyle().setColor(TextFormatting.BLACK); return combined; } }
public static void setProfile(EntityPlayer player, LockProfile profile) { String name = player.getName(); if(profile == null) lockProfiles.remove(name); else { boolean locked = player.getEntityData().getBoolean(TAG_LOCKED_ONCE); if(!locked) { ITextComponent text = new TextComponentTranslation("quarkmisc.rotationLockBefore"); ITextComponent keybind = new TextComponentKeybind("quark.keybind.lockBuilding"); keybind.getStyle().setColor(TextFormatting.AQUA); text.appendSibling(keybind); text.appendSibling(new TextComponentTranslation("quarkmisc.rotationLockAfter")); player.sendMessage(text); player.getEntityData().setBoolean(TAG_LOCKED_ONCE, true); } lockProfiles.put(name, profile); } }
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; } }
@Override public ITextComponent processStack(ItemStack stack) { ITextComponent component = new TextComponentString(""); component.appendSibling(stack.getTextComponent()); if (stack.hasDisplayName()) { String s = stack.getItem().getUnlocalizedName(stack); if (!I18n.canTranslate(s)) { s += ".name"; } ITextComponent component2 = new TextComponentTranslation(s); component2.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(s))); component.appendText(" (").appendSibling(component2).appendText(")"); } return component; } }, Id {
component.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, FTBUtilities.lang(sender, "ftbutilities.lang.tpa.from_to", otherName, selfName))); sender.sendMessage(component); component.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, FTBUtilities.lang(other.player.getPlayer(), "ftbutilities.lang.tpa.from_to", otherName, selfName))); other.player.getPlayer().sendMessage(component);