Try specified break durability for crops if greater than 0, fixes #1213

This commit is contained in:
PikaMug 2020-04-17 05:43:02 -04:00
parent 4523067f35
commit 0f333341da

View File

@ -50,6 +50,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.Crops;
import com.alessiodp.parties.api.interfaces.Party; import com.alessiodp.parties.api.interfaces.Party;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
@ -1261,7 +1262,6 @@ public class Quester {
for (ItemStack is : getQuestData(quest).blocksBroken) { for (ItemStack is : getQuestData(quest).blocksBroken) {
if (m.getType() == is.getType()) { if (m.getType() == is.getType()) {
if (m.getType().isSolid() && is.getType().isSolid()) { if (m.getType().isSolid() && is.getType().isSolid()) {
//Blocks are solid so check for durability //Blocks are solid so check for durability
if (m.getDurability() == is.getDurability()) { if (m.getDurability() == is.getDurability()) {
broken = is; broken = is;
@ -1269,6 +1269,16 @@ public class Quester {
//Ignore durability for 1.13+ //Ignore durability for 1.13+
broken = is; 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 { } else {
//Blocks are not solid so ignore durability //Blocks are not solid so ignore durability
broken = is; broken = is;
@ -1278,7 +1288,6 @@ public class Quester {
for (ItemStack is : getCurrentStage(quest).blocksToBreak) { for (ItemStack is : getCurrentStage(quest).blocksToBreak) {
if (m.getType() == is.getType()) { if (m.getType() == is.getType()) {
if (m.getType().isSolid() && is.getType().isSolid()) { if (m.getType().isSolid() && is.getType().isSolid()) {
//Blocks are solid so check for durability //Blocks are solid so check for durability
if (m.getDurability() == is.getDurability()) { if (m.getDurability() == is.getDurability()) {
toBreak = is; toBreak = is;
@ -1286,9 +1295,19 @@ public class Quester {
//Ignore durability for 1.13+ //Ignore durability for 1.13+
toBreak = is; 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 { } else {
//Blocks are not solid so ignore durability //Blocks are not solid so ignore durability
toBreak = is; broken = is;
} }
} }
} }