mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Finished implementing new config management.
This commit is contained in:
parent
5f6c37cfee
commit
d1ed5b8509
@ -26,7 +26,7 @@ dist.jar=${dist.dir}/TotalFreedomMod.jar
|
|||||||
dist.javadoc.dir=${dist.dir}/javadoc
|
dist.javadoc.dir=${dist.dir}/javadoc
|
||||||
endorsed.classpath=
|
endorsed.classpath=
|
||||||
excludes=
|
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
|
file.reference.MobDisguise.jar=C:\\github\\MobDisguise\\dist\\MobDisguise.jar
|
||||||
includes=**
|
includes=**
|
||||||
jar.compress=false
|
jar.compress=false
|
||||||
|
@ -72,7 +72,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
loadConfig();
|
loadTFMConfig();
|
||||||
|
|
||||||
registerEventHandlers();
|
registerEventHandlers();
|
||||||
|
|
||||||
@ -219,8 +219,10 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadConfig()
|
private void loadTFMConfig()
|
||||||
{
|
{
|
||||||
|
log.info("[Total Freedom Mod] Loading configuration...");
|
||||||
|
|
||||||
createDefaultConfiguration("config.yml");
|
createDefaultConfiguration("config.yml");
|
||||||
|
|
||||||
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "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);
|
File actual = new File(getDataFolder(), name);
|
||||||
if (!actual.exists())
|
if (!actual.exists())
|
||||||
{
|
{
|
||||||
|
log.info("[Total Freedom Mod]: Loading default configuration file: " + name);
|
||||||
InputStream input = null;
|
InputStream input = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
JarFile file = new JarFile(getFile());
|
JarFile file = new JarFile(getFile());
|
||||||
ZipEntry copy = file.getEntry("src/" + name);
|
ZipEntry copy = file.getEntry(name);
|
||||||
if (copy == null)
|
if (copy == null)
|
||||||
{
|
{
|
||||||
|
log.severe("[TotalFreedomMod]: Unable to read default configuration: " + name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
input = file.getInputStream(copy);
|
input = file.getInputStream(copy);
|
||||||
@ -280,6 +284,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
getDataFolder().mkdirs();
|
||||||
output = new FileOutputStream(actual);
|
output = new FileOutputStream(actual);
|
||||||
byte[] buf = new byte[8192];
|
byte[] buf = new byte[8192];
|
||||||
int length = 0;
|
int length = 0;
|
||||||
@ -288,11 +293,11 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
output.write(buf, 0, length);
|
output.write(buf, 0, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("[TotalFreedomMod]: Default configuration file written: " + name);
|
log.info("[Total Freedom Mod]: Default configuration file written: " + name);
|
||||||
}
|
}
|
||||||
catch (IOException ioex)
|
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
|
finally
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user