Commits

md_5 authored 4f16bdbabba
SPIGOT-3568: Fix single letter pagination edge case
No tags

src/main/java/org/bukkit/util/ChatPaginator.java

Modified
86 86 lineColorChars += 2;
87 87 i++; // Eat the next character as we have already processed it
88 88 continue;
89 89 }
90 90
91 91 if (c == ' ' || c == '\n') {
92 92 if (line.length() == 0 && word.length() > lineLength) { // special case: extremely long word begins a line
93 93 for (String partialWord : word.toString().split("(?<=\\G.{" + lineLength + "})")) {
94 94 lines.add(partialWord);
95 95 }
96 - } else if (line.length() + word.length() - lineColorChars == lineLength) { // Line exactly the correct length...newline
96 + } else if (line.length() + 1 + word.length() - lineColorChars == lineLength) { // Line exactly the correct length...newline
97 + if (line.length() > 0) {
98 + line.append(' ');
99 + }
97 100 line.append(word);
98 101 lines.add(line.toString());
99 102 line = new StringBuilder();
100 103 lineColorChars = 0;
101 104 } else if (line.length() + 1 + word.length() - lineColorChars > lineLength) { // Line too long...break the line
102 105 for (String partialWord : word.toString().split("(?<=\\G.{" + lineLength + "})")) {
103 106 lines.add(line.toString());
104 107 line = new StringBuilder(partialWord);
105 108 }
106 109 lineColorChars = 0;

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut