Safety check Quest Journal, resolves #243

This commit is contained in:
HappyPikachu 2018-01-17 19:25:02 -05:00
parent e85f67ed0c
commit 0562b57ac4

View File

@ -265,18 +265,22 @@ public class Quester {
currentLength += quest.name.length();
currentLines += (quest.name.length() / 19);
}
for (String obj : getObjectivesReal(quest)) {
// Length/Line check
if ((currentLength + obj.length() > 240) || (currentLines + ((obj.length() % 19) == 0 ? (obj.length() / 19) : ((obj.length() / 19) + 1))) > 13) {
book.addPage(page);
page = obj + "\n";
currentLength = obj.length();
currentLines = (obj.length() % 19) == 0 ? (obj.length() / 19) : (obj.length() + 1);
} else {
page += obj + "\n";
currentLength += obj.length();
currentLines += (obj.length() / 19);
if (getObjectivesReal(quest) != null) {
for (String obj : getObjectivesReal(quest)) {
// Length/Line check
if ((currentLength + obj.length() > 240) || (currentLines + ((obj.length() % 19) == 0 ? (obj.length() / 19) : ((obj.length() / 19) + 1))) > 13) {
book.addPage(page);
page = obj + "\n";
currentLength = obj.length();
currentLines = (obj.length() % 19) == 0 ? (obj.length() / 19) : (obj.length() + 1);
} else {
page += obj + "\n";
currentLength += obj.length();
currentLines += (obj.length() / 19);
}
}
} else {
plugin.getLogger().severe("Quest Journal: objectives were null for " + quest.name);
}
if (currentLines < 13)
page += "\n";