Skip to content

Commit

Permalink
Move the null check to a logically more proper place
Browse files Browse the repository at this point in the history
  • Loading branch information
Krakenied committed Sep 6, 2024
1 parent c1a0153 commit 721bce0
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,35 +104,35 @@ public void onPlayerTrade(final @NotNull PlayerTradeEvent event) {
}
}

if (firstIngredient != null && task.hasConfigKey("first-ingredient")) {
if (task.hasConfigKey("first-ingredient")) {
QuestItem qi;
if ((qi = fixedQuestFirstIngredientCache.get(quest.getId(), task.getId())) == null) {
QuestItem fetchedItem = TaskUtils.getConfigQuestItem(task, "first-ingredient", "data");
fixedQuestFirstIngredientCache.put(quest.getId(), task.getId(), fetchedItem);
qi = fetchedItem;
}

super.debug("First ingredient was of type " + firstIngredient.getType(), quest.getId(), task.getId(), player.getUniqueId());
super.debug("First ingredient was of type " + (firstIngredient != null ? firstIngredient.getType() : null), quest.getId(), task.getId(), player.getUniqueId());

boolean exactMatch = TaskUtils.getConfigBoolean(task, "first-ingredient-exact-match", true);
if (!qi.compareItemStack(firstIngredient, exactMatch)) {
if (firstIngredient == null || !qi.compareItemStack(firstIngredient, exactMatch)) {
super.debug("First ingredient does not match required item, continuing...", quest.getId(), task.getId(), player.getUniqueId());
continue;
}
}

if (secondIngredient != null && task.hasConfigKey("second-ingredient")) {
if (task.hasConfigKey("second-ingredient")) {
QuestItem qi;
if ((qi = fixedQuestSecondIngredientCache.get(quest.getId(), task.getId())) == null) {
QuestItem fetchedItem = TaskUtils.getConfigQuestItem(task, "second-ingredient", "data");
fixedQuestSecondIngredientCache.put(quest.getId(), task.getId(), fetchedItem);
qi = fetchedItem;
}

super.debug("Second ingredient was of type " + secondIngredient.getType(), quest.getId(), task.getId(), player.getUniqueId());
super.debug("Second ingredient was of type " + (secondIngredient != null ? secondIngredient.getType() : null), quest.getId(), task.getId(), player.getUniqueId());

boolean exactMatch = TaskUtils.getConfigBoolean(task, "second-ingredient-exact-match", true);
if (!qi.compareItemStack(secondIngredient, exactMatch)) {
if (secondIngredient == null || !qi.compareItemStack(secondIngredient, exactMatch)) {
super.debug("Second ingredient does not match required item, continuing...", quest.getId(), task.getId(), player.getUniqueId());
continue;
}
Expand Down

0 comments on commit 721bce0

Please sign in to comment.