Plugin Help Config going back to default

Discussion in 'Plugin Help/Development/Requests' started by PotatoLol12321, Nov 6, 2014.

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

    PotatoLol12321

    Code:java
    1. package potato.kits;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.command.Command;
    5. import org.bukkit.command.CommandSender;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.event.Listener;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10. public class MenuInv extends JavaPlugin implements Listener {
    11.  
    12. private Menu menu;
    13.  
    14. public void onEnable() {
    15. menu = new Menu(this);
    16. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    17. loadConfiguration();
    18. reloadConfig();
    19. }
    20.  
    21. public void loadConfiguration(){
    22. getConfig().options().copyDefaults(true);
    23. saveConfig();
    24. }
    25.  
    26. public void onDisable() {
    27. saveConfig();
    28. reloadConfig();
    29. }
    30.  
    31. public boolean onCommand(CommandSender sender, Command cmd, String commandLablel, String[] args) {
    32. if(commandLablel.equalsIgnoreCase("kit")) {
    33. Player player = (Player) sender;
    34. if(sender instanceof Player){
    35. menu.show(player);
    36. }
    37. }
    38. return false;
    39. }
    40. }


    When I edit the config.yml and reload, it goes back to default? Any ideas?
     
  2. Offline

    Lolmewn

    You have saveConfig() in your onDisable. When you reload the config that is stored in memory gets written to the file - so it overwrites your changes.

    Also please don't use /reload.
     
  3. Offline

    1Camer0471

    make sure your editing the config when your server is OFF, otherwise it will just save whatever data that was in the config when the server started
     
Thread Status:
Not open for further replies.

Share This Page