From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: jmp <jasonpenilla2@me.com>
Date: Mon, 30 Nov 2020 18:30:13 -0800
Subject: [PATCH] Config migration: disable saving projectiles to disk ->
 projectile load/save limit of 0


diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
index f99566da1ea88cfddf14fd73cba98643707bb893..dc6122ef302055eb2c08fda05be977b045b6debe 100644
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
@@ -1,6 +1,7 @@
 package net.pl3x.purpur;
 
 import co.aikar.timings.TimingsManager;
+import com.destroystokyo.paper.PaperConfig;
 import com.google.common.base.Throwables;
 import net.minecraft.locale.LocaleLanguage;
 import net.minecraft.server.MinecraftServer;
@@ -133,6 +134,17 @@ public class PurpurConfig {
         return config.getString(path, config.getString(path));
     }
 
+    private static void migrateDisableProjectileSaving() {
+        if (PurpurConfig.version < 6) {
+            final boolean saveProjectilesToDisk = getBoolean("world-settings.default.gameplay-mechanics.save-projectiles-to-disk", true);
+            set("world-settings.default.gameplay-mechanics.save-projectiles-to-disk", null);
+            if (!saveProjectilesToDisk) {
+                PaperConfig.config.set("world-settings.default.projectile-load-save-per-chunk-limit", 0);
+                PaperConfig.saveConfig();
+            }
+        }
+    }
+
     public static String afkBroadcastAway = "§e§o%s is now AFK";
     public static String afkBroadcastBack = "§e§o%s is no longer AFK";
     public static String afkTabListPrefix = "[AFK] ";
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index df42e4a1d1c542eb20759ede3e20ce186352e5c2..dbd3836c4f35a5ae560234b268d0f69b0a13701d 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -1,5 +1,6 @@
 package net.pl3x.purpur;
 
+import com.destroystokyo.paper.PaperConfig;
 import net.minecraft.core.IRegistry;
 import net.minecraft.world.EnumDifficulty;
 import net.minecraft.world.level.Explosion;
@@ -84,6 +85,17 @@ public class PurpurWorldConfig {
         return PurpurConfig.config.getString("world-settings." + worldName + "." + path, PurpurConfig.config.getString("world-settings.default." + path));
     }
 
+    private void migrateDisableProjectileSaving() {
+        if (PurpurConfig.version < 6) {
+            final boolean saveProjectilesToDisk = PurpurConfig.config.getBoolean("world-settings." + worldName + ".gameplay-mechanics.save-projectiles-to-disk", true);
+            PurpurConfig.config.set("world-settings." + worldName + ".gameplay-mechanics.save-projectiles-to-disk", null);
+            if (!saveProjectilesToDisk) {
+                PaperConfig.config.set("world-settings." + worldName + ".projectile-load-save-per-chunk-limit", 0);
+                PaperConfig.saveConfig();
+            }
+        }
+    }
+
     public boolean armorstandSetNameVisible = false;
     public boolean armorstandFixNametags = false;
     public float armorstandStepHeight = 0.0F;
