Solved Added Another Plugin of I Created and Now Inventories Won't Open

Discussion in 'Plugin Development' started by oriamrm, Aug 29, 2017.

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

    oriamrm

    Waddupppp?!
    So I Had a long break from programming, and now that I got back I am trying to make 2 plugins I created work together. I changed all of the basic stuff and it works totally fine, but then I noticed that I can't open any inventories for the player from one Plugin (We'll call it plugin 1 :)). It worked just fine before I added the other one (We'll call it plugin 2). and even when I remove plugin 2 I can open inventories in plugin 1 (BTW I can open inventories in plugin 2, and it seems like overall plugin 2 is getting priority).

    I have no idea what is causing this problem or what code to post, but can I get some help here?
    Method that opens the Inventory:
    Code:
    public static Inventory defaultInv(String paneName, String playerName){
            PlayerData pd = new PlayerData(playerName);
            Inventory SFinv = Bukkit.createInventory(null, 54, "Smart Phone");
          
            ItemStack pane = new ItemStack(Material.STAINED_GLASS_PANE);
            pane.setDurability(pd.getTheme());
            ItemMeta paneM = pane.getItemMeta();
            paneM.setDisplayName(ChatColor.GREEN + paneName);
            pane.setItemMeta(paneM);
            for(int slot = 0; slot < 9; slot++){
                SFinv.setItem(slot, pane);
            }
          
            for(int slot = 45; slot <= 53; slot++){
                SFinv.setItem(slot, pane);
            }
          
            ItemStack back = new ItemStack(Material.ARROW);
            ItemMeta backM = back.getItemMeta();
            backM.setDisplayName(ChatColor.GREEN + "Back");
            back.setItemMeta(backM);
            SFinv.setItem(49, back);
          
            return SFinv;
        }
        public static void openPhone(Player player){
            PlayerData pd = new PlayerData(player.getName());
            Inventory SFinv = Bukkit.createInventory(null, 54, "Smart Phone");
                  
            int appSlot = 11;
            ItemStack pane = new ItemStack(Material.STAINED_GLASS_PANE);
            pane.setDurability(pd.getTheme());
            ItemMeta paneM = pane.getItemMeta();
            paneM.setDisplayName(ChatColor.GREEN + "Smart Phone");
            pane.setItemMeta(paneM);
    
            for(int slot = 0; slot < 9; slot++){
                SFinv.setItem(slot, pane);
            }
            for(int slot = 9; slot <= 51; slot = slot + 8){
                if(slot % 9 == 8){
                    SFinv.setItem(slot, pane);
                    slot = slot + 1;
                }
                SFinv.setItem(slot, pane);
            }
            for(int slot = 45; slot <= 53; slot++){
                SFinv.setItem(slot, pane);
            }
    
            ItemStack PM = new ItemStack(Material.DARK_OAK_DOOR_ITEM);
            ItemMeta PMM = PM.getItemMeta();
            PMM.setDisplayName("" + ChatColor.GREEN + ChatColor.BOLD + "Property Management");
            PM.setItemMeta(PMM);
          
            ItemStack apps = new ItemStack(Material.EMERALD);
            List<String> appsLore = new ArrayList<String>();
            appsLore.add(ChatColor.RED + "Coming Soon!");
            ItemMeta appsM = apps.getItemMeta();
            appsM.setDisplayName("" + ChatColor.GREEN + ChatColor.BOLD + "Download Apps");
            appsM.setLore(appsLore);
            apps.setItemMeta(appsM);
          
            ItemStack inbox = new ItemStack(Material.JUKEBOX);
            ItemMeta inboxM = inbox.getItemMeta();
            inboxM.setDisplayName("" + ChatColor.GREEN + ChatColor.BOLD + "Mail");
            inbox.setItemMeta(inboxM);
          
            ItemStack options = new ItemStack(Material.REDSTONE_COMPARATOR);
            ItemMeta optionsM = options.getItemMeta();
            optionsM.setDisplayName("" + ChatColor.GREEN + ChatColor.BOLD + "Settings");
            options.setItemMeta(optionsM);
          
            ItemStack SM = new ItemStack(Material.DIAMOND);
            ItemMeta SMM = SM.getItemMeta();
            SMM.setDisplayName("" + ChatColor.GREEN + ChatColor.BOLD + "Shop Management");
            SM.setItemMeta(SMM);
    
            ItemStack resign = new ItemStack(Material.BARRIER);
            ItemMeta resignM = resign.getItemMeta();
            resignM.setDisplayName("" + ChatColor.GREEN + ChatColor.BOLD + "Resign");
            resign.setItemMeta(resignM);
          
            if(!pd.getAllProp().isEmpty()){
                SFinv.setItem(appSlot, PM);
                appSlot++;
            }
            if(pd.hasShop()){
                SFinv.setItem(appSlot, SM);
                appSlot++;
            }
            if(pd.isEmployed()){
                SFinv.setItem(appSlot, resign);
                appSlot++;
            }
            SFinv.setItem(20, apps);
            SFinv.setItem(21, inbox);
            SFinv.setItem(22, options);
            
    
            player.openInventory(SFinv);
        }
        
    Thanks in advance!
     
    Last edited: Aug 29, 2017
  2. Offline

    ItsComits

    @oriamrm
    Hello, I see that you have set all the items but you have not opened the inventory for the player. For more information regarding openInventory, look below.
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
     
    Last edited: Aug 29, 2017
  3. Offline

    oriamrm

    Oh no sorry, just forgot to copy that part ;)
    I'll Edit That...
     
  4. Offline

    ItsComits

    If your problem is solved, Make sure to mark this thread as solved. :)
     
  5. Offline

    oriamrm

    @ItsComits Not solved, I just did not post it correctly.
     
  6. Offline

    ItsComits

    @oriamrm Does any inventory open up at all when running that method?
     
  7. Offline

    oriamrm

    @ItsComits No. Nor does an error message appear in the console log :(
     
  8. Offline

    ItsComits

    You need to return an inventory in your openPhone method. Also which method do you execute first?
     
  9. Offline

    oriamrm

    No offense, but you don't understand, I execute openPhone first, and I didn't copy the "player.openInventory" line from the code to this post. It did work, until I added another plugin. Is there some way these 2 Plugins are colliding or something?

    Nevermind, Solved It!
    Turnes out Plugin 2 had a Listener that prevent players from placing blocks, and somehow it didn't allow them to open inventories as well. Go figure :)

    Thanks for the help anyway
    @ItsComits

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Aug 29, 2017
Thread Status:
Not open for further replies.

Share This Page