Correctly handle line overflow in book pager

Fixes a bug with the last book pager tweak.
This commit is contained in:
KHobbits 2014-04-05 15:33:38 +01:00
parent af3f3fb4c7
commit fe9fbf585f
2 changed files with 13 additions and 4 deletions

View file

@ -5,6 +5,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import org.bukkit.Bukkit;
public class BookPager public class BookPager
@ -94,7 +95,10 @@ public class BookPager
tempLine = pageLine.substring(start, pointer); tempLine = pageLine.substring(start, pointer);
pageLines.add(tempLine); pageLines.add(tempLine);
buildPage(pages, pageLines, forcePageEnd); if (buildPage(pages, pageLines, forcePageEnd))
{
pageLength = 0;
}
forcePageEnd = false; forcePageEnd = false;
start = pointer; start = pointer;
@ -149,7 +153,10 @@ public class BookPager
{ {
tempLine = pageLine.substring(start, lineLength); tempLine = pageLine.substring(start, lineLength);
pageLines.add(tempLine); pageLines.add(tempLine);
buildPage(pages, pageLines, false); if (buildPage(pages, pageLines, false))
{
pageLength = 0;
}
} }
} }
@ -157,7 +164,7 @@ public class BookPager
return pages; return pages;
} }
void buildPage(List<String> pages, List<String> lines, boolean override) boolean buildPage(List<String> pages, List<String> lines, boolean override)
{ {
if (override || lines.size() > lineMax) if (override || lines.size() > lineMax)
{ {
@ -168,6 +175,8 @@ public class BookPager
} }
pages.add(newPage.toString()); pages.add(newPage.toString());
lines.clear(); lines.clear();
return true;
} }
return false;
} }
} }

View file

@ -4,11 +4,11 @@
<actionName>build-with-dependencies</actionName> <actionName>build-with-dependencies</actionName>
<reactor>also-make</reactor> <reactor>also-make</reactor>
<goals> <goals>
<goal>clean</goal>
<goal>package</goal> <goal>package</goal>
<goal>dependency:copy</goal> <goal>dependency:copy</goal>
</goals> </goals>
</action> </action>
<action> <action>