package me.rafaskb.ticketmaster;

import me.rafaskb.ticketmaster.utils.ConfigLoader;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

import me.rafaskb.ticketmaster.listeners.PlayerJoinListener;
import me.rafaskb.ticketmaster.sql.DatabaseManager;
import me.rafaskb.ticketmaster.tasks.CooldownCleanup;
import me.rafaskb.ticketmaster.tasks.PendingTicketNotifier;
import me.rafaskb.ticketmaster.utils.LangConfig;

public class TicketMaster extends JavaPlugin {
	private static TicketMaster instance;
	
	@Override
	public void onEnable() {
		instance = this;

		// Load lang.yml
		LangConfig.reloadConfig();
        ConfigLoader.reloadConfig();

		// Open database
		DatabaseManager.open();
		DatabaseManager.createTablesIfNotExists();
		DatabaseManager.updateDatabase();
		
		// Commands
		CommandHandler cmdHandler = new CommandHandler();
		getCommand("ticket").setExecutor(cmdHandler);
		getCommand("tickets").setExecutor(cmdHandler);
		
		// Listeners
		PluginManager pm = getServer().getPluginManager();
		pm.registerEvents(new PlayerJoinListener(), this);
		
		// Tasks
		new PendingTicketNotifier().register(this);
		new CooldownCleanup().register(this);
	}
	
	@Override
	public void onDisable() {
        ConfigLoader.saveConfig();
		DatabaseManager.close();
		Bukkit.getScheduler().cancelTasks(this);
		instance = null;
	}
	
	public static TicketMaster getInstance() {
		return instance;
	}
}

@@ -627,12 +627,19 @@
 lang
-.yml
+ and config
 %0A%09%09L
@@ -664,24 +664,18 @@
 nfig();%0A
-        
+%09%09
 ConfigLo
@@ -1259,43 +1259,8 @@
 ) %7B%0A
-        ConfigLoader.saveConfig();%0A
 %09%09Da

Fix config being overwritten on plugin disable