Avoid rewriting pufferfish config

This commit is contained in:
NotAlexNoyle committed 2025-11-19 03:53:48 -05:00
1 parent 6886272913
commit 34acccd5a8
2 files changed
+9 -5

No files matched your search

@@ -650,6 +650,7 @@ index 0000000000000000000000000000000000000000..0dd3374468e05f7a312ba5856b9cf8a4
+
+ private static final YamlFile config = new YamlFile();
+ private static int updates = 0;
+ private static boolean saveRequired; // Purpur
+
+ private static ConfigurationSection convertToBukkit(org.simpleyaml.configuration.ConfigurationSection section) {
+ ConfigurationSection newSection = new MemoryConfiguration();
@@ -673,6 +674,7 @@ index 0000000000000000000000000000000000000000..0dd3374468e05f7a312ba5856b9cf8a4
+
+ public static void load() throws IOException {
+ File configFile = new File("pufferfish.yml");
+ saveRequired = !configFile.exists(); // Purpur
+
+ if (configFile.exists()) {
+ try {
@@ -703,7 +705,9 @@ index 0000000000000000000000000000000000000000..0dd3374468e05f7a312ba5856b9cf8a4
+
+ updates++;
+
+ config.save(configFile);
+ if (saveRequired) {
+ config.save(configFile);
+ }
+
+ // Attempt to detect vectorization
+ try {
@@ -735,6 +739,7 @@ index 0000000000000000000000000000000000000000..0dd3374468e05f7a312ba5856b9cf8a4
+ if (!config.contains(key)) {
+ config.set(key, defaultValue);
+ config.setComment(key, String.join("\n", comment), CommentType.BLOCK);
+ saveRequired = true; // Purpur
+ }
+ }
+
@@ -8,10 +8,9 @@ diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java b/src/
index 5c691db595ee412b77f729e90172bc4f8ae57226..47e77541e558e18758ae0fcc2aa4e47261e928b6 100644
--- a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
+++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
@@ -28,6 +28,7 @@ public class PufferfishConfig {
private static final YamlFile config = new YamlFile();
@@ -29,6 +29,7 @@ public class PufferfishConfig {
private static int updates = 0;
private static boolean saveRequired; // Purpur
+ public static File pufferfishFile; // Purpur
private static ConfigurationSection convertToBukkit(org.simpleyaml.configuration.ConfigurationSection section) {
@@ -21,7 +20,7 @@ index 5c691db595ee412b77f729e90172bc4f8ae57226..47e77541e558e18758ae0fcc2aa4e472
public static void load() throws IOException {
- File configFile = new File("pufferfish.yml");
+ File configFile = pufferfishFile; // Purpur
+ File configFile = pufferfishFile != null ? pufferfishFile : new File("pufferfish.yml"); // Purpur
if (configFile.exists()) {
try {