Finished implementing new config management.

This commit is contained in:
Steven Lawson 2011-10-12 16:25:26 -04:00
parent 5f6c37cfee
commit d1ed5b8509
2 changed files with 11 additions and 6 deletions

View File

@ -26,7 +26,7 @@ dist.jar=${dist.dir}/TotalFreedomMod.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.bukkit-0.0.1-SNAPSHOT.jar=C:\\github\\bukkit-0.0.1-SNAPSHOT.jar
file.reference.bukkit-0.0.1-SNAPSHOT.jar=C:\\github\\Bukkit\\target\\bukkit-0.0.1-SNAPSHOT.jar
file.reference.MobDisguise.jar=C:\\github\\MobDisguise\\dist\\MobDisguise.jar
includes=**
jar.compress=false

View File

@ -72,7 +72,7 @@ public class TotalFreedomMod extends JavaPlugin
@Override
public void onEnable()
{
loadConfig();
loadTFMConfig();
registerEventHandlers();
@ -219,8 +219,10 @@ public class TotalFreedomMod extends JavaPlugin
return removed;
}
private void loadConfig()
private void loadTFMConfig()
{
log.info("[Total Freedom Mod] Loading configuration...");
createDefaultConfiguration("config.yml");
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
@ -259,13 +261,15 @@ public class TotalFreedomMod extends JavaPlugin
File actual = new File(getDataFolder(), name);
if (!actual.exists())
{
log.info("[Total Freedom Mod]: Loading default configuration file: " + name);
InputStream input = null;
try
{
JarFile file = new JarFile(getFile());
ZipEntry copy = file.getEntry("src/" + name);
ZipEntry copy = file.getEntry(name);
if (copy == null)
{
log.severe("[TotalFreedomMod]: Unable to read default configuration: " + name);
return;
}
input = file.getInputStream(copy);
@ -280,6 +284,7 @@ public class TotalFreedomMod extends JavaPlugin
try
{
getDataFolder().mkdirs();
output = new FileOutputStream(actual);
byte[] buf = new byte[8192];
int length = 0;
@ -292,7 +297,7 @@ public class TotalFreedomMod extends JavaPlugin
}
catch (IOException ioex)
{
log.severe("[TotalFreedomMod]: Unable to write default configuration: " + name);
log.log(Level.SEVERE, "[Total Freedom Mod]: Unable to write default configuration: " + name, ioex);
}
finally
{