Skip to content

Commit

Permalink
Add fix for citizens_deliver as well
Browse files Browse the repository at this point in the history
  • Loading branch information
LMBishop committed Apr 21, 2022
1 parent 23aeb21 commit 5258cbf
Showing 1 changed file with 22 additions and 14 deletions.
Expand Up @@ -123,32 +123,40 @@ private void checkInventory(Player player, NPC npc) {
fixedQuestItemCache.put(quest.getId(), task.getId(), qi);
}

int[] amountPerSlot = getAmountsPerSlot(player, qi);
int total = Math.min(amountPerSlot[36], amount);

int progress;
if (taskProgress.getProgress() == null) {
progress = 0;
} else {
progress = (int) taskProgress.getProgress();
}

int deficit = amount - progress;
if (allowPartial) {
if (total == 0) {
continue;
}

int[] amountPerSlot = getAmountsPerSlot(player, qi);
int total = Math.min(amountPerSlot[36], deficit);
progress += total;

if (total == 0) {
continue;
}
// We must ALWAYS remove items if partial completion is allowed
// https://github.com/LMBishop/Quests/issues/375
removeItemsInSlots(player, amountPerSlot, total);

progress += total;
taskProgress.setProgress(progress);
taskProgress.setProgress(progress);
if (progress >= amount) {
taskProgress.setCompleted(true);
}
} else {
taskProgress.setProgress(total);
if (total >= amount) {
taskProgress.setCompleted(true);

if (progress >= amount) {
taskProgress.setCompleted(true);
if (remove) {
removeItemsInSlots(player, amountPerSlot, total);
if (remove) {
removeItemsInSlots(player, amountPerSlot, total);
}
}
} else if (remove && allowPartial) {
removeItemsInSlots(player, amountPerSlot, total);
}
}
}
Expand Down

0 comments on commit 5258cbf

Please sign in to comment.