Skip to content

Commit

Permalink
Add compression level to linear region format
Browse files Browse the repository at this point in the history
  • Loading branch information
sofianedjerbi committed Feb 15, 2023
1 parent ffbcddc commit dfa8a7b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
5 changes: 3 additions & 2 deletions patches/server/0002-Kaiiju-Configuration.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Subject: [PATCH] Kaiiju Configuration

diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..da7e04a93664e20b9187292ddb7c1f935f5f2883
index 0000000000000000000000000000000000000000..ef48d534d239fc5fcfd1b0500cc7868c1cf63142
--- /dev/null
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -0,0 +1,193 @@
@@ -0,0 +1,194 @@
+package dev.kaiijumc.kaiiju;
+
+import com.google.common.base.Throwables;
Expand All @@ -27,6 +27,7 @@ index 0000000000000000000000000000000000000000..da7e04a93664e20b9187292ddb7c1f93
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
Expand Down
15 changes: 4 additions & 11 deletions patches/server/0003-Kaiiju-RegionFormat-Configuration.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,10 @@ Subject: [PATCH] Kaiiju RegionFormat Configuration


diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
index da7e04a93664e20b9187292ddb7c1f935f5f2883..66bbab7ebe1738cd937963b35fad9cdda763fa88 100644
index ef48d534d239fc5fcfd1b0500cc7868c1cf63142..328fbed775c26faa9a87171bfda68d8ee977a889 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -15,6 +15,7 @@ import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -190,4 +191,15 @@ public class KaiijuConfig {
@@ -191,4 +191,16 @@ public class KaiijuConfig {
}
return builder.build();
}
Expand All @@ -27,8 +19,9 @@ index da7e04a93664e20b9187292ddb7c1f935f5f2883..66bbab7ebe1738cd937963b35fad9cdd
+ private static void regionFormatSettings() {
+ regionFormatName = getString("region-format.format", regionFormatName).toUpperCase();
+ if (!regionFormatList.contains(regionFormatName)) {
+ Bukkit.getLogger().log(Level.SEVERE, "Unknown region format in fusion.yml: " + regionFormatName);
+ Bukkit.getLogger().log(Level.SEVERE, "Unknown region format in kaiiju.yml: " + regionFormatName);
+ Bukkit.getLogger().log(Level.SEVERE, "Falling back to ANVIL region file format.");
+ regionFormatName = "ANVIL";
+ }
+ }
}
Expand Down
31 changes: 23 additions & 8 deletions patches/server/0004-Kaiiju-RegionFormat-Linear.patch
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ Copyright [email protected]
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

diff --git a/build.gradle.kts b/build.gradle.kts
index c6a4c48b14a8c927284720b79b93ee1aa9df7da6..2ea3d2f26d4547ea5094cc63d492ea1406ffbd44 100644
index c6a4c48b14a8c927284720b79b93ee1aa9df7da6..cc727f183e0a2058c0b785efa9a95545b5ceb32a 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -13,6 +13,10 @@ dependencies {
exclude("io.papermc.paper", "paper-api")
}
// Pufferfish end
+ // Kaiiju start - Linear format
+ implementation("com.github.luben:zstd-jni:1.5.2-5")
+ implementation("com.github.luben:zstd-jni:1.5.4-1")
+ implementation("org.lz4:lz4-java:1.8.0")
+ // Kaiiju end
// Paper start
Expand All @@ -38,18 +38,33 @@ index f2c27e0ac65be4b75c1d86ef6fd45fdb538d96ac..00724993d0448454d14a47652b039b88
public static final class InProgressWrite {
public long writeCounter;
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
index 66bbab7ebe1738cd937963b35fad9cdda763fa88..16ebf32e0c62025958c95216531f72cc418e8d14 100644
index 328fbed775c26faa9a87171bfda68d8ee977a889..f5c9a42b98dceda2355a28591c59c383e7906421 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -192,7 +192,7 @@ public class KaiijuConfig {
@@ -192,8 +192,9 @@ public class KaiijuConfig {
return builder.build();
}

- public static List<String> regionFormatList = Arrays.asList("ANVIL");
+ public static List<String> regionFormatList = Arrays.asList("ANVIL", "LINEAR");
public static String regionFormatName = "ANVIL";
+ public static int regionFormatLinearCompressionLevel = 1;

private static void regionFormatSettings() {
regionFormatName = getString("region-format.format", regionFormatName).toUpperCase();
@@ -202,5 +203,11 @@ public class KaiijuConfig {
Bukkit.getLogger().log(Level.SEVERE, "Falling back to ANVIL region file format.");
regionFormatName = "ANVIL";
}
+ regionFormatLinearCompressionLevel = getInt("region-format.linear.compression-level", regionFormatLinearCompressionLevel);
+ if (regionFormatLinearCompressionLevel > 23 || regionFormatLinearCompressionLevel < 1) {
+ Bukkit.getLogger().log(Level.SEVERE, "Linear region compression level should be between 1 and 22 in kaiiju.yml: " + regionFormatLinearCompressionLevel);
+ Bukkit.getLogger().log(Level.SEVERE, "Falling back to compression level 1.");
+ regionFormatLinearCompressionLevel = 1;
+ }
}
}
\ No newline at end of file
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFile.java b/src/main/java/dev/kaiijumc/kaiiju/region/AbstractRegionFile.java
new file mode 100644
index 0000000000000000000000000000000000000000..70d53d80f474eb80acc93275ad6bf1da98ea8ae7
Expand Down Expand Up @@ -134,7 +149,7 @@ index 0000000000000000000000000000000000000000..0b84b1aa4b822bdcb783285e8ea99a4f
+}
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java
new file mode 100644
index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52573d1944
index 0000000000000000000000000000000000000000..0beed445c120e2ce299d4ec54a9f09389adb8e91
--- /dev/null
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java
@@ -0,0 +1,338 @@
Expand All @@ -143,7 +158,7 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
+import com.github.luben.zstd.ZstdInputStream;
+import com.github.luben.zstd.ZstdOutputStream;
+import com.mojang.logging.LogUtils;
+import net.jpountz.lz4.LZ4Compressor;
+import dev.kaiijumc.kaiiju.KaiijuConfig;import net.jpountz.lz4.LZ4Compressor;
+import net.jpountz.lz4.LZ4Factory;
+import net.jpountz.lz4.LZ4FastDecompressor;
+import net.jpountz.xxhash.XXHashFactory;
Expand Down Expand Up @@ -173,7 +188,7 @@ index 0000000000000000000000000000000000000000..ba4910d564064a1367cb9d727e8fcc52
+ private boolean close = false;
+ public Path regionFile;
+ public final ReentrantLock fileLock = new ReentrantLock(true);
+ final byte COMPRESSION_LEVEL = 1;
+ final byte COMPRESSION_LEVEL = (byte) KaiijuConfig.regionFormatLinearCompressionLevel;
+
+ public Path getRegionFile() {
+ return this.regionFile;
Expand Down Expand Up @@ -903,7 +918,7 @@ index bd502ca721de0cab438d995efa00ad0554c0d2fe..37242c6225795271e0ba6a853252f2da
regionfile.flush();
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index b17bc6482d2bd97d2e48d3967dea72605cf13164..2a13629ffb60dc60706da446e6dc7f3683d0410b 100644
index 9b5323edd99848b73ea0e34230e7bec8dc23be8c..619c7713d573e8f438ea23a3fcb185a98abf5100 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -552,7 +552,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
Expand Down

0 comments on commit dfa8a7b

Please sign in to comment.