aboutsummaryrefslogtreecommitdiffstats
path: root/bukkit/src/main
diff options
context:
space:
mode:
authorLMBishop <13875753+LMBishop@users.noreply.github.com>2022-07-11 14:50:09 +0100
committerLMBishop <13875753+LMBishop@users.noreply.github.com>2022-07-11 14:50:09 +0100
commitf753a6ca11efb63cabb5f71c03701d4f257bad2e (patch)
tree7aa1de983e37bee77dcbac5cf359df7eb33c81af /bukkit/src/main
parent84eb73f9c31209e79291443270434356a7143962 (diff)
Fix interact task type
Diffstat (limited to 'bukkit/src/main')
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java1
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/InteractTaskType.java25
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/TaskUtils.java5
3 files changed, 11 insertions, 20 deletions
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java
index 48a137cb..ad967cdc 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java
@@ -314,6 +314,7 @@ public class BukkitQuestsPlugin extends JavaPlugin implements Quests {
taskTypeManager.registerTaskType(new CraftingTaskType(this));
taskTypeManager.registerTaskType(new BucketEmptyTaskType(this));
taskTypeManager.registerTaskType(new BucketFillTaskType(this));
+ taskTypeManager.registerTaskType(new InteractTaskType(this));
// TODO: FIX
// taskTypeManager.registerTaskType(new BrewingCertainTaskType());
try {
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/InteractTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/InteractTaskType.java
index c5137b49..1577c267 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/InteractTaskType.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/InteractTaskType.java
@@ -45,7 +45,6 @@ public final class InteractTaskType extends BukkitTaskType {
fixedQuestItemCache.clear();
}
- @SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInteract(PlayerInteractEvent event) {
if (event.getPlayer().hasMetadata("NPC")) return;
@@ -64,21 +63,16 @@ public final class InteractTaskType extends BukkitTaskType {
super.debug("Player interacted", quest.getId(), task.getId(), player.getUniqueId());
- List<String> configBlocks = TaskUtils.getConfigStringList(task, task.getConfigValues().containsKey("mob") ? "mob" : "mobs");
-
if (task.hasConfigKey("item")) {
ItemStack held = event.getItem();
- if (held == null) {
- super.debug("Item is required, current item is null", quest.getId(), task.getId(), player.getUniqueId());
- }
- super.debug("Item is required, current item is " + held.getType(), quest.getId(), task.getId(), player.getUniqueId());
+ super.debug("Item is required, current item is " + (held == null ? "null" : held.getType()) , quest.getId(), task.getId(), player.getUniqueId());
QuestItem qi;
if ((qi = fixedQuestItemCache.get(quest.getId(), task.getId())) == null) {
QuestItem fetchedItem = TaskUtils.getConfigQuestItem(task, "item", "data");
fixedQuestItemCache.put(quest.getId(), task.getId(), fetchedItem);
qi = fetchedItem;
}
- if (!qi.compareItemStack(held)) {
+ if (held == null || !qi.compareItemStack(held)) {
super.debug("Item is not the required item, continuing...", quest.getId(), task.getId(), player.getUniqueId());
continue;
} else {
@@ -86,15 +80,12 @@ public final class InteractTaskType extends BukkitTaskType {
}
}
- if (!configBlocks.isEmpty()) {
- Block block = event.getClickedBlock();
- if (block == null) {
- super.debug("Clicked block is required, current clicked block is null", quest.getId(), task.getId(), player.getUniqueId());
- }
- super.debug("Clicked block is required, current clicked block is " + block.getType(), quest.getId(), task.getId(), player.getUniqueId());
- if (TaskUtils.matchBlock(this, pendingTask, block, player.getUniqueId())) {
- super.debug("Block match", quest.getId(), task.getId(), player.getUniqueId());
- }
+ Block block = event.getClickedBlock();
+
+ super.debug("Current clicked block is " + (block == null ? "null" : block.getType()), quest.getId(), task.getId(), player.getUniqueId());
+ if (!TaskUtils.matchBlock(this, pendingTask, block, player.getUniqueId())) {
+ super.debug("Continuing...", quest.getId(), task.getId(), player.getUniqueId());
+ continue;
}
int progress = TaskUtils.incrementIntegerTaskProgress(taskProgress);
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/TaskUtils.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/TaskUtils.java
index 21aacd95..001addca 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/TaskUtils.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/TaskUtils.java
@@ -199,13 +199,12 @@ public class TaskUtils {
}
material = Material.getMaterial(String.valueOf(split[0]));
- Material blockType = block.getType();
- short blockData = block.getData();
type.debug("Checking against block " + material, pendingTask.quest.getId(), task.getId(), player);
- if (blockType == material) {
+ if (block != null && block.getType() == material) {
+ short blockData = block.getData();
if (((split.length == 1 && configData == null) || ((int) blockData) == comparableData)) {
type.debug("Block match", pendingTask.quest.getId(), task.getId(), player);
return true;