Hello so I'm going to ask how to make a ItemStack skull and too many owners such as List<String> if thats a for loop statement how or what to do ? Code (Java): // config.yml List: - MadMaxCookie - love - cookies Code (Java): // Inventory Inventory inv; for(int i = 0; i <= 8; i++) { inv.setItem(i, skull); }
oh well so I'm trying to do that the player's in the list has their own skull then put it to the inventory from slot 0 to slot 8
If I understand correctly what you're trying to do, here's pseudo-code that should work: Code (Text): for each player in the configuration's list: create an item stack use SkullMeta#setOwner(String name) for slot 0 to 8: set the item in this slot
yes Code (Java): List<String> list = getConfig().getStringList(list); for(s : list) { SkullMeta#setOwner(s); } for(int i = 0; i <= 8; i++) { inv.setItem(i, skull); } is it correct ?
You would set the owner to "s" not "list" as that's the itterating veritable. Add the heads in the same for-each loop of the skull owner list.
oh lol thanks for notifying that thing I didn't expected I putted list not the for loop string s sorry gotta edit that post
Code (Java): List<String> list = getConfig().getStringList(list); Here, list has to be replaced by something like "List", it shouldn't be the variable but a hardcoded string (not sure if you did that on purpose, so I wanted to point it out just to be sure). Code (Java): for(s : list) { You have to define the type of the "s" variable. So it would look like that: for (String s : list) Code (Java): SkullMeta#setOwner(s); Don't use "#", but a dot (the pound sign is to reference a function, it is used in pseudo-code and anything outside of real code). Code (Java): for(int i = 0; i <= 8; i++) { Here I would have put "i < 9" rather than "i <= 8", both would work it's just question of habit. And this for loop should be IN the first one, as @xMrPoi said.