Why does the GUI not open?

Discussion in 'Spigot Plugin Development' started by danielm175, Apr 19, 2017.

  1. Here is my code i dont understand why when i click AIR it doesnt open the GUI

    Here is my code

    Code (Text):
        public void onInt(PlayerInteractEvent e) {
        if(e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR) {
            ItemStack heald = new ItemStack(Material.POTION);
            ItemMeta meta = heald.getItemMeta();
            meta.setDisplayName(ChatColor.AQUA + "Testers");
            ItemStack feed = new ItemStack(Material.FEATHER);
            ItemMeta feedmeta = feed.getItemMeta();
            feedmeta.setDisplayName(ChatColor.AQUA + "FeedMeta");
            Inventory inv = Bukkit.createInventory(null, 27, ChatColor.GREEN + "Heal And Feed");
            inv.setItem(2, heald);
            inv.setItem(6, feed);
  2. Error Message?

    //EDIT: Event registered?
  3. whats the code to register the event?
  4. Do you perform a left or right click ingame?
  5. Bukkit.getPluginManager.registerEvents(new YourClass(), classInstance);
    • Agree Agree x 1
  6. If nothing is in your hand when checking for a right click air nothing would happen
  7. Eh what? The Action is still applied to the right click at the air ( block ) so the items in hand are not necessary
  8. No from what I know, let's say you have the event checking for a right click in the air it wouldn't do anything unless you an item in your hand. It works for left click air tho. As for clicking blocks the right click block check should be true and run the code
    • Agree Agree x 1
  9. @danielm175 @Phloxz

    Basically the minecraft client doesn't send a player interact packet when you right-click in the air with nothing in your hand. There's unfortunately nothing you can do about it.
  10. Lol ok checked that, you are right
  11. Do you registerevents on Enable ?