Configuration should now update. Doesn't keep comments -.-

This commit is contained in:
Andrew 2013-08-06 00:04:01 +12:00
parent fd3903f311
commit e3c83482d8

View File

@ -1,5 +1,6 @@
package me.libraryaddict.disguise; package me.libraryaddict.disguise;
import java.io.File;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -35,6 +36,7 @@ import net.minecraft.server.v1_6_R2.World;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.craftbukkit.v1_6_R2.CraftWorld; import org.bukkit.craftbukkit.v1_6_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftEntity; import org.bukkit.craftbukkit.v1_6_R2.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_6_R2.entity.CraftLivingEntity;
@ -377,16 +379,17 @@ public class LibsDisguises extends JavaPlugin {
return; return;
} }
saveDefaultConfig(); saveDefaultConfig();
if (!getConfig().contains("DisguiseRadiusMax")) YamlConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
getConfig().set("DisguiseRadiusMax", getConfig().getInt("DisguiseRadiusMax")); if (!config.contains("DisguiseRadiusMax"))
if (!getConfig().contains("UndisguiseRadiusMax")) config.set("DisguiseRadiusMax", getConfig().getInt("DisguiseRadiusMax"));
getConfig().set("UndisguiseRadiusMax", getConfig().getInt("UndisguiseRadiusMax")); if (!config.contains("UndisguiseRadiusMax"))
if (!getConfig().contains("DisguiseSounds")) config.set("UndisguiseRadiusMax", getConfig().getInt("UndisguiseRadiusMax"));
getConfig().set("DisguiseSounds", getConfig().getBoolean("DisguiseSounds")); if (!config.contains("DisguiseSounds"))
if (!getConfig().contains("HearSelfDisguise")) config.set("DisguiseSounds", getConfig().getBoolean("DisguiseSounds"));
getConfig().set("HearSelfDisguise", getConfig().getBoolean("HearSelfDisguise")); if (!config.contains("HearSelfDisguise"))
if (!getConfig().contains("SendVelocity")) config.set("HearSelfDisguise", getConfig().getBoolean("HearSelfDisguise"));
getConfig().set("SendVelocity", getConfig().getBoolean("SendVelocity")); if (!config.contains("SendVelocity"))
config.set("SendVelocity", getConfig().getBoolean("SendVelocity"));
DisguiseAPI.init(this); DisguiseAPI.init(this);
DisguiseAPI.enableSounds(getConfig().getBoolean("DisguiseSounds")); DisguiseAPI.enableSounds(getConfig().getBoolean("DisguiseSounds"));
DisguiseAPI.setVelocitySent(getConfig().getBoolean("SendVelocity")); DisguiseAPI.setVelocitySent(getConfig().getBoolean("SendVelocity"));