Creating a dummy inventory

Discussion in 'Plugin Development' started by Limeth, May 16, 2013.

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


    Hi, my goal is to create something like 5x5 FTB project table (Crafting table, which saves it's content). I'm saving objects "CraftingTable", holding it's own inventory, in a public list and looping through them and checking, if the CraftingTable's inventory is the same as the InventoryClickEvent's. The problem is, they don't equal, even when they should.
    1. public Inventory inv;
    3. public void init() {
    4. Player player = Bukkit.getPlayer("Limeth");
    5. inv = Bukkit.createInventory(null, 45, "Crafting Table");
    6. player.openInventory(inv);
    7. }
    9. EventHandler
    10. public void invClick(InventoryClickEvent event) { //A click in the "Crafting Table" inventory...
    11. if(!event.getPlayer().getName().equals("Limeth")) return;
    12. boolean result = event.getInventory().equals(inv); //The result is getting set to false. No idea why.
    13. }
  2. Offline


    Sadly, .equals() isn't currently supported by Inventory objects. There is a PR for this, however; see

    For now, the best you can do is compare the inventory titles ("Crafting Table" in your case), and perhaps verifying that the player who made the click (event.getWhoClicked()) is actually one of the players currently viewing your special inventory.
    Limeth likes this.
Thread Status:
Not open for further replies.

Share This Page