Need help with inventories

Discussion in 'Plugin Development' started by DEYMONTV, Jan 6, 2020.

Thread Status:
Not open for further replies.
  1. Offline


    Hi, I'm actually trying to make a plugin to watch others player's inventory with a stick but players can't take from the inventory. But when I try to created an inventory with the target's items in, its returning me an error. Because I need to put a name to the inventory so I can set it in the InventoryClickEvent.

        public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
            Player player = event.getPlayer();
            ItemStack it = event.getPlayer().getInventory().getItemInMainHand();
            if(it == null) return;
            if(it.getType() == Material.STICK && it.getItemMeta().hasDisplayName() && it.getItemMeta().getDisplayName().equalsIgnoreCase("§6Frisk")) {
                if(event.getRightClicked() instanceof Player){
                    Player target = plugin.getServer().getPlayer(event.getRightClicked().getName());
                    Inventory targetInv = Bukkit.createInventory(null, 34, "§6Frisk");
        public void onClick(InventoryClickEvent event) {
            Inventory inv = event.getInventory();
            Player player = (Player) event.getWhoClicked();
            if(inv.getName().equalsIgnoreCase("§6Frisk")) {
    I've done this but its not working :( Can someone help me please ?
  2. Offline


    "its not working" is a useless error description. What doesn't work? Nothing happens? If so, put System.out.println all over the place. If there are any errors in console, show them.
  3. Offline


    This line should throw an error because 34 isn't a multiple of 9, i'd recommend doing something like this:
    1. Bukkit.createInventory(null, 9 * rows, "§6Frisk")

    That way you can't go wrong with the multiple of 9 thing. (An inventory can have 1 to 6 rows, just in case you didn't know)
Thread Status:
Not open for further replies.

Share This Page