Player crafting inventory problem

Discussion in 'Plugin Development' started by bensku, Aug 11, 2014.

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


    1. HumanEntity clicker = event.getWhoClicked();
    2. InventoryView invView = clicker.getOpenInventory();
    3. CraftingInventory inv = (CraftingInventory) invView.getTopInventory();
    4. inv.setResult(result); //result is defined earlier in my code
    5. clicker.openInventory(inv);

    That code should do very simple things:
    1. Get clicker from InventoryClickEvent
    2. Get clicker's inventoryview
    3. (Not in that code, but) check is the click happened in crafting inventory
    4. Put one item to result slot of inventory
    5. Open new crafting inventory to clicker

    It currently does steps 1-4. I have done some debugging, so I know:
    • Event is triggered
    • Clicker is me
    • Doing ((Player) clicker).updateInventory() won't help anything
    • Doing clicker.closeInventory() before opening new one won't help
    • Player actually haves that item in crafting result slot (Bukkit.getLogger().info("Debug: result is " + ((CraftingInventory) clicker.getOpenInventory().getTopInventory()).getResult());
      • That returns the correct item
    So what I should do? I simply don't see any item in result slot, but its there... Is it bug or am I blind? :D
  2. Offline


    I'm just guessing - maybe you need to get the name of the clicker then get the player another way?
  3. Offline


    Try closing clickers inv with Player.closeInventory(), before step 5
Thread Status:
Not open for further replies.

Share This Page