From 0f333341da4800297bb85c7d8ac52ee6982eb506 Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Fri, 17 Apr 2020 05:43:02 -0400 Subject: [PATCH] Try specified break durability for crops if greater than 0, fixes #1213 --- .../java/me/blackvein/quests/Quester.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/main/src/main/java/me/blackvein/quests/Quester.java b/main/src/main/java/me/blackvein/quests/Quester.java index 8a8dd0626..b96f29694 100644 --- a/main/src/main/java/me/blackvein/quests/Quester.java +++ b/main/src/main/java/me/blackvein/quests/Quester.java @@ -50,6 +50,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.material.Crops; import com.alessiodp.parties.api.interfaces.Party; import com.gmail.nossr50.datatypes.skills.SkillType; @@ -1261,7 +1262,6 @@ public class Quester { for (ItemStack is : getQuestData(quest).blocksBroken) { if (m.getType() == is.getType()) { if (m.getType().isSolid() && is.getType().isSolid()) { - //Blocks are solid so check for durability if (m.getDurability() == is.getDurability()) { broken = is; @@ -1269,6 +1269,16 @@ public class Quester { //Ignore durability for 1.13+ broken = is; } + } else if (m.getData() instanceof Crops && is.getData() instanceof Crops) { + if (is.getDurability() > 0) { + // Age is specified so check for durability + if (m.getDurability() == is.getDurability()) { + broken = is; + } + } else { + // Age is unspecified so ignore durability + broken = is; + } } else { //Blocks are not solid so ignore durability broken = is; @@ -1278,7 +1288,6 @@ public class Quester { for (ItemStack is : getCurrentStage(quest).blocksToBreak) { if (m.getType() == is.getType()) { if (m.getType().isSolid() && is.getType().isSolid()) { - //Blocks are solid so check for durability if (m.getDurability() == is.getDurability()) { toBreak = is; @@ -1286,9 +1295,19 @@ public class Quester { //Ignore durability for 1.13+ toBreak = is; } + } else if (m.getData() instanceof Crops && is.getData() instanceof Crops) { + if (is.getDurability() > 0) { + // Age is specified so check for durability + if (m.getDurability() == is.getDurability()) { + broken = is; + } + } else { + // Age is unspecified so ignore durability + broken = is; + } } else { //Blocks are not solid so ignore durability - toBreak = is; + broken = is; } } }