What I want to do is create Icons from a config like this is in my config, Code: AWESOME_BIOME: Location: X: 13.433264692805967 Z: 9.544612608063655 Y: 71.0 World: Spawn ID: ItemID There are more of this format things n the config now I want to add them all in an inventory.. How do I do that? IM SORRY FOR MY BAD LANGUAGE AND BAD EXPLANATION!
@MordorKing78 First you must create an inventory: Inventory inv = Bukkit.createInventory(Holder, Slots, name) Then you need to make some ItemStacks: ItemStack i = new ItemStack(Material.getMaterial(String), Amount, Data); Set it`s name: ItemMeta im = i.getItemMeta(); im.setDisplayName(String); i.setItemMeta(im); Set the item on the inventory: inv.setItem(Slot, i) <-- i = ItemStack. Open the inventory: player.openInventory(inv); For make something when someone clicks over the item, you must use InventoryClick event and check if CurrentItem is the ItemStack you`re looking for. @EventHandler public void onInventoryClick(InventoryClickEvent e) { ItemStack i = new ItemStack(Material.getMaterial(String), Amount, Data); ItemMeta im = i.getItemMeta(); im.setDisplayName(String); i.setItemMeta(im); if (e.getCurrentItem.equals(i)) { World w = Bukkit.getWorld(getConfig().getString("AWESOME_BIOME.Location.World)); double x = getConfig().getDouble("AWESOME_BIOME.Location.X"); double y = getConfig().getDouble("AWESOME_BIOME.Location.Y"); double z = getConfig().getDouble("AWESOME_BIOME.Location.Z"); Location l = new Location(w, x, y, z); e.getPlayer().teleport(l); } }
@Shadowkiller891 I know how create an inventory @Juancomaster1998 My problem is to get the AWESOME_BIOME part out of the config. There are more named like BIOME_SMALL or something this must be automated. @Skionz Well, I have not much. I only have the created inventory.
@MordorKing78 Well, imagine you put all that names on a path named "BIOMES", so it will be something like: Code: BIOMES: AWESOME_BIOME: Location: X: 13.433264692805967 Z: 9.544612608063655 Y: 71.0 World: Spawn ID: ItemID SMALL_BIOME: Location: X: 13.433264692805967 Z: 9.544612608063655 Y: 71.0 World: Spawn ID: ItemID So you do something like: for (String biome : getConfig().getConfigurationSection("BIOMES").getKeys(false)) { //Stuff to do } That will repeat the stuff for every biome, when the biome`s name is the string biome
@Shadowkiller891 Firstly, theBcBroz are NOT good tutorials to follow. There code shows MANY bad practices and general basic Java issues. You do not want to be following his tutorials, any developer will tell you also. Secondly, tahging or quoting people makes them see the post much quicker. Lastly, @MordorKing78 if you are looking for video tutorials, the best you can get is PogoStick29dev. If you don't mind text tutorials I would recommend going to the Resources section.
@Juancomaster1998 So if I understand this correcly I can do something like this, for (String biome : getConfig().getConfigurationSection("BIOMES").getKeys(false)) { s.addItem()... } ??
@Juancomaster1998 s is my inventory. EDIT: How would I do it then? EDIT: This wont work, Code: for (String biome : plugin.getConfig().getConfigurationSection("BIOMES").getKeys(false)) { ItemStack item = new ItemStack(Material.DIAMOND); ItemMeta im = item.getItemMeta(); im.setDisplayName("§e" + biome); item.setItemMeta(im); s.addItem(new ItemStack(item)); } Omg, My configuartionsection was Biomes. Thanks man you helped me out A LOT! Thanks!