Config files generate properly on reload.

This commit is contained in:
Adam committed 2012-05-16 15:48:54 -04:00
1 parent 6aa10fca11
commit 9de009cc44
2 files changed
+20 -10

No files matched your search

@@ -65,19 +65,11 @@ public class Anticheat extends JavaPlugin
public void onEnable() public void onEnable()
{ {
plugin = this; plugin = this;
if(!new File(this.getDataFolder()+"/config.yml").exists()) checkConfig();
{
saveDefaultConfig();
if(verbose)
{
logger.log(Level.INFO,"[AC] Config file created");
}
}
config = AnticheatManager.CONFIGURATION; config = AnticheatManager.CONFIGURATION;
verbose = config.verboseStartup(); verbose = config.verboseStartup();
updateFolder = config.updateFolder(); updateFolder = config.updateFolder();
checkForUpdate(); checkForUpdate();
eventList.add(new PlayerListener()); eventList.add(new PlayerListener());
eventList.add(new BlockListener()); eventList.add(new BlockListener());
eventList.add(new EntityListener()); eventList.add(new EntityListener());
@@ -217,6 +209,18 @@ public class Anticheat extends JavaPlugin
} }
} }
public static void checkConfig()
{
if(!config.getConfigFile().exists())
{
plugin.saveDefaultConfig();
if(verbose)
{
logger.log(Level.INFO,"[AC] Config file created");
}
}
}
private void checkForUpdate() private void checkForUpdate()
{ {
if(verbose) if(verbose)
@@ -71,7 +71,7 @@ public class Configuration {
public boolean alertXRay() public boolean alertXRay()
{ {
return logXRay; return alertXRay;
} }
public boolean autoUpdate() public boolean autoUpdate()
@@ -91,6 +91,7 @@ public class Configuration {
public final void load() public final void load()
{ {
Anticheat.checkConfig();
config = YamlConfiguration.loadConfiguration(configFile); config = YamlConfiguration.loadConfiguration(configFile);
bukkit = YamlConfiguration.loadConfiguration(bukkitFile); bukkit = YamlConfiguration.loadConfiguration(bukkitFile);
updateFolder = bukkit.getString("settings.update-folder"); updateFolder = bukkit.getString("settings.update-folder");
@@ -163,6 +164,11 @@ public class Configuration {
return worlds; return worlds;
} }
public File getConfigFile()
{
return configFile;
}
public boolean checkInWorld(World world) public boolean checkInWorld(World world)
{ {
return worlds.contains(world.getName()); return worlds.contains(world.getName());