Add items to an inventory in the config file

Discussion in 'Spigot Plugin Development' started by Kompye, Sep 11, 2019.

  1. Hello. I am working on a plugin that lets you heal with items in a healing inventory. I want players to be able to edit the materials, the lore, the name of the item, and so on. I am just getting into plugin development, so how can I do it? Here is an example of what I need the custom items to be like:
    Code (Java):
            ArrayList<String> item1_lore = new ArrayList<String>();
            item1_lore.add(Utils.color("&aPret: $100"));
            item1_lore.add(Utils.color("&cVei primi 3 vieti."));
            ItemStack item1 = new ItemStack(Material.COAL, 1);
            ItemMeta item1_meta = item1.getItemMeta();
            item1_meta.setDisplayName(ChatColor.AQUA + "Basic Healing");
            ArrayList<String> item2_lore = new ArrayList<String>();
            item2_lore.add(Utils.color("&aPret: $300"));
            item2_lore.add(Utils.color("&cViata va fi umpluta!"));
            ItemStack item2 = new ItemStack(Material.DIAMOND, 1);
            ItemMeta item2_meta = item2.getItemMeta();
            item2_meta.setDisplayName(Utils.color("&4Complete Healing"));
            gui.setItem(0, item1);
            gui.setItem(1, item2);
    • Useful Useful x 2
  2. Thanks! And what is the problem with my notation? I and the forum are the only ones that see the code :)
  3. I'm assuming you want them to be able to create custom items?
  4. Umm yes. But I want them to be able to add as many items as they want.
  5. Clean code is easier to maintain. Conventions have a reason.
  6. I thought the reason is for other people to understand your code easier and it is just a personal prefference. Nevermind, I am just a begginer, so thanks for the tip!
  7. You should look into keys, and other conventions. You will need to iterate through a configuration and setup a system for the configuration that will interpret what it is looking at.

    There is no easy way to do this unfortunately.