public static String formatAmmo(int durability, int ref) { return String.format("%s: %s%s%s/%s%s", Util.translate(LOC_Ammo), CustomFontColor.valueToColorCode((float) durability / (float) ref), df.format(durability), TextFormatting.GRAY.toString(), COLOR_Durability, df.format(ref)) + TextFormatting.RESET; }
private static String removeChatFormatting(String string) { String withoutFormattingCodes = TextFormatting.getTextWithoutFormattingCodes(string); return (withoutFormattingCodes == null) ? "" : withoutFormattingCodes; }
public static String getFontChar(TextFormatting color) { if (color == null) { return ""; } return color + color.getFriendlyName().substring(0, 1); }
private static String configToTextFormat(String input) { if ("context".equals(input)) { return "context"; } StringBuilder builder = new StringBuilder(); String[] splitted = StringUtils.split(input, ','); for (String s : splitted) { TextFormatting format = TextFormatting.getValueByName(s); if (format != null) { builder.append(format.toString()); } } return builder.toString(); }
/** * Change attribute format when displayed on item tooltip * * @param event */ @SubscribeEvent public void onItemTooltip(ItemTooltipEvent event) { for (String txt : event.getToolTip()) { if (txt.startsWith(TextFormatting.BLUE.toString())) { if (txt.contains(attributeNames[0]) || txt.contains(attributeNames[2])) event.getToolTip().set(event.getToolTip().indexOf(txt), TextFormatting.DARK_GREEN + TextFormatting.getTextWithoutFormattingCodes(txt)); else if (txt.contains(attributeNames[3])) event.getToolTip().set(event.getToolTip().indexOf(txt), TextFormatting.DARK_GREEN + reformat(txt, 3)); else if (txt.contains(attributeNames[1])) event.getToolTip().set(event.getToolTip().indexOf(txt), TextFormatting.GOLD + reformat(txt, 1)); } } if(event.getItemStack().getItem() instanceof IBackStabbable){ event.getToolTip().add(TextFormatting.GOLD + I18n.format("attribute.name.weapon.backstab")); } }
cvBackground.addPanel(cvFormatList); TextFormatting[] tfValues = TextFormatting.values(); for(int i = 0; i < tfValues.length; i++) cvFormatList.addPanel(new PanelButtonStorage<>(new GuiRectangle(0, i * 16, 100, 16), 1, tfValues[i].getFriendlyName(), tfValues[i].toString()));
private void addButtonRowForTextbox(int signRowNum, int height, int leftMost) { Map<TextFormatting, GuiButtonTooltip> rowButtons = buttonMaps.get(signRowNum); int buttonID = signRowNum * 100; int w, h, x = leftMost, y = height;//leftMost was 104 w = h = 14; for (TextFormatting color : TextFormatting.values()) { if (color.isColor()) { GuiButtonTooltip btn = new GuiButtonTooltip(buttonID++, x + 40, y, w, h, getColorChar(color)); btn.allowPressedIfDisabled().setTooltip(color + color.getFriendlyName()); btn.packedFGColour = toHex(color); this.addButton(btn); x += w - 1; rowButtons.put(color, btn); } } x += w * 3 + 2; y = height; for (TextFormatting color : TextFormatting.values()) { if (!color.isColor() && color != TextFormatting.RESET) { GuiButtonTooltip btn = new GuiButtonTooltip(buttonID++, x, y, w, h, getFontChar(color)); btn.allowPressedIfDisabled().setTooltip(color + color.getFriendlyName()); this.addButton(btn); x += w; rowButtons.put(color, btn); } } }
@Override public void messageOnServerThread(final TeamColonyColorChangeMessage message, final EntityPlayerMP player) { final Colony colony = ColonyManager.getColonyByDimension(message.colonyId, message.dimension); if (colony != null) { //Verify player has permission to change this huts settings if (!colony.getPermissions().hasPermission(player, Action.MANAGE_HUTS)) { return; } colony.setColonyColor(TextFormatting.values()[message.colorOrdinal]); } } }
@Override public void apply() { BotaniaAPI.registerKnowledgeType(unlocalized, TextFormatting.getValueByName(color.toUpperCase()), autoUnlock); }
public static String parseFriendlyModNameFormat(String formatWithEnumNames) { if (formatWithEnumNames.isEmpty()) { return ""; } StringBuilder format = new StringBuilder(); String[] strings = formatWithEnumNames.split(" "); for (String string : strings) { TextFormatting valueByName = TextFormatting.getValueByName(string); if (valueByName != null) { format.append(valueByName.toString()); } else { Log.get().error("Invalid format: {}", string); } } return format.toString(); }
/** * Initialise the previous/next and drop down list for style. */ private void initColorPicker() { registerButton(BUTTON_PREVIOUS_COLOR_ID, this::previousStyle); registerButton(BUTTON_NEXT_COLOR_ID, this::nextStyle); findPaneOfTypeByID(DROPDOWN_COLOR_ID, DropDownList.class).setEnabled(enabled); colorDropDownList = findPaneOfTypeByID(DROPDOWN_COLOR_ID, DropDownList.class); colorDropDownList.setHandler(this::onDropDownListChanged); final List<TextFormatting> textColors = Arrays.stream(TextFormatting.values()).filter(TextFormatting::isColor).collect(Collectors.toList()); colorDropDownList.setDataProvider(new DropDownList.DataProvider() { @Override public int getElementCount() { return textColors.size(); } @Override public String getLabel(final int index) { if (index >= 0 && index < textColors.size()) { return textColors.get(index).getFriendlyName(); } return ""; } }); }
private String getFormattedString(TextData data) { StringBuilder modifiers = new StringBuilder(); modifiers.append(TextFormatting.getValueByName(data.color)); if (data.bold) { modifiers.append(TextFormatting.BOLD); } if (data.italic) { modifiers.append(TextFormatting.ITALIC); } if (data.underlined) { modifiers.append(TextFormatting.UNDERLINE); } if (data.strikethrough) { modifiers.append(TextFormatting.STRIKETHROUGH); } if (data.obfuscated) { modifiers.append(TextFormatting.OBFUSCATED); } modifiers.append(data.text); return modifiers.toString(); }
public static String formatPartialAmount(int value, int max) { return String.format("%s%s%s/%s%s", CustomFontColor.valueToColorCode((float) value / (float) max), Util.df.format(value), TextFormatting.GRAY.toString(), CustomFontColor.valueToColorCode(1f), Util.df.format(max)) + TextFormatting.RESET; } }
private static String removeChatFormatting(String string) { String withoutFormattingCodes = TextFormatting.getTextWithoutFormattingCodes(string); return (withoutFormattingCodes == null) ? "" : withoutFormattingCodes; }
this.teamColonyColor = TextFormatting.values()[buf.readInt()];
@Override public String getLabel(final int index) { if (index >= 0 && index < textColors.size()) { return textColors.get(index).getFriendlyName(); } return ""; } });
modifiers += TextFormatting.getValueByName(data.color);