mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-27 11:07:44 +01:00
Backup and replace updated treasures.yml file.
This commit is contained in:
parent
d5545de81f
commit
81140824e4
@ -11,7 +11,7 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
public abstract class ConfigLoader {
|
public abstract class ConfigLoader {
|
||||||
protected static final mcMMO plugin = mcMMO.p;
|
protected static final mcMMO plugin = mcMMO.p;
|
||||||
protected String fileName;
|
protected String fileName;
|
||||||
protected File configFile;
|
private File configFile;
|
||||||
protected FileConfiguration config;
|
protected FileConfiguration config;
|
||||||
|
|
||||||
public ConfigLoader(String relativePath, String fileName) {
|
public ConfigLoader(String relativePath, String fileName) {
|
||||||
@ -66,4 +66,19 @@ public abstract class ConfigLoader {
|
|||||||
public File getFile() {
|
public File getFile() {
|
||||||
return configFile;
|
return configFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void backup() {
|
||||||
|
plugin.getLogger().warning("You are using an old version of the " + fileName + " file.");
|
||||||
|
plugin.getLogger().warning("Your old file has been renamed to " + fileName + ".old and has been replaced by an updated version.");
|
||||||
|
|
||||||
|
configFile.renameTo(new File(configFile.getPath() + ".old"));
|
||||||
|
|
||||||
|
if (plugin.getResource(fileName) != null) {
|
||||||
|
plugin.saveResource(fileName, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.getLogger().warning("Reloading " + fileName + " with new values...");
|
||||||
|
loadFile();
|
||||||
|
loadKeys();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,9 +75,7 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
@Override
|
@Override
|
||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
if (config.getConfigurationSection("Treasures") != null) {
|
if (config.getConfigurationSection("Treasures") != null) {
|
||||||
plugin.getLogger().warning("You are using an old version of the treasures.yml file.");
|
backup();
|
||||||
plugin.getLogger().warning("You should delete your current file and allow a new one to generate.");
|
|
||||||
plugin.getLogger().warning("Shake, Hylian Luck, Fishing, and Excavation will not work properly until you do.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.repair.config;
|
package com.gmail.nossr50.skills.repair.config;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -161,19 +160,4 @@ public class RepairConfig extends ConfigLoader {
|
|||||||
|
|
||||||
return issues.isEmpty();
|
return issues.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void backup() {
|
|
||||||
plugin.getLogger().warning("You are using an old version of the " + fileName + " file.");
|
|
||||||
plugin.getLogger().warning("Your old file has been renamed to " + fileName + ".old and has been replaced by an updated version.");
|
|
||||||
|
|
||||||
configFile.renameTo(new File(configFile.getPath() + ".old"));
|
|
||||||
|
|
||||||
if (plugin.getResource(fileName) != null) {
|
|
||||||
plugin.saveResource(fileName, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin.getLogger().warning("Reloading " + fileName + " with new values...");
|
|
||||||
loadFile();
|
|
||||||
loadKeys();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user