2012-03-23 00:02:29 +01:00
|
|
|
package org.bukkit.craftbukkit;
|
|
|
|
|
2012-05-17 01:09:33 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import org.bukkit.ChatColor;
|
2012-03-23 00:22:35 +01:00
|
|
|
|
2012-05-17 01:09:33 +02:00
|
|
|
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;
|
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
for (String line : lines) {
|
2012-05-17 01:09:33 +02:00
|
|
|
if (lastColor != null) {
|
|
|
|
line = lastColor + line;
|
2012-03-23 00:22:35 +01:00
|
|
|
}
|
|
|
|
|
2012-05-17 01:09:33 +02:00
|
|
|
output.add(line);
|
|
|
|
lastColor = ChatColor.getLastColors(line);
|
2012-03-23 00:22:35 +01:00
|
|
|
}
|
2012-03-23 00:02:29 +01:00
|
|
|
|
2012-05-17 01:09:33 +02:00
|
|
|
return output;
|
2012-03-23 00:02:29 +01:00
|
|
|
}
|
2012-09-10 06:19:28 +02:00
|
|
|
}
|