From 85d0f035a6790c70bfc0282eab4d88e4a985345d Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Thu, 4 May 2023 23:04:11 -0400 Subject: [PATCH] Ignore placing of Water Bottle, see #2096 --- .../quests/listeners/ItemListener.java | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/me/blackvein/quests/listeners/ItemListener.java b/core/src/main/java/me/blackvein/quests/listeners/ItemListener.java index fb7eb81ad..da92c0bc0 100644 --- a/core/src/main/java/me/blackvein/quests/listeners/ItemListener.java +++ b/core/src/main/java/me/blackvein/quests/listeners/ItemListener.java @@ -12,10 +12,10 @@ package me.blackvein.quests.listeners; -import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.player.IQuester; import me.blackvein.quests.Quests; import me.blackvein.quests.enums.ObjectiveType; +import me.blackvein.quests.player.IQuester; +import me.blackvein.quests.quests.IQuest; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -28,6 +28,8 @@ import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType.SlotType; import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; +import org.bukkit.potion.PotionType; import java.util.HashSet; import java.util.Set; @@ -163,7 +165,7 @@ public class ItemListener implements Listener { } public boolean isAllowedBrewingAction(final InventoryClickEvent event) { - if (event.getCursor() != null && event.getCursor().getType().equals(Material.GLASS_BOTTLE)) { + if (event.getCursor() != null && isWaterBottle(event.getCursor())) { return true; } final int slot = event.getRawSlot(); @@ -183,6 +185,22 @@ public class ItemListener implements Listener { } return true; } + + public boolean isWaterBottle(ItemStack item) { + if (item == null) { + return false; + } + if (item.getType().equals(Material.POTION)) { + PotionMeta meta = (PotionMeta) item.getItemMeta(); + if (meta == null) { + return false; + } + if (meta.getBasePotionData().getType().equals(PotionType.WATER)) { + return true; + } + } + return false; + } @EventHandler public void onEnchantItem(final EnchantItemEvent event) {