Solved How to get the 'top' inventory?

Discussion in 'Plugin Development' started by PunditPoe, Apr 2, 2016.

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

    PunditPoe

    I'm making a trading Plugin, so, when one player requests trading and the other player accepts it opens a 'top inventory' to them both.

    That inventory that opens is like a Chest inventory. Its a 36 slots inventory that apeears above the players inventory.

    Like this:
    Captura de tela 2016-04-02 16.40.57.png

    The thing is, when the player A clicks on the Emerald Block I want that the Stone Block of player B's inventory change to a Emerald Block, like saying that the player accepts to trade the items that were placed.

    But I can't get the player B inventory to use 'setItem(...);' to set a Emerald Block.

    I get the event of player A clicking on the Emerald Block and then what I tried to do was something like:
    Code:
    playerB.getInventory().remove(index);
    playerB.getInventory().setItem(index, new ItemStack(Material.EMERALD_BLOCK));
    But it doesn't get player B's top inventory, it gets the container inventory (the normal one).
     
    Last edited: Apr 2, 2016
  2. Offline

    xaanit

    You'll have to save the target as a Player, and when one clicks the emerald block, save each inventory, close the current users inventories, and open them again. It's possible there's a cleaner way to do it, but that's how I would.
     
  3. Offline

    Suppressing

    Instead of setting them item in playerB.getInventory(), use the inventory name.
     
  4. Offline

    PunditPoe

Thread Status:
Not open for further replies.

Share This Page