mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-02 17:09:58 +01:00
Make the paging logic even more complicated.
This commit is contained in:
parent
0292cb59cd
commit
f485cbc48b
@ -55,14 +55,31 @@ public class BookPager
|
||||
while (pointer < lineLength)
|
||||
{
|
||||
Character letter = pageLine.charAt(pointer);
|
||||
|
||||
|
||||
if (pageLine.charAt(start) == ' ')
|
||||
{
|
||||
start++;
|
||||
pointer++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (length >= max || (letter == '\u00a7' && length + 1 >= max))
|
||||
{
|
||||
int pos = pointer;
|
||||
while (pos > start && pageLine.charAt(pos) != ' ' && pageLine.charAt(pos) != "\n".charAt(0))
|
||||
{
|
||||
pos--;
|
||||
}
|
||||
if (pos != start)
|
||||
{
|
||||
pointer = pos;
|
||||
}
|
||||
|
||||
tempLine = pageLine.substring(start, pointer);
|
||||
pageLines.add(tempLine);
|
||||
start = pointer;
|
||||
length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (letter == '\u00a7' && pointer + 1 < lineLength)
|
||||
{
|
||||
@ -77,7 +94,15 @@ public class BookPager
|
||||
}
|
||||
pointer++;
|
||||
}
|
||||
else if (letter == ' ')
|
||||
else if (letter == 'i' || letter == '.' || letter == ',')
|
||||
{
|
||||
length += (0.4 * weight);
|
||||
}
|
||||
else if (letter == 'l')
|
||||
{
|
||||
length += (0.6 * weight);
|
||||
}
|
||||
else if (letter == ' ' || letter == 't')
|
||||
{
|
||||
length += (0.7 * weight);
|
||||
}
|
||||
@ -87,6 +112,7 @@ public class BookPager
|
||||
}
|
||||
pointer++;
|
||||
}
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
tempLine = pageLine.substring(start, lineLength);
|
||||
@ -100,7 +126,7 @@ public class BookPager
|
||||
StringBuilder newPage = new StringBuilder();
|
||||
for (int i = count; i < count + 12 && i < pageLines.size(); i++)
|
||||
{
|
||||
newPage.append("\n").append(pageLines.get(i));
|
||||
newPage.append(pageLines.get(i)).append("\n");
|
||||
}
|
||||
|
||||
pages.add(newPage.toString());
|
||||
|
Loading…
Reference in New Issue
Block a user