Prevent brew result drag, fixes #2203

This commit is contained in:
PikaMug 2024-05-10 01:24:04 -04:00
parent d0c1f92acf
commit 74a3d093fa

View File

@ -22,6 +22,7 @@ import org.bukkit.event.enchantment.EnchantItemEvent;
import org.bukkit.event.inventory.CraftItemEvent; import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.inventory.InventoryType.SlotType; import org.bukkit.event.inventory.InventoryType.SlotType;
import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.event.player.PlayerItemConsumeEvent;
@ -162,6 +163,25 @@ public class BukkitItemListener implements Listener {
} }
} }
@EventHandler
public void onInventoryDrag(final InventoryDragEvent event) {
if (event.isCancelled()) {
return;
}
if (event.getWhoClicked() instanceof Player) {
if (event.getInventory().getType() == InventoryType.BREWING) {
final Quester quester = plugin.getQuester(event.getWhoClicked().getUniqueId());
for (final Quest quest : plugin.getLoadedQuests()) {
if (quester.getCurrentQuests().containsKey(quest)
&& quester.getCurrentStage(quest).containsObjective(ObjectiveType.BREW_ITEM)) {
event.setCancelled(true);
return;
}
}
}
}
}
public boolean isAllowedBrewingAction(final InventoryClickEvent event) { public boolean isAllowedBrewingAction(final InventoryClickEvent event) {
if (event.getCursor() != null && isWaterBottle(event.getCursor())) { if (event.getCursor() != null && isWaterBottle(event.getCursor())) {
return true; return true;