1.12.2 I need help for solving the error for Inventory

Discussion in 'Spigot Plugin Development' started by noob_joey, Feb 17, 2020.

Thread Status:
Not open for further replies.
  1. Here is the event. Btw, for the sign, just to prevent from messing up with the sign listener.
    Code (Text):
        @EventHandler

        public void OnClick(PlayerInteractEvent e) {
            if (!(e.getAction() == Action.RIGHT_CLICK_BLOCK)) return;
            Player player = e.getPlayer();
            if (!(player.getItemInHand().getType().equals(Material.NAME_TAG))) return;
            Block cb = e.getClickedBlock();
            BlockState state = cb.getState();
            if (state instanceof Sign) return;
            else {
                if (player.getItemInHand().getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.LIGHT_PURPLE + "Pass")) {
                    IvnCardInfo(player);
                }
            }
        }
     
    Here is the inventory.
    Code (Text):
        public void IvnCardInfo(Player player){
            Inventory ivn = plugin.getServer().createInventory(null, 9, ChatColor.DARK_GREEN + "Pass Info");

            ItemStack empty = new ItemStack(Material.GLASS_PANE, 1,(byte)1);
            ItemMeta emptyMeta = empty.getItemMeta();
            emptyMeta.setDisplayName("-");
            empty.setItemMeta(emptyMeta);

            ItemStack bal = new ItemStack(Material.DIAMOND_BLOCK, 1);
            ItemMeta balMeta = bal.getItemMeta();
            balMeta.setDisplayName("Balance: " + getPlayerBalance(player));
            bal.setItemMeta(balMeta);


            ItemStack close = new ItemStack(Material.REDSTONE_BLOCK, 1);
            ItemMeta closeMeta = bal.getItemMeta();
            closeMeta.setDisplayName(ChatColor.RED + "Close");
            close.setItemMeta(closeMeta);


            ItemStack ID = new ItemStack(Material.NAME_TAG, 1);
            ItemMeta IDMeta = bal.getItemMeta();
            IDMeta.setDisplayName("ID: " + getPlayerid(player));
            ID.setItemMeta(IDMeta);

            ivn.setItem(0,bal);
            ivn.setItem(1,empty);
            ivn.setItem(2,empty);
            ivn.setItem(3,empty);
            ivn.setItem(4,empty);
            ivn.setItem(5,empty);
            ivn.setItem(6,empty);
            ivn.setItem(7,empty);
            ivn.setItem(8,close);

            player.openInventory(ivn);
        }
     
    Anyway, I registered event already
    Code (Text):
            this.getServer().getPluginManager().registerEvents(new InvCardInfo(), this);
     
    And here is the error when I am trying to open the inventory.
    Code (Text):
    [23:42:47 ERROR]: Could not pass event PlayerInteractEvent to SmartRider v1.0
    org.bukkit.event.EventException: null
    Sorry if I am asking a bad question but please help.
     
  2. Can you give us the full error?
     
  3. opps forgto to use code to quote
     
  4. You seem to be using the incorrect Spigot in your project or on your server
     
  5. [00:14:04 INFO]: This server is running CraftBukkit version git-Spigot-dcd1643-e60fc34 (MC: 1.12.2) (Implementing API version 1.12.2-R0.1-SNAPSHOT)
     
  6. Are you checking if the player clicks outside of the inventory and returning if they do?
     
Thread Status:
Not open for further replies.