I would like to ask if the player has the compass in his hand and if so the inventory should open Does not work. Please help translated by Google Code: package de.boulyt.lobby.listeners;import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.Inventory; public class NavigatorListener implements Listener { @EventHandler public void ballFiring(PlayerInteractEvent event) { Player player = event.getPlayer(); Action a = event.getAction(); if ((a == Action.PHYSICAL) || (event.getItem() == null) || (event.getItem().getType() == Material.COMPASS)) { Inventory inventory = Bukkit.createInventory(null, InventoryType.BREWING, "§aNavigator"); player.openInventory(inventory); } } }
You should add this line to prevent your event to be called twice, maybe that should help if (event.getHand().equals(EquipmentSlot.HAND)) { } Try to add System.out.println("") something to see if your event is called too
The action is only physical if you're interacting with pressure plates, tripwire hooks, etc. Instead, check if it's Action.RIGHT_CLICK_BLOCK or Action.RIGHT_CLICK_AIR