Solved Inventory Issues!

Discussion in 'Plugin Development' started by CONTREKEE, Mar 3, 2015.

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

    CONTREKEE

    I need advice on how to fix this issue! When I type a command(/blah blah), it opens an inventory with items you can click to do difference functions. So, if there are at least two people who type that command, the first person who typed it can now take the items out of the inventory, and it has no functionality. Please help, and thank you very much!


    Here is the code :

    Code:
    inv = Bukkit.getServer().createInventory(player, 9, ChatColor.BLUE + bold + "Tools");
    
    
    
        @EventHandler
        public void Inv(InventoryClickEvent e) {
         
            Player player = (Player) e.getWhoClicked();
         
            if(e.getInventory().equals(inv)) {
                e.setCancelled(true);
                player.closeInventory();
                return;
            }
         
        }
     
        @EventHandler
        public void Craft(InventoryClickEvent e) {
         
            Player player = (Player) e.getWhoClicked();
         
            if(e.getInventory().equals(inv)) {
                e.setCancelled(true);
                player.closeInventory();
                 
                    if (e.getCurrentItem() != null && !e.getCurrentItem().getType().equals(Material.AIR)){
                     
                        if(e.getCurrentItem().getType() == Material.WORKBENCH) {
                            player.openWorkbench(player.getLocation(), true);
                            return;
                        }else if(e.getCurrentItem().getType() == Material.ENCHANTMENT_TABLE) {
                            player.openEnchanting(player.getLocation(), true);
                            return;
                         
                 
                        }
                 
                        }
                 
            }
         
        }
     
    Last edited: Mar 4, 2015
  2. Offline

    Cycryl

    maybe try to set the inventoryowner to null instead of player
    @CONTREKEE
     
  3. Offline

    CONTREKEE

    Yeah, I accidentally put it in the middle and it messed up. lol @MaTaMoR_
     
Thread Status:
Not open for further replies.

Share This Page