Skip to content

Commit

Permalink
Improve brewing stand player detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Krakenied committed May 26, 2023
1 parent 189414e commit 4d19504
Showing 1 changed file with 15 additions and 7 deletions.
Expand Up @@ -12,13 +12,14 @@
import com.leonardobishop.quests.common.quest.Task;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.BrewEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.inventory.BrewerInventory;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;

import java.util.HashMap;
Expand Down Expand Up @@ -46,12 +47,19 @@ public void onReady() {
fixedQuestItemCache.clear();
}

@SuppressWarnings("ConstantConditions")
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.BREWING_STAND) {
brewingStands.put(event.getClickedBlock().getLocation(), event.getPlayer().getUniqueId());
public void onInventoryOpen(InventoryOpenEvent event) {
final Inventory inventory = event.getInventory();
if (!(inventory instanceof BrewerInventory)) {
return;
}

final InventoryHolder holder = inventory.getHolder();
if (holder == null) {
return;
}

brewingStands.put(inventory.getLocation(), event.getPlayer().getUniqueId());
}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
Expand Down

0 comments on commit 4d19504

Please sign in to comment.