Fix potential NPE

this can occur if the player disconnects before logging in
This commit is contained in:
KingRainbow44 2023-04-29 01:59:45 -04:00
parent c2e9bdd261
commit 7efa6d1b78
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE

View File

@ -137,6 +137,8 @@ public class QuestManager extends BasePlayerManager {
} }
private void checkTimeVars() { private void checkTimeVars() {
if (this.player.getWorld() == null) return;
val currentDays = player.getWorld().getTotalGameTimeDays(); val currentDays = player.getWorld().getTotalGameTimeDays();
val currentHours = player.getWorld().getTotalGameTimeHours(); val currentHours = player.getWorld().getTotalGameTimeHours();
boolean checkDays = currentDays != lastDayCheck; boolean checkDays = currentDays != lastDayCheck;
@ -151,12 +153,12 @@ public class QuestManager extends BasePlayerManager {
player.getActiveQuestTimers().forEach(mainQuestId -> { player.getActiveQuestTimers().forEach(mainQuestId -> {
if (checkHours) { if (checkHours) {
queueEvent(QuestCond.QUEST_COND_TIME_VAR_GT_EQ, mainQuestId); this.queueEvent(QuestCond.QUEST_COND_TIME_VAR_GT_EQ, mainQuestId);
queueEvent(QuestContent.QUEST_CONTENT_TIME_VAR_GT_EQ, mainQuestId); this.queueEvent(QuestContent.QUEST_CONTENT_TIME_VAR_GT_EQ, mainQuestId);
} }
if (checkDays) { if (checkDays) {
queueEvent(QuestCond.QUEST_COND_TIME_VAR_PASS_DAY, mainQuestId); this.queueEvent(QuestCond.QUEST_COND_TIME_VAR_PASS_DAY, mainQuestId);
queueEvent(QuestContent.QUEST_CONTENT_TIME_VAR_PASS_DAY, mainQuestId); this.queueEvent(QuestContent.QUEST_CONTENT_TIME_VAR_PASS_DAY, mainQuestId);
} }
}); });
} }