Paper/src/main/java/org/bukkit/craftbukkit/TextWrapper.java

25 lines
643 B
Java
Raw Normal View History

package org.bukkit.craftbukkit;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
public class TextWrapper {
public static List<String> wrapText(final String text) {
ArrayList<String> output = new ArrayList<String>();
String[] lines = text.split("\n");
String lastColor = null;
for (int i = 0; i < lines.length; i++) {
String line = lines[i];
if (lastColor != null) {
line = lastColor + line;
}
output.add(line);
lastColor = ChatColor.getLastColors(line);
}
return output;
}
}