diff options
| author | Krakenied <Krakenied1@gmail.com> | 2024-09-06 21:17:15 +0200 |
|---|---|---|
| committer | Krakenied <46192742+Krakenied@users.noreply.github.com> | 2024-09-06 21:30:21 +0200 |
| commit | 721bce0f58b6c90f520a84dace60c35dbe9bbacc (patch) | |
| tree | 43a40ceb3184e56731e084ff7a3ec206e1a7d51c /bukkit/src/main/java | |
| parent | c1a01536f7bd3fdffe46ecd24115c4515350a283 (diff) | |
Move the null check to a logically more proper place
Diffstat (limited to 'bukkit/src/main/java')
| -rw-r--r-- | bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/TradingTaskType.java | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/TradingTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/TradingTaskType.java index 6fd4440c..ce74a327 100644 --- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/TradingTaskType.java +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/TradingTaskType.java @@ -104,7 +104,7 @@ public final class TradingTaskType extends BukkitTaskType { } } - 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"); @@ -112,16 +112,16 @@ public final class TradingTaskType extends BukkitTaskType { 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"); @@ -129,10 +129,10 @@ public final class TradingTaskType extends BukkitTaskType { 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; } |
