Solved Force user to open THEIR Inventory?

Discussion in 'Plugin Development' started by ccrama, Apr 6, 2014.

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

    ccrama

    Hello Bukkit.
    I'm trying to create an inventory GUI like so:

    [​IMG]
    (just threw that together)

    and I have all the items correctly added to an inventory, but the InventoryType.PLAYER is just a double chest inventory. Is there a way to force a user to open THEIR inventory ( like shown above ), or is there an inventorytype for this type of inventory?

    Thanks for the help,
    ccrama
     
  2. Offline

    Retherz_

    Have you tried player.openInventory(player.getInventory()); ?
     
  3. Offline

    ccrama

    That returns a double chest with the users inventory content inside ( I'm trying to make it show their inventory items and layout).
     
  4. Offline

    SainttX

    I think the only way to accomplish this would be through packets. I've been looking around for the packet but haven't been successful in getting the inventory open. I could get every other window (crafting, anvil, enchantment table, beacon, villager trade, etc) open, but not the inventory window.

    Here's the code if you wish to play with it
    Code:java
    1. Player p = ...;
    2. PacketPlayOutOpenWindow openInventory = new PacketPlayOutOpenWindow(int ?, int inventoryType, String inventoryName, int numInventorySlots, boolean ?);
    3. ((CraftPlayer) p).getHandle().playerConnection.sendPacket(openInventory);

    For the ones with question marks I didn't see any difference when changing around the values. The numInventorySlots should be a multiple of 9 I believe. Good luck!
     
  5. Offline

    ccrama

    SainttX sorry for the late reply. This method crashes the client and disconnects them from the server with an internal connection error. Eclipse doesn't like all those parameters after PacketPlayOutOpenWindow either :(. I think I'll just tell the user in a message or something to open up their inventory.

    Thanks again!
     
Thread Status:
Not open for further replies.

Share This Page