Solved Reload config with command doesn't works

Discussion in 'Spigot Plugin Development' started by froyz, Jun 23, 2016.

  1. Hi guys,
    I'm trying to change an armor name by a config with a "/armorcolor reload", but when i change the name in the config and i save, and i use /armorcolor reload it rollback the name and it doesn't works, but if i do /reload it works.
    an explicit example :
    I change in the config the armor name : "Example name" by "Hello armor"
    I type /armorcolor reload --> In game it doesn't works, it give me example name armor.
    I look in the config, "Example name" is back.
    I change in the config the armor name : "Example name" by "Hello armor"
    I type /reload --> In game it works, it give me "Hello armor"
    I look in the config, there is "Hello armor"

    When i do my "/armorcolor reload" command : (this code)
    Code (Text):
            if (args.length == 1 && args[0].equalsIgnoreCase("reload")){
                   if (sender instanceof Player) {
                   if (player.hasPermission("armorcolor.reload")) {
                       player.sendMessage("§a[ArmorColor] reloaded");
                       System.out.println("§c[ArmorColor] reloaded");
    May you help me please
    • Winner Winner x 1
  2. Why are you enabling and disabling the plugin? o_o

  3. I though enabling and disabling it is like reload does(cause relaod works and not that) the #reloadConfig doesn't works too, it give me the same result
  4. Did you make your own config object? Give the whole class
  5. Try saveConfig() then reloadConfig() :l
  6. Doesn't work too :/, it does the same
  7. Insolvable :/ ?
  8. you're reloading the plugin itself not it's config,

    Code (Java):
     or Plugin#reloadConfig()
     or FileConfiguration#reloadConfig()
     or YamlConfiguration#reloadConfig()
    • Funny Funny x 1
  9. Ever if i try pl.reloadConfig(); it doesn't works, and if i try config.x reloadConfig() doesn't appear
    • Useful Useful x 1
  10. try doing this
    Code (Java):
    File file = new File(p.getDataFolder(), "config.yml");
    // vv to reload config
    FileConfiguration config = YamlConfiguration.loadConfiguration(file);
    have you setted up correctly the instance of JavaPlugin to use it on the other class ?
  11. Code (Text):
    This way is much simpler.

    Your code wasn't working because you were disabling the plugin before it could start up the plugin, I think.
  12. If it's a custom config file there is no reload. You just need to load it again from the file its self
  13. Hmm, yes i think, and it's not working :/
    Already did and it doesn't works.
    But how ??
  14. Solved, there was 2 configs file in my code, i delete one and now it works :)