Add config updater.

This commit is contained in:
drtshock
2013-03-30 19:01:16 -05:00
parent 708976dacb
commit f550a27f4f
2 changed files with 34 additions and 2 deletions
@@ -71,7 +71,7 @@ public class Main extends JavaPlugin {
dropOnDeath = true;
inventoriesToDrop = getConfig().getInt("drop-on-death.inventories");
}
new File(directory + File.separator + "backups").mkdirs();
config = getConfig();
@@ -128,6 +128,37 @@ public class Main extends JavaPlugin {
}
}
public void updateConfig() {
if(getConfig().get("check-update") == null) {
getConfig().set("check-update", true);
}
if(getConfig().get("economy.enabled") == null) {
getConfig().set("economy.enabled", false);
}
if(getConfig().get("economy.cost-to-create") == null) {
getConfig().set("economy.cost-to-create", 100);
}
if(getConfig().get("economy.cost-to-open") == null) {
getConfig().set("economy.cost-to-create", 10);
}
if(getConfig().get("economy.refund-on-delete") == null) {
getConfig().set("economy.refund-on-delete", 50);
}
if(getConfig().get("drop-on-death.enabled") == null) {
getConfig().set("drop-on-death.enabled", false);
}
if(getConfig().get("drop-on-death.inventories") == null) {
getConfig().set("drop-on-death.inventories", 1);
}
saveConfig();
}
public YamlConfiguration loadLang() {
File lang = new File(getDataFolder(), "lang.yml");
if(!lang.exists()) {
@@ -158,7 +189,7 @@ public class Main extends JavaPlugin {
public YamlConfiguration getLang() {
return lang;
}
public File getLangFile() {
return langFile;
}
@@ -83,6 +83,7 @@ public class BackwardsCompatibility {
return inventory;
}
@SuppressWarnings("unused")
private static CraftItemStack getCraftVersion(org.bukkit.inventory.ItemStack stack) {
if ((stack instanceof CraftItemStack))
return (CraftItemStack) stack;