fix config updating
Comments still won't appear in nested paths. That needs to be fixed
This commit is contained in:
@@ -10,7 +10,6 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
@@ -35,7 +34,6 @@ public class Main extends JavaPlugin {
|
|||||||
public static boolean dropOnDeath = false;
|
public static boolean dropOnDeath = false;
|
||||||
public static int inventoriesToDrop = 0;
|
public static int inventoriesToDrop = 0;
|
||||||
public static boolean useVault = false;
|
public static boolean useVault = false;
|
||||||
public static FileConfiguration config;
|
|
||||||
public static YamlConfiguration lang;
|
public static YamlConfiguration lang;
|
||||||
public static File langFile;
|
public static File langFile;
|
||||||
public static String directory = "plugins" + File.separator + "PlayerVaults" + File.separator + "vaults";
|
public static String directory = "plugins" + File.separator + "PlayerVaults" + File.separator + "vaults";
|
||||||
@@ -80,7 +78,6 @@ public class Main extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
new File(directory + File.separator + "backups").mkdirs();
|
new File(directory + File.separator + "backups").mkdirs();
|
||||||
config = getConfig();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,36 +135,29 @@ public class Main extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateConfig() {
|
public void updateConfig() {
|
||||||
if(getConfig().get("check-update") == null) {
|
boolean checkUpdate = getConfig().getBoolean("check-update", true);
|
||||||
getConfig().set("check-update", true);
|
boolean ecoEnabled = getConfig().getBoolean("economy.enabled", false);
|
||||||
}
|
int ecoCreate = getConfig().getInt("economy.cost-to-create", 100);
|
||||||
|
int ecoOpen = getConfig().getInt("economy.cost-to-open", 10);
|
||||||
if(getConfig().get("economy.enabled") == null) {
|
int ecoDelete = getConfig().getInt("economy.refund-on-delete", 50);
|
||||||
getConfig().set("economy.enabled", false);
|
boolean dropEnabled = getConfig().getBoolean("drop-on-death.enabled", false);
|
||||||
}
|
int dropInvs = getConfig().getInt("drop-on-death.inventories", 50);
|
||||||
|
new File("plugins" + File.separator + "PlayerVaults" + File.separator + "config.yml").delete();
|
||||||
if(getConfig().get("economy.cost-to-create") == null) {
|
saveDefaultConfig();
|
||||||
getConfig().set("economy.cost-to-create", 100);
|
setInConfig("check-update", checkUpdate);
|
||||||
}
|
setInConfig("economy.enabled", ecoEnabled);
|
||||||
|
setInConfig("economy.cost-to-create", ecoCreate);
|
||||||
if(getConfig().get("economy.cost-to-open") == null) {
|
setInConfig("economy.cost-to-open", ecoOpen);
|
||||||
getConfig().set("economy.cost-to-create", 10);
|
setInConfig("economy.refund-on-delete", ecoDelete);
|
||||||
}
|
setInConfig("drop-on-death.enabled", dropEnabled);
|
||||||
if(getConfig().get("economy.refund-on-delete") == null) {
|
setInConfig("drop-on-death.inventories", dropInvs);
|
||||||
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();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T> void setInConfig(String path, T object) {
|
||||||
|
getConfig().set(path, object);
|
||||||
|
}
|
||||||
|
|
||||||
public YamlConfiguration loadLang() {
|
public YamlConfiguration loadLang() {
|
||||||
File lang = new File(getDataFolder(), "lang.yml");
|
File lang = new File(getDataFolder(), "lang.yml");
|
||||||
if(!lang.exists()) {
|
if(!lang.exists()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user