mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-24 09:16:06 +01:00
Re-added TextWrapper, and fixed chat length issues (at cost of it looking not so nice sometimes!) This fixes BUKKIT-1275
By: Nathan Adams <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
ec19b8a466
commit
9aba8f4210
1 changed files with 20 additions and 0 deletions
|
@ -0,0 +1,20 @@
|
|||
package org.bukkit.craftbukkit;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class TextWrapper {
|
||||
private static final int CHAT_STRING_LENGTH = 119;
|
||||
|
||||
public static String[] wrapText(final String text) {
|
||||
return insertLineBreaks(text).split("\n");
|
||||
}
|
||||
|
||||
public static String insertLineBreaks(String input) {
|
||||
if (input.length() <= CHAT_STRING_LENGTH) return input;
|
||||
|
||||
String head = input.substring(0, CHAT_STRING_LENGTH);
|
||||
String tail = ChatColor.getLastColors(head) + input.substring(CHAT_STRING_LENGTH + (input.charAt(CHAT_STRING_LENGTH) == ' ' ? 1 : 0));
|
||||
|
||||
return head + "\n" + insertLineBreaks(tail);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue