Solved Compass gui opening for every block!

Discussion in 'Spigot Plugin Development' started by MGPro, Nov 16, 2017.

  1. Hello,
    I have this plugin its a hub plugin so it has a compass and i am currently adding a ender butt and player visibility, But i have a problem with the compass. So when i right click the compass it opens the gui but if i right click the enderbutt or player visibility it opens the compass gui while doing the the player vanish or the pearl. It also works with just a normal block. I just put a block in the hotbar and right click it. It opens the gui.
    Please help thanks!

    Code (Text):
        @EventHandler(priority = EventPriority.HIGHEST)
        public void onInteract(PlayerInteractEvent event) {
            Player player = event.getPlayer();
            if (event.getItem() != null && event.getItem().getType() == Material.COMPASS
                    && event.getAction().equals(Action.RIGHT_CLICK_BLOCK)
                    || event.getAction().equals(Action.RIGHT_CLICK_AIR)) {
                openInventory(player, Hub.getInstance().selector);
  2. You're missing parentheses. Fixed:
    Code (Text):

            if (event.getItem() != null && event.getItem().getType() == Material.COMPASS
                    && (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)
                    || event.getAction().equals(Action.RIGHT_CLICK_AIR)))
    • Useful Useful x 1
  3. @Fluglow Thank you so much. Im so dumb i missed that!
    • Funny Funny x 1