Introduced updater for config.yml
Signed-off-by: DroppingAnvil <dr0pping.4nvi1@gmail.com>
This commit is contained in:
parent
d590d854ce
commit
d3870731f4
@ -185,17 +185,19 @@ public class FactionsPlugin extends MPlugin {
|
||||
// Load Conf from disk
|
||||
Conf.load();
|
||||
//Dependency checks
|
||||
if (Conf.dependencyCheck && (Bukkit.getPluginManager().isPluginEnabled("Vault") && Bukkit.getPluginManager().isPluginEnabled("Essentials"))) {
|
||||
RegisteredServiceProvider<Economy> rsp = FactionsPlugin.this.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
FactionsPlugin.econ = rsp.getProvider();
|
||||
} else if (Conf.dependencyCheck) {
|
||||
if (Conf.dependencyCheck && (!Bukkit.getPluginManager().isPluginEnabled("Vault") && !Bukkit.getPluginManager().isPluginEnabled("Essentials"))) {
|
||||
divider();
|
||||
System.out.println("You are missing dependencies!");
|
||||
System.out.println("Please verify EssentialsX and Vault are installed!");
|
||||
Conf.save();
|
||||
Bukkit.getPluginManager().disablePlugin(instance);
|
||||
divider();
|
||||
return;
|
||||
}
|
||||
//Update their config if needed
|
||||
Updater.updateIfNeeded(getConfig());
|
||||
RegisteredServiceProvider<Economy> rsp = FactionsPlugin.this.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
FactionsPlugin.econ = rsp.getProvider();
|
||||
com.massivecraft.factions.integration.Essentials.setup();
|
||||
hookedPlayervaults = setupPlayervaults();
|
||||
FPlayers.getInstance().load();
|
||||
|
26
src/main/java/com/massivecraft/factions/util/Updater.java
Normal file
26
src/main/java/com/massivecraft/factions/util/Updater.java
Normal file
@ -0,0 +1,26 @@
|
||||
package com.massivecraft.factions.util;
|
||||
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Updater {
|
||||
public static double currentVersion = 1.0;
|
||||
public static void updateIfNeeded(FileConfiguration conf) {
|
||||
double version = conf.getDouble("Config-Version", 0);
|
||||
//Previous version
|
||||
if (version == 0) {
|
||||
//Instructions for this configuration to be updated to current
|
||||
FactionsPlugin.getInstance().log("Your config.yml is pre-versioning so we are going to assign it version 1.0 \n Please regenerate your config.yml if you run into any errors relating to config.");
|
||||
conf.set("Config-Version", 1.0);
|
||||
version = 1.0;
|
||||
}
|
||||
//End with save + reload
|
||||
try {
|
||||
conf.save(new File("plugins/Factions/config.yml"));
|
||||
FactionsPlugin.getInstance().reloadConfig();
|
||||
} catch (IOException e) {e.printStackTrace();}
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
Config-Version: 1.0
|
||||
# SaberFactions by Driftay
|
||||
# Report issues: https://github.com/Driftay/Saber-Factions/issues/new
|
||||
# Live support: https://discord.gg/TFxWKeX
|
||||
|
Loading…
Reference in New Issue
Block a user