Weird error

Discussion in 'Spigot Plugin Development' started by Snowmite, May 20, 2017.

  1. When I do this:
    Code (Text):
        public static void openHousesMenu(Player player)
        {

            ArrayList<ItemStack> items = new ArrayList<>();

            List<House> listHouse = new ArrayList<>();

            for(House house : Houses.getHouses()){
                if(Houses.getSellingHouses().contains(house)){
                    if(house.getState()==HouseState.FINISHED){
                        listHouse.add(house);
                    }
                }
            }

            for(House house : listHouse){
                ItemStack item = new ItemStack(Material.matchMaterial(Life.getInstance().getConfig().getString("houses-menu.house-item-material")), 1);
                ItemMeta meta = item.getItemMeta();
                meta.setDisplayName(Life.getInstance().getConfig().getString("houses-menu.house-item-name").replace("&", "§").replace("{house}", house.getName()));
                List<String> lore = new ArrayList<>();

                for(String string : Life.getInstance().getConfig().getStringList("houses-menu.house-item-lore")){
                    string = string.replace("&", "§");
                    string = string.replace("{house}", house.getName());
                    string = string.replace("{builder}", String.valueOf(house.getBuilder()));
                    string = string.replace("{cost}", String.valueOf(house.getCost()));
                    lore.add(string);
                }
                meta.setLore(lore);

                items.add(item);
            }

            HouseScrollingInventory inventory = new HouseScrollingInventory(items, Life.getInstance().getConfig().getString("houses-menu.name").replace("&", "§"), player);
        }
    It shows 3 stacks of paper with no item meta.
     
  2. You forgot to set the meta to the item

    ItemStack#setItemMeta(ItemMeta);

    Edit: Also, you can do all your replaces on a single line
     
  3. Thank you but I'm still having the amount issue.
     
  4. Post updated code.