mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-11-27 04:25:14 +01:00
Prepare for database migrations
This commit is contained in:
parent
f193276372
commit
7842be5f75
@ -86,6 +86,8 @@ public class ChestShop extends JavaPlugin {
|
||||
Configuration.pairFileAndClass(loadFile("config.yml"), Properties.class);
|
||||
Configuration.pairFileAndClass(loadFile("local.yml"), Messages.class);
|
||||
|
||||
handleMigrations();
|
||||
|
||||
itemDatabase = new ItemDatabase();
|
||||
|
||||
NameManager.load();
|
||||
@ -127,6 +129,24 @@ public class ChestShop extends JavaPlugin {
|
||||
startUpdater();
|
||||
}
|
||||
|
||||
private final int CURRENT_DATABASE_VERSION = 1;
|
||||
|
||||
private void handleMigrations() {
|
||||
YamlConfiguration previousVersion = YamlConfiguration.loadConfiguration(loadFile("version"));
|
||||
|
||||
if (previousVersion.get("version") == null) {
|
||||
previousVersion.set("version", CURRENT_DATABASE_VERSION);
|
||||
}
|
||||
|
||||
int lastVersion = previousVersion.getInt("version");
|
||||
|
||||
switch(lastVersion){
|
||||
case CURRENT_DATABASE_VERSION:
|
||||
default:
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
public static File loadFile(String string) {
|
||||
File file = new File(dataFolder, string);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user