Solved Opening inventory from another

Discussion in 'Plugin Development' started by UnAnswereed, Oct 30, 2017.

Thread Status:
Not open for further replies.
  1. Hey guys!
    My goal is to make a inventory menu plugin, with submenus.
    I'm okay with the basics, and I can do inventories, and the main menu is done, but i can't open the submenus.
    Is there any specific way to open a custom inventory from another?
     
  2. Offline

    timtower Administrator Administrator Moderator

    @UnAnswereed Close the old one, open the other one a tick later.
     
  3. @timtower I did that, but it's just closing the inventory and don't happen anything else.
     
  4. Offline

    timtower Administrator Administrator Moderator

  5. That's it. The codes are in different java file. I didn't posted the ItemStack beacuse of the length.

    Code:
    public static void diamondShop(Player p) {
            Inventory invt = Bukkit.createInventory(p, 36, EventInfo.prefix + "§bDiamond Items");
            invt.setItem(24, j);
            p.openInventory(invt);
        }
    Code:
        @EventHandler
        public void onInvClick(InventoryClickEvent e) {
            Player p = (Player) e.getWhoClicked();
            if (e.getInventory().getTitle().equalsIgnoreCase(Main.EventInfo.prefix + "§5Shop")) {
                if (e.getCurrentItem().getType() == Material.DIAMOND) {
                    p.closeInventory();
                    Main.diamondShop(p);
                }
            }
        }
    
     
  6. Offline

    timtower Administrator Administrator Moderator

  7. @timtower

    Then should I use it like that?
    Code:
    final Player p = (Player) e.getWhoClicked();
    if (e.getCurrentItem().getType() == Material.DIAMOND) {
                    p.closeInventory();
                    Bukkit.getServer().getScheduler().runTaskLater((Plugin) Main.plugin, new Runnable(){
                          public void run(){
                            Main.diamondShop(p);
                          }
                        },1);
                }
    
     
  8. Offline

    timtower Administrator Administrator Moderator

  9. @timtower I tried but nothing, just the same
     
Thread Status:
Not open for further replies.

Share This Page