mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-09-16 01:57:09 +02: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)
|
while (pointer < lineLength)
|
||||||
{
|
{
|
||||||
Character letter = pageLine.charAt(pointer);
|
Character letter = pageLine.charAt(pointer);
|
||||||
|
|
||||||
|
if (pageLine.charAt(start) == ' ')
|
||||||
|
{
|
||||||
|
start++;
|
||||||
|
pointer++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (length >= max || (letter == '\u00a7' && length + 1 >= max))
|
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);
|
tempLine = pageLine.substring(start, pointer);
|
||||||
pageLines.add(tempLine);
|
pageLines.add(tempLine);
|
||||||
start = pointer;
|
start = pointer;
|
||||||
length = 0;
|
length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (letter == '\u00a7' && pointer + 1 < lineLength)
|
if (letter == '\u00a7' && pointer + 1 < lineLength)
|
||||||
{
|
{
|
||||||
@ -77,7 +94,15 @@ public class BookPager
|
|||||||
}
|
}
|
||||||
pointer++;
|
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);
|
length += (0.7 * weight);
|
||||||
}
|
}
|
||||||
@ -87,6 +112,7 @@ public class BookPager
|
|||||||
}
|
}
|
||||||
pointer++;
|
pointer++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length > 0)
|
if (length > 0)
|
||||||
{
|
{
|
||||||
tempLine = pageLine.substring(start, lineLength);
|
tempLine = pageLine.substring(start, lineLength);
|
||||||
@ -100,7 +126,7 @@ public class BookPager
|
|||||||
StringBuilder newPage = new StringBuilder();
|
StringBuilder newPage = new StringBuilder();
|
||||||
for (int i = count; i < count + 12 && i < pageLines.size(); i++)
|
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());
|
pages.add(newPage.toString());
|
||||||
|
Loading…
Reference in New Issue
Block a user