106 lines
5.0 KiB
Diff
106 lines
5.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
|
Date: Fri, 10 Feb 2023 20:03:58 +0200
|
|
Subject: [PATCH] Region format configuration
|
|
|
|
|
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
|
index 7da7e0aeb5eac9ac73a3570e716f1ceb11fd7027..f08bcc9ae1770fa847d8a5e873a554bef5485100 100644
|
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
|
@@ -192,4 +192,7 @@ public class KaiijuConfig {
|
|
}
|
|
return builder.build();
|
|
}
|
|
+
|
|
+ private static void regionFormatSettings() {
|
|
+ }
|
|
}
|
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
|
index 87ca934473f3b9553c1b9b3ed60e0fa07838c711..a6e7af5f4148e067660e9f5beeacde3a59a1de9c 100644
|
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
|
|
@@ -1,12 +1,15 @@
|
|
package dev.kaiijumc.kaiiju;
|
|
|
|
+import dev.kaiijumc.kaiiju.region.RegionFileFormat;
|
|
import org.apache.commons.lang.BooleanUtils;
|
|
import org.bukkit.World;
|
|
import org.bukkit.configuration.ConfigurationSection;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.function.Predicate;
|
|
+import java.util.logging.Level;
|
|
|
|
import static dev.kaiijumc.kaiiju.KaiijuConfig.log;
|
|
|
|
@@ -122,4 +125,22 @@ public class KaiijuWorldConfig {
|
|
final Map<String, Object> value = getMap("world-settings." + worldName + "." + path, null);
|
|
return value.isEmpty() ? fallback : value;
|
|
}
|
|
+
|
|
+ public RegionFileFormat regionFormatName = RegionFileFormat.ANVIL;
|
|
+ public int regionFormatLinearCompressionLevel = 1;
|
|
+
|
|
+ private void regionFormatSettings() {
|
|
+ regionFormatName = RegionFileFormat.fromString(getString("region-format.format", regionFormatName.name()));
|
|
+ if (regionFormatName.equals(RegionFileFormat.INVALID)) {
|
|
+ log(Level.SEVERE, "Unknown region format in kaiiju.yml: " + regionFormatName);
|
|
+ log(Level.SEVERE, "Falling back to ANVIL region file format.");
|
|
+ regionFormatName = RegionFileFormat.ANVIL;
|
|
+ }
|
|
+ regionFormatLinearCompressionLevel = getInt("region-format.linear.compression-level", regionFormatLinearCompressionLevel);
|
|
+ if (regionFormatLinearCompressionLevel > 23 || regionFormatLinearCompressionLevel < 1) {
|
|
+ log(Level.SEVERE, "Linear region compression level should be between 1 and 22 in kaiiju.yml: " + regionFormatLinearCompressionLevel);
|
|
+ log(Level.SEVERE, "Falling back to compression level 1.");
|
|
+ regionFormatLinearCompressionLevel = 1;
|
|
+ }
|
|
+ }
|
|
}
|
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/RegionFileFormat.java b/src/main/java/dev/kaiijumc/kaiiju/region/RegionFileFormat.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..7164d9cd03186f0657783f83de3d6435cda2b17e
|
|
--- /dev/null
|
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/RegionFileFormat.java
|
|
@@ -0,0 +1,16 @@
|
|
+package dev.kaiijumc.kaiiju.region;
|
|
+
|
|
+public enum RegionFileFormat {
|
|
+ ANVIL,
|
|
+ LINEAR,
|
|
+ INVALID;
|
|
+
|
|
+ public static RegionFileFormat fromString(String format) {
|
|
+ for (RegionFileFormat rff : values()) {
|
|
+ if (rff.name().equalsIgnoreCase(format)) {
|
|
+ return rff;
|
|
+ }
|
|
+ }
|
|
+ return RegionFileFormat.INVALID;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index a6f1068884669cfedfe8df40506b011b8b411489..7243443d4bf24ad0b32b8a76d9b8701cca8612a7 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -892,7 +892,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
// Paper start - rewrite chunk system
|
|
worldserver.save((ProgressListener) null, flush, worldserver.noSave && !force, close);
|
|
if (flush) {
|
|
- MinecraftServer.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", worldserver.getChunkSource().chunkMap.getStorageName());
|
|
+ MinecraftServer.LOGGER.info("ThreadedChunkStorage ({}): All chunks are saved", worldserver.getChunkSource().chunkMap.getStorageName()); // Kaiiju
|
|
}
|
|
// Paper end - rewrite chunk system
|
|
}
|
|
@@ -916,7 +916,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
//MinecraftServer.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", worldserver2.getChunkSource().chunkMap.getStorageName()); // Paper - move up
|
|
}
|
|
|
|
- MinecraftServer.LOGGER.info("ThreadedAnvilChunkStorage: All dimensions are saved");
|
|
+ MinecraftServer.LOGGER.info("ThreadedChunkStorage: All dimensions are saved"); // Kaiiju
|
|
}
|
|
|
|
return flag3;
|