getDefaultSection null after reload

Discussion in 'Spigot Plugin Development' started by TheCreeperCow, Oct 10, 2018.

  1. Hi. So i have a problem my getDefaultSection() returns null after doing the reloadConfig() method is there a way to fix this?
  2. Can you post full code?
  3. Can you post your code....
  4. Reload method
    Code (Java):
        public void reload() {
            String langMode = getConfig().getString("System.Language Mode");
            this.locale = Locale.getLocale(getConfig().getString("System.Language Mode", langMode));
            this.spawnerFile.createNewFile("Loading Spawners File", "EpicSpawners Spawners File");
            this.hooksFile.createNewFile("Loading hookHandler File", "EpicSpawners Spawners File");
            this.references = new References();
    OpenSettings method
    Code (Java):
        public void openSettingsManager(Player player) {
            Inventory inventory = Bukkit.createInventory(null, 27, pluginName + " Settings Manager");
            ItemStack glass = Methods.getGlass();
            for (int i = 0; i < inventory.getSize(); i++) {
                inventory.setItem(i, glass);

            int slot = 10;
            for (String key : instance.getConfig().getDefaultSection().getKeys(false)) {
                ItemStack item = new ItemStack(Material.WHITE_WOOL, 1, (byte) (slot - 9)); //ToDo: Make this function as it was meant to.
                ItemMeta meta = item.getItemMeta();
                meta.setLore(Collections.singletonList(TextComponent.formatText("&6Click To Edit This Category.")));
                meta.setDisplayName(TextComponent.formatText("&f&l" + key));
                inventory.setItem(slot, item);

    This one is the one that gives the null error after the reload method has been invoked
  5. Have to cheaked to see if instance is null ?
    In your for loop
  6. The console throw a bug?

    You can use this code:
    Code (Java):
    for (String key : instance.getConfig().getConfigurationSection().getKeys(false)) {

Share This Page