Informative config migration
This commit is contained in:
@@ -312,7 +312,7 @@ public class PlayerVaults extends JavaPlugin {
|
|||||||
private void loadConfig() {
|
private void loadConfig() {
|
||||||
File configYaml = new File(this.getDataFolder(), "config.yml");
|
File configYaml = new File(this.getDataFolder(), "config.yml");
|
||||||
if (configYaml.exists()) {
|
if (configYaml.exists()) {
|
||||||
this.config.setFromConfig(this.getConfig());
|
this.config.setFromConfig(this.getLogger(), this.getConfig());
|
||||||
try {
|
try {
|
||||||
Files.move(configYaml.toPath(), this.getDataFolder().toPath().resolve("old_unused_config.yml"));
|
Files.move(configYaml.toPath(), this.getDataFolder().toPath().resolve("old_unused_config.yml"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@SuppressWarnings({"FieldCanBeLocal", "InnerClassMayBeStatic", "unused"})
|
@SuppressWarnings({"FieldCanBeLocal", "InnerClassMayBeStatic", "unused"})
|
||||||
public class Config {
|
public class Config {
|
||||||
@@ -158,25 +159,27 @@ public class Config {
|
|||||||
@Comment("Storage option. Currently only flatfile, but soon more! :)")
|
@Comment("Storage option. Currently only flatfile, but soon more! :)")
|
||||||
private Storage storage = new Storage();
|
private Storage storage = new Storage();
|
||||||
|
|
||||||
public void setFromConfig(FileConfiguration c) {
|
public void setFromConfig(Logger l, FileConfiguration c) {
|
||||||
this.debug = c.getBoolean("debug", false);
|
l.info("Importing old configuration...");
|
||||||
this.language = c.getString("language", "english");
|
l.info("debug = "+(this.debug = c.getBoolean("debug", false)));
|
||||||
this.signs = c.getBoolean("signs-enabled", false);
|
l.info("language = "+(this.language = c.getString("language", "english")));
|
||||||
this.economy.enabled = c.getBoolean("economy.enabled", false);
|
l.info("signs = "+(this.signs = c.getBoolean("signs-enabled", false)));
|
||||||
this.economy.feeToCreate = c.getDouble("economy.cost-to-create", 100);
|
l.info("economy enabled = "+(this.economy.enabled = c.getBoolean("economy.enabled", false)));
|
||||||
this.economy.feeToOpen = c.getDouble("economy.cost-to-open", 10);
|
l.info(" creation fee = "+(this.economy.feeToCreate = c.getDouble("economy.cost-to-create", 100)));
|
||||||
this.economy.refundOnDelete = c.getDouble("economy.refund-on-delete", 50);
|
l.info(" open fee = "+(this.economy.feeToOpen = c.getDouble("economy.cost-to-open", 10)));
|
||||||
this.itemBlocking.enabled = c.getBoolean("blockitems", true);
|
l.info(" refund = "+(this.economy.refundOnDelete = c.getDouble("economy.refund-on-delete", 50)));
|
||||||
this.itemBlocking.list = c.getStringList("blocked-items");
|
l.info("item blocking enabled = "+(this.itemBlocking.enabled = c.getBoolean("blockitems", true)));
|
||||||
|
l.info("blocked items = "+(this.itemBlocking.list = c.getStringList("blocked-items")));
|
||||||
if (this.itemBlocking.list == null) {
|
if (this.itemBlocking.list == null) {
|
||||||
this.itemBlocking.list = new ArrayList<>();
|
this.itemBlocking.list = new ArrayList<>();
|
||||||
this.itemBlocking.list.add("PUMPKIN");
|
this.itemBlocking.list.add("PUMPKIN");
|
||||||
this.itemBlocking.list.add("DIAMOND_BLOCK");
|
this.itemBlocking.list.add("DIAMOND_BLOCK");
|
||||||
|
l.info(" set defaults: "+this.itemBlocking.list);
|
||||||
}
|
}
|
||||||
this.purge.enabled = c.getBoolean("cleanup.enable", false);
|
l.info("cleanup purge enabled = "+(this.purge.enabled = c.getBoolean("cleanup.enable", false)));
|
||||||
this.purge.daysSinceLastEdit = c.getInt("cleanup.lastEdit", 30);
|
l.info(" days since last edit = "+(this.purge.daysSinceLastEdit = c.getInt("cleanup.lastEdit", 30)));
|
||||||
this.storage.flatFile.backups = c.getBoolean("backups.enabled", true);
|
l.info("flatfile storage backups = "+(this.storage.flatFile.backups = c.getBoolean("backups.enabled", true)));
|
||||||
this.maxVaultAmountPermTest = c.getInt("max-vault-amount-perm-to-test", 99);
|
l.info("max vault amount to test via perms = "+(this.maxVaultAmountPermTest = c.getInt("max-vault-amount-perm-to-test", 99)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDebug() {
|
public boolean isDebug() {
|
||||||
|
|||||||
Reference in New Issue
Block a user