mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 00:07:56 +01:00
We build for 1.5.
By: EvilSeph <evilseph@gmail.com>
This commit is contained in:
parent
10cd1cbb5c
commit
b02f2bb28b
@ -1,6 +1,5 @@
|
|||||||
package org.bukkit.util;
|
package org.bukkit.util;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -42,8 +41,8 @@ public class ChatPaginator {
|
|||||||
|
|
||||||
int from = (actualPageNumber - 1) * pageHeight;
|
int from = (actualPageNumber - 1) * pageHeight;
|
||||||
int to = from + pageHeight <= lines.length ? from + pageHeight : lines.length;
|
int to = from + pageHeight <= lines.length ? from + pageHeight : lines.length;
|
||||||
String[] selectedLines = Arrays.copyOfRange(lines, from, to);
|
String[] selectedLines = Java15Compat.Arrays_copyOfRange(lines, from, to);
|
||||||
|
|
||||||
return new ChatPage(selectedLines, actualPageNumber, totalPages);
|
return new ChatPage(selectedLines, actualPageNumber, totalPages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +58,7 @@ public class ChatPaginator {
|
|||||||
if (rawString == null) {
|
if (rawString == null) {
|
||||||
return new String[] {""};
|
return new String[] {""};
|
||||||
}
|
}
|
||||||
|
|
||||||
// A string shorter than the lineWidth is a single line
|
// A string shorter than the lineWidth is a single line
|
||||||
if (rawString.length() <= lineLength && !rawString.contains("\n")) {
|
if (rawString.length() <= lineLength && !rawString.contains("\n")) {
|
||||||
return new String[] {rawString};
|
return new String[] {rawString};
|
||||||
@ -92,7 +91,7 @@ public class ChatPaginator {
|
|||||||
line.append(word);
|
line.append(word);
|
||||||
}
|
}
|
||||||
word = new StringBuilder();
|
word = new StringBuilder();
|
||||||
|
|
||||||
if (c == '\n') { // Newline forces the line to flush
|
if (c == '\n') { // Newline forces the line to flush
|
||||||
lines.add(line.toString());
|
lines.add(line.toString());
|
||||||
line = new StringBuilder();
|
line = new StringBuilder();
|
||||||
@ -105,16 +104,16 @@ public class ChatPaginator {
|
|||||||
if(line.length() > 0) { // Only add the last line if there is anything to add
|
if(line.length() > 0) { // Only add the last line if there is anything to add
|
||||||
lines.add(line.toString());
|
lines.add(line.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return lines.toArray(new String[0]);
|
return lines.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ChatPage {
|
public static class ChatPage {
|
||||||
|
|
||||||
private String[] lines;
|
private String[] lines;
|
||||||
private int pageNumber;
|
private int pageNumber;
|
||||||
private int totalPages;
|
private int totalPages;
|
||||||
|
|
||||||
public ChatPage(String[] lines, int pageNumber, int totalPages) {
|
public ChatPage(String[] lines, int pageNumber, int totalPages) {
|
||||||
this.lines = lines;
|
this.lines = lines;
|
||||||
this.pageNumber = pageNumber;
|
this.pageNumber = pageNumber;
|
||||||
|
Loading…
Reference in New Issue
Block a user