Connect Inventories not working

Discussion in 'Plugin Development' started by FireBreath14, Aug 15, 2013.

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

    FireBreath14

    Hello,

    I am trying to make a plugin where when one player opens their inventory, they are actually opening another player's. What I mean is, when player A presses the button to open his inventory, the plugin cancels that and instead has player A open player B's inventory. I rather not use a command to do this, I'd like it done like I described.

    I am using InventoryOpenEvent and for some reason when player A opens his inventory, nothing happens! If someone could give me a good working example of how the code should look, I'd appreciate it!
     
  2. Offline

    CaptainBern Retired Staff

    FireBreath14 You have to use playerA.openInventory(playerB.getInventory());
     
    AndyAndreiH likes this.
  3. Offline

    FireBreath14

  4. Offline

    Door Knob

  5. Offline

    FireBreath14

    Door Knob Its not. I cancel the event where player A's inventory is open, and then i use

    Code:
    playerA.openInventory(playerB.getInventory());
    maybe it's the wrong event? I highly doubt that but maybe im overlooknig something
     
  6. Offline

    Door Knob

    Okay, well what's going wrong currently? Is the inventory not opening? Is the normal inventory opening?
    I believe the event would be something like InventoryOpenEvent, let me look it up...

    yeah, that's it. Try InventoryOpenEvent.
     
  7. Offline

    FireBreath14

    Yeah thats what im doing. Let me update craftbukkit and get back to you. What was happening is that the normal inventory was opening :I

    heres the code that is FAILING ME lol

    Code:
    @EventHandler
    public void onIOpen(InventoryOpenEvent e){
    if(plugin.getConfig().contains(e.getPlayer.getName()){
      e.setCancelled(true);
      e.getPlayer.openInventory(<a player on the server>);
    }
    }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  8. Offline

    CaptainBern Retired Staff

  9. Offline

    FireBreath14

Thread Status:
Not open for further replies.

Share This Page