Solved check if a configuration section contains a specific string

Discussion in 'Plugin Development' started by thechrisanator, Nov 15, 2018.

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

    thechrisanator

    How can I check if a configuration section contains AIR?
    I'm storing ItemStacks in a config file, but I just want to see if certain sections have AIR as the item stack.

    I have this so far, but I want to put a glass pane in the place of air, if there is air.

    Code:
    for (String item : getConfig().getConfigurationSection("toolinv." + event.getPlayer().getUniqueId()).getKeys(false)) {
                    if (getConfig().getConfigurationSection("toolinv." + event.getPlayer().getUniqueId() + "." + item) != null) {
                        inv.setItem(index , loadItem(getConfig().getConfigurationSection("toolinv." + event.getPlayer().getUniqueId() + "." + item)));
                    }
                    index += 1;
                }
    I've tried this: but it just dies on me

    Code:
    if (inv.getItem(index).getType() == null) {
                        System.out.println("air " + Integer.toString(index));
                    }
    nevermind.

    answer:

    Code:
    if (inv.getItem(index) == null) {
                        inv.setItem(index, placeholders.get(index));
                    }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 16, 2018
Thread Status:
Not open for further replies.

Share This Page