Inventory

Discussion in 'Plugin Development' started by ProStriker123, Feb 17, 2015.

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

    ProStriker123

    Waddup.
    How can i return my method if the players is already inside the inventory.
    Thanks!
     
  2. Offline

    Twistt

    Could you maybe go into more detail on what you mean?
     
  3. Offline

    WinX64

    Not sure if you mean this, but you want to check if the player is viewing a certain inventory, right?
    If you have the inventory object, you can call Inventory#getViewers, it will return a list of players viewing the inventory.
    If you have the player object, you can call Player#getOpenInventory, which will return the players' current open inventory.
     
    ProStriker123 likes this.
  4. Offline

    ProStriker123

    @Twistt, I want if the players is already inside an inventory its wont open him again.

    @WinX64, Its noy working or maybe i did it worngly maybe can you send me example?
    Thanks!
     
  5. Offline

    I'm Osama

    @ProStriker123 Its impossible to not allow players to open their inventories
     
  6. Offline

    WinX64

    Can you show what you actually did?
     
    ProStriker123 likes this.
  7. Offline

    ProStriker123

    @WinX64,
    Yup
    if(p.getOpenInventory() != null) {
    return;
    }
     
  8. Offline

    WinX64

    That doesn't work, this method will never return null, if the player has no inventory opened, it will return the default player's inventory.
     
    ProStriker123 likes this.
  9. Offline

    ProStriker123

    @WinX64, How to do then? #getTitle()?

    @I'm Osama, No i have created my own inventory and i want from it to not re-open it.
    @WinX64

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 13, 2016
  10. Offline

    WinX64

    Could you explain in details what exactly are you trying to do, where and when?
     
    ProStriker123 likes this.
  11. Offline

    ProStriker123

    I created my own Kit Selector GUI and when admin does /openkit <Playername> its opens him a kit Selector then i want when hes inventory named "Kits" already open its wont reopen by that command /openkit
    @WinX64
     
  12. Offline

    SuperOriginal

    @ProStriker123 Then don't open the GUI if they have already used it..
     
    ProStriker123 likes this.
  13. Offline

    ProStriker123

    @SuperOriginal, If the admin dosent know that he use it?. So i realy need it sur
     
  14. Offline

    I'm Osama

    @ProStriker123 then you can simply put everyone who opened it in a list, and then check if they already opened the menu.

    eg. A method I created for this
    Code:
    ArrayList<String> openedKitMenu = new ArrayList<String>();
    
        private void openKitMenu(Player p, Inventory inv, ArrayList<String> list) {
            if(inv.getTitle().equalsIgnoreCase("Kits")) {
                if(!list.contains(p.getName())) {
                    p.openInventory(inv);
                    openedKitMenu.add(p.getName());
                }else{
                    p.sendMessage(ChatColor.RED + "You have already used the kit menu!");
                }
            }
        }
    [/code]
     
    Last edited: Feb 18, 2015
Thread Status:
Not open for further replies.

Share This Page