public class FontUtils { public static final Pattern SPACE_OPTIMAL_PATTERN = Pattern.compile("()"); public static final String ROW_1_CHAR = "\uE0A1"; public static final String ROW_2_CHAR = "\uE0A2"; public static final String ROW_3_CHAR = "\uE0A3"; public static final String ROW_4_CHAR = "\uE0A4"; public static final String ROW_5_CHAR = "\uE0A5"; public static final String ROW_6_CHAR = "\uE0A6"; private static final int INVENTORY_ROW_SIZE = 9; private static final int INVENTORY_SLOT_SIZE = 18; private static final String ONE_SPACE = space(1); private static final String INVENTORY_SLOT_SPACE = space(INVENTORY_SLOT_SIZE); private static final String INVENTORY_ROW_SPACE = space(-(INVENTORY_ROW_SIZE * INVENTORY_SLOT_SIZE)); private FontUtils() { } public static String space(int size) { return ""; } public static String color(Color awtColor) { return ""; } public static String mergeSpaces(String input) { Matcher matcher = SPACE_OPTIMAL_PATTERN.matcher(input); while (matcher.find()) { String line = matcher.group(1); String first = matcher.group(2); String second = matcher.group(3); int merged = Integer.parseInt(first) + Integer.parseInt(second); input = input.replace(line, ""); } return input; } public static String renderLockedSlots(Map slotColors) { // We render the slots top to bottom, left to right StringBuilder builder = new StringBuilder(); Color currentColor = null; for (int row = 0; row < 6; row++) { for (int column = 0; column < INVENTORY_ROW_SIZE; column++) { int slot = (row * INVENTORY_ROW_SIZE) + column; if (!slotColors.containsKey(slot)) { builder.append(INVENTORY_SLOT_SPACE); continue; } Color color = slotColors.get(slot); if (!color.equals(currentColor)) { if (currentColor != null) { builder.append(""); } builder.append(color(color)); currentColor = color; } builder.append(getRowChar(row + 1)); builder.append(ONE_SPACE); } builder.append(INVENTORY_ROW_SPACE); } if (currentColor != null) { builder.append(""); } String output = builder.toString(); return mergeSpaces(output); } private static String getRowChar(int row) { return switch (row) { case 1 -> ROW_1_CHAR; case 2 -> ROW_2_CHAR; case 3 -> ROW_3_CHAR; case 4 -> ROW_4_CHAR; case 5 -> ROW_5_CHAR; case 6 -> ROW_6_CHAR; default -> throw new IllegalArgumentException("Invalid row: " + row); }; } }