Small bug fix + Code added to run randomized missions

Signed-off-by: DroppingAnvil <dr0pping.4nvi1@gmail.com>
This commit is contained in:
DroppingAnvil
2019-11-14 02:27:29 -06:00
parent 8bde1385fc
commit bd77c8266c
5 changed files with 105 additions and 4 deletions

View File

@@ -5,9 +5,11 @@ import org.bukkit.configuration.file.FileConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class Updater {
public static double currentVersion = 1.0;
public static double currentVersion = 1.1;
public static void updateIfNeeded(FileConfiguration conf) {
double version = conf.getDouble("Config-Version", 0);
//Previous version
@@ -17,6 +19,25 @@ public class Updater {
conf.set("Config-Version", 1.0);
version = 1.0;
}
if (version == 1.0) {
FactionsPlugin.getInstance().log("Updating config from version 1.0 to 1.1");
FactionsPlugin.getInstance().log("Adding randomization support for f missions...");
conf.set("Randomization.Enabled", false);
conf.set("Randomization.Start-Item.Allowed.Name", "&aStart!");
conf.set("Randomization.Start-Item.Allowed.Material", "GREEN_STAINED_GLASS_PANE");
List<String> lore = new ArrayList<>();
lore.add("&aStart a new mission!");
conf.set("Randomization.Start-Item.Allowed.Lore", lore);
conf.set("Randomization.Start-Item.Disallowed.Name", "&4Cannot start new mission");
conf.set("Randomization.Start-Item.Disallowed.Material", "GRAY_STAINED_GLASS_PANE");
lore.clear();
lore.add("&4%reason%");
conf.set("Randomization.Start-Item.Disallowed.Lore", lore);
conf.set("Randomization.Start-Item.Slot", 23);
conf.set("Config-Version", 1.1);
version = 1.1;
}
//End with save + reload
try {
conf.save(new File("plugins/Factions/config.yml"));