From 552f9a5611d24889f6d064eabc44c986935cc4b3 Mon Sep 17 00:00:00 2001 From: Indyuce Date: Thu, 9 Apr 2020 18:02:02 +0200 Subject: [PATCH] Added quest mineblock support for custom mining --- .../api/quest/objective/MineBlockObjective.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/Indyuce/mmocore/api/quest/objective/MineBlockObjective.java b/src/main/java/net/Indyuce/mmocore/api/quest/objective/MineBlockObjective.java index 6d0cbf81..86d68b32 100644 --- a/src/main/java/net/Indyuce/mmocore/api/quest/objective/MineBlockObjective.java +++ b/src/main/java/net/Indyuce/mmocore/api/quest/objective/MineBlockObjective.java @@ -7,6 +7,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; +import net.Indyuce.mmocore.api.event.CustomBlockMineEvent; import net.Indyuce.mmocore.api.quest.ObjectiveProgress; import net.Indyuce.mmocore.api.quest.QuestProgress; import net.mmogroup.mmolib.api.MMOLineConfig; @@ -36,9 +37,19 @@ public class MineBlockObjective extends Objective { super(questProgress, objective); } - @EventHandler(priority = EventPriority.HIGH) + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void a(BlockBreakEvent event) { - if (!event.isCancelled() && event.getPlayer().equals(getQuestProgress().getPlayer().getPlayer()) && event.getBlock().getType() == block) { + if (event.getPlayer().equals(getQuestProgress().getPlayer().getPlayer()) && event.getBlock().getType() == block) { + count++; + getQuestProgress().getPlayer().getQuestData().updateBossBar(); + if (count >= required) + getQuestProgress().completeObjective(); + } + } + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void b(CustomBlockMineEvent event) { + if (event.getPlayer().equals(getQuestProgress().getPlayer().getPlayer()) && event.getBlock().getType() == block) { count++; getQuestProgress().getPlayer().getQuestData().updateBossBar(); if (count >= required)