private void split() { this.prefix = new String[60]; this.suffix = new String[60]; for (int i = 0; i < 60; i++) { String s = ss[i]; if (s == null || s.isEmpty()) continue; if (s.length() <= 16) prefix[i] = s; else { String px = s.substring(0, 16); if (px.charAt(15) == '\u00A7') px = s.substring(0, 15); String color = ChatColor.getLastColors(px); if (color == null || color.isEmpty()) color = "\u00A7f"; String sx = color; if (px.length() == 15) { int l = s.length(); if (l < 32) sx += s.substring(15, s.length()); else sx += s.substring(15, 32); } else { int l = s.length(); if (l < 32) sx += s.substring(16, s.length()); else sx += s.substring(16, 32); } prefix[i] = px; suffix[i] = sx; } } }
public static List<String> wrapLoreText(String string) { String workingString = ChatColor.translateAlternateColorCodes('&', string).trim(); if (workingString.length() <= LORE_LINE_LENGTH) return Arrays.asList(workingString); // Because this is faster! double numberOfLines = Math.ceil(workingString.length() / LORE_LINE_LENGTH); // Always round up List<String> lines = new ArrayList<>(); // Get a list to put the lines in and fill it up String lastColor = null; // MUST start next line with last color of former line. for (int lineIndex = 0; lineIndex < numberOfLines; lineIndex++) { String line = workingString.substring( lineIndex * LORE_LINE_LENGTH, Math.min((lineIndex + 1) * LORE_LINE_LENGTH, workingString.length())); if (lastColor != null) line = lastColor + line; lastColor = ChatColor.getLastColors(line); lines.add(line); } return lines; }