9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-23 08:59:23 +00:00

Add back Linear region format

This commit is contained in:
Dreeam
2024-07-20 15:07:42 +08:00
parent ff0edf706c
commit 02125666c1
43 changed files with 105 additions and 75 deletions

View File

@@ -3,6 +3,8 @@ From: Triassic <techbyteofficial9@gmail.com>
Date: Fri, 22 Sep 2023 23:27:14 +0300
Subject: [PATCH] LinearPurpur: Add Linear region format
Removed since it's old version of Linear region format impeachment
Original license: MIT
Original project: https://github.com/StupidCraft/LinearPurpur

View File

@@ -3,6 +3,8 @@ From: Xymb <xymb@endcrystal.me>
Date: Sat, 9 Dec 2023 23:06:25 +0100
Subject: [PATCH] LinearPurpur: Just remove all locks on region files
Removed since it's old version of Linear region format impeachment
Original license: MIT
Original project: https://github.com/StupidCraft/LinearPurpur

View File

@@ -1,16 +1,23 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
Date: Sun, 30 Jun 2024 00:35:19 +0800
Subject: [PATCH] Linear-region-file-format
Subject: [PATCH] Linear region file format
Original license: MIT
Original project: https://github.com/LuminolMC/Luminol
Linear is a region file format that uses ZSTD compression instead of
ZLIB.
This format saves about 50% of disk space.
Documentation: https://github.com/xymb-endcrystalme/LinearRegionFileFormatTools
diff --git a/build.gradle.kts b/build.gradle.kts
index 49a3b6892b3e075f393e4ed8e4e0d5afc4798db5..d83e9365287a497a997cdb0e5d608635a739528c 100644
index 2dde13d18112b3f5a356546a59aca06bf6771a58..8ca21359f9be43d59417448554a9aaebd5140094 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -28,6 +28,11 @@ dependencies {
implementation("com.github.ben-manes.caffeine:caffeine:3.1.8")
// Leaf end
@@ -21,6 +21,11 @@ dependencies {
}
// Leaf end - Leaf Config
+ // LinearPaper start
+ implementation("com.github.luben:zstd-jni:1.5.6-3")
@@ -36,10 +43,10 @@ index 73df26b27146bbad2106d57b22dd3c792ed3dd1d..d2f209dd61f4412478a4b8fbe3489787
}
diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/RegionFileIOThread.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/RegionFileIOThread.java
index c833f78d083b8f661087471c35bc90f65af1b525..25bd2a98f494f9b3d16032ccee70f2e36ecf1069 100644
index 3218cbf84f54daf06e84442d5eb1a36d8da6b215..ec9b27177dc526510e86d85f48f167b44c01ac62 100644
--- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/RegionFileIOThread.java
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/RegionFileIOThread.java
@@ -1042,9 +1042,9 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
@@ -1043,9 +1043,9 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
return ((ChunkSystemRegionFileStorage)(Object)this.getCache()).moonrise$doesRegionFileNotExistNoIO(chunkX, chunkZ);
}
@@ -51,7 +58,7 @@ index c833f78d083b8f661087471c35bc90f65af1b525..25bd2a98f494f9b3d16032ccee70f2e3
synchronized (cache) {
try {
if (existingOnly) {
@@ -1060,9 +1060,9 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
@@ -1061,9 +1061,9 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
}
}
@@ -64,10 +71,10 @@ index c833f78d083b8f661087471c35bc90f65af1b525..25bd2a98f494f9b3d16032ccee70f2e3
synchronized (cache) {
regionFile = ((ChunkSystemRegionFileStorage)(Object)cache).moonrise$getRegionFileIfLoaded(chunkX, chunkZ);
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index ef14203da6f9d0f5cad4335c98095522209023cd..f9704361f1d480071ae07b0cb48c9851396f8ffa 100644
index c5fa13527dc1729f7cbb15067b4edf449c2f6fb1..b39f743e008a26b8d5ca88b6175b50ffcb8e3c99 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -904,10 +904,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -966,10 +966,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
while (iterator1.hasNext()) {
ServerLevel worldserver2 = (ServerLevel) iterator1.next();
@@ -81,7 +88,7 @@ index ef14203da6f9d0f5cad4335c98095522209023cd..f9704361f1d480071ae07b0cb48c9851
return flag3;
diff --git a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
index 0382b6597a130d746f8954a93a756a9d1ac81d50..5dff9e480a885a08f5ac59b83e0ef1ba2a8074a8 100644
index cb39c629af1827078f35904a373d35a63fea17ff..dc41c7c4616fa925427cd5a862f3923c5fa65902 100644
--- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
+++ b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
@@ -76,7 +76,7 @@ public class WorldUpgrader {
@@ -93,7 +100,7 @@ index 0382b6597a130d746f8954a93a756a9d1ac81d50..5dff9e480a885a08f5ac59b83e0ef1ba
final DimensionDataStorage overworldDataStorage;
public WorldUpgrader(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, RegistryAccess dynamicRegistryManager, boolean eraseCache, boolean recreateRegionFiles) {
@@ -394,7 +394,7 @@ public class WorldUpgrader {
@@ -400,7 +400,7 @@ public class WorldUpgrader {
private static List<WorldUpgrader.FileToUpgrade> getAllChunkPositions(RegionStorageInfo key, Path regionDirectory) {
File[] afile = regionDirectory.toFile().listFiles((file, s) -> {
@@ -102,7 +109,7 @@ index 0382b6597a130d746f8954a93a756a9d1ac81d50..5dff9e480a885a08f5ac59b83e0ef1ba
});
if (afile == null) {
@@ -414,7 +414,7 @@ public class WorldUpgrader {
@@ -420,7 +420,7 @@ public class WorldUpgrader {
List<ChunkPos> list1 = Lists.newArrayList();
try {
@@ -111,7 +118,7 @@ index 0382b6597a130d746f8954a93a756a9d1ac81d50..5dff9e480a885a08f5ac59b83e0ef1ba
try {
for (int i1 = 0; i1 < 32; ++i1) {
@@ -477,7 +477,7 @@ public class WorldUpgrader {
@@ -483,7 +483,7 @@ public class WorldUpgrader {
protected abstract boolean tryProcessOnePosition(T storage, ChunkPos chunkPos, ResourceKey<Level> worldKey);
@@ -120,7 +127,7 @@ index 0382b6597a130d746f8954a93a756a9d1ac81d50..5dff9e480a885a08f5ac59b83e0ef1ba
if (WorldUpgrader.this.recreateRegionFiles) {
if (this.previousWriteFuture != null) {
this.previousWriteFuture.join();
@@ -502,7 +502,7 @@ public class WorldUpgrader {
@@ -508,7 +508,7 @@ public class WorldUpgrader {
}
}
@@ -130,7 +137,7 @@ index 0382b6597a130d746f8954a93a756a9d1ac81d50..5dff9e480a885a08f5ac59b83e0ef1ba
}
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
index e761b63eebc1e76b2bb1cb887d83d0b63ad6ec90..18c06a3a261d6f1488c64a9e77cc88e6eaabf263 100644
index 6d864396f72220d9c92733a38ff6f2fd235238f5..66fadf8b6e01624272bcf303979687f9d9418402 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
@@ -28,7 +28,7 @@ import net.minecraft.nbt.NbtIo; // Paper
@@ -142,7 +149,16 @@ index e761b63eebc1e76b2bb1cb887d83d0b63ad6ec90..18c06a3a261d6f1488c64a9e77cc88e6
private static final Logger LOGGER = LogUtils.getLogger();
private static final int SECTOR_BYTES = 4096;
@@ -465,10 +465,10 @@ public class RegionFile implements AutoCloseable {
@@ -129,7 +129,7 @@ public class RegionFile implements AutoCloseable {
}
// note: only call for CHUNK regionfiles
- boolean recalculateHeader() throws IOException {
+ public boolean recalculateHeader() throws IOException { // LinearPaper - make public
if (!this.canRecalcHeader) {
return false;
}
@@ -928,10 +928,10 @@ public class RegionFile implements AutoCloseable {
private static int getChunkIndex(int x, int z) {
return (x & 31) + (z & 31) * 32;
}
@@ -155,7 +171,7 @@ index e761b63eebc1e76b2bb1cb887d83d0b63ad6ec90..18c06a3a261d6f1488c64a9e77cc88e6
final int offset = getChunkIndex(x, z);
boolean previous = this.oversized[offset] == 1;
this.oversized[offset] = (byte) (oversized ? 1 : 0);
@@ -507,7 +507,7 @@ public class RegionFile implements AutoCloseable {
@@ -970,7 +970,7 @@ public class RegionFile implements AutoCloseable {
return this.path.getParent().resolve(this.path.getFileName().toString().replaceAll("\\.mca$", "") + "_oversized_" + x + "_" + z + ".nbt");
}
@@ -165,7 +181,7 @@ index e761b63eebc1e76b2bb1cb887d83d0b63ad6ec90..18c06a3a261d6f1488c64a9e77cc88e6
try (DataInputStream out = new DataInputStream(new java.io.BufferedInputStream(new InflaterInputStream(Files.newInputStream(file))))) {
return NbtIo.read((java.io.DataInput) out);
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
index e8f0f0e2b3afd305afb6cf4d41f4fc31bf2bc68d..6c565c70de9a63ba897e582425e775fbe29dbb38 100644
index 54f7aa95cfbcf39bb86ad1b4eb0f9ff2f8526030..7c4b81e97562bb158478c70dae082526413cd534 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
@@ -21,7 +21,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -217,8 +233,17 @@ index e8f0f0e2b3afd305afb6cf4d41f4fc31bf2bc68d..6c565c70de9a63ba897e582425e775fb
this.regionCache.putAndMoveToFirst(key, ret);
@@ -112,7 +116,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
this.info = storageKey;
@@ -115,7 +119,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@Nullable
public static ChunkPos getRegionFileCoordinates(Path file) {
String fileName = file.getFileName().toString();
- if (!fileName.startsWith("r.") || !fileName.endsWith(".mca")) {
+ if (!fileName.startsWith("r.") || !fileName.endsWith(".mca") || !fileName.endsWith(".linear")) { // LinearPaper
return null;
}
@@ -143,7 +147,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
this.isChunkData = isChunkDataFolder(this.folder); // Paper - recalculate region file headers
}
- public RegionFile getRegionFile(ChunkPos chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit // Paper - public
@@ -226,7 +251,7 @@ index e8f0f0e2b3afd305afb6cf4d41f4fc31bf2bc68d..6c565c70de9a63ba897e582425e775fb
// Paper start - rewrite chunk system
if (existingOnly) {
return this.moonrise$getRegionFileIfExists(chunkcoordintpair.x, chunkcoordintpair.z);
@@ -120,7 +124,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -151,7 +155,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
synchronized (this) {
final long key = ChunkPos.asLong(chunkcoordintpair.x >> REGION_SHIFT, chunkcoordintpair.z >> REGION_SHIFT);
@@ -235,7 +260,7 @@ index e8f0f0e2b3afd305afb6cf4d41f4fc31bf2bc68d..6c565c70de9a63ba897e582425e775fb
if (ret != null) {
return ret;
}
@@ -129,13 +133,13 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -160,13 +164,13 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
this.regionCache.removeLast().close();
}
@@ -251,7 +276,7 @@ index e8f0f0e2b3afd305afb6cf4d41f4fc31bf2bc68d..6c565c70de9a63ba897e582425e775fb
this.regionCache.putAndMoveToFirst(key, ret);
@@ -155,7 +159,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -186,7 +190,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
// Gale end - branding changes
}
@@ -260,7 +285,7 @@ index e8f0f0e2b3afd305afb6cf4d41f4fc31bf2bc68d..6c565c70de9a63ba897e582425e775fb
synchronized (regionfile) {
try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) {
CompoundTag oversizedData = regionfile.getOversizedData(chunkCoordinate.x, chunkCoordinate.z);
@@ -190,7 +194,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -221,7 +225,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@Nullable
public CompoundTag read(ChunkPos pos) throws IOException {
// CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
@@ -269,7 +294,7 @@ index e8f0f0e2b3afd305afb6cf4d41f4fc31bf2bc68d..6c565c70de9a63ba897e582425e775fb
if (regionfile == null) {
return null;
}
@@ -241,7 +245,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -285,7 +289,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
public void scanChunk(ChunkPos chunkPos, StreamTagVisitor scanner) throws IOException {
// CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
@@ -278,7 +303,7 @@ index e8f0f0e2b3afd305afb6cf4d41f4fc31bf2bc68d..6c565c70de9a63ba897e582425e775fb
if (regionfile == null) {
return;
}
@@ -271,7 +275,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -315,7 +319,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
}
public void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException { // Paper - public
@@ -287,7 +312,7 @@ index e8f0f0e2b3afd305afb6cf4d41f4fc31bf2bc68d..6c565c70de9a63ba897e582425e775fb
// Paper start - rewrite chunk system
if (regionfile == null) {
// if the RegionFile doesn't exist, no point in deleting from it
@@ -330,7 +334,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -374,7 +378,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
// Paper start - rewrite chunk system
synchronized (this) {
final ExceptionCollector<IOException> exceptionCollector = new ExceptionCollector<>();
@@ -296,7 +321,7 @@ index e8f0f0e2b3afd305afb6cf4d41f4fc31bf2bc68d..6c565c70de9a63ba897e582425e775fb
try {
regionFile.close();
} catch (final IOException ex) {
@@ -347,7 +351,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -391,7 +395,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
// Paper start - rewrite chunk system
synchronized (this) {
final ExceptionCollector<IOException> exceptionCollector = new ExceptionCollector<>();
@@ -307,57 +332,55 @@ index e8f0f0e2b3afd305afb6cf4d41f4fc31bf2bc68d..6c565c70de9a63ba897e582425e775fb
} catch (final IOException ex) {
diff --git a/src/main/java/org/dreeam/leaf/config/modules/misc/RegionFormatConfig.java b/src/main/java/org/dreeam/leaf/config/modules/misc/RegionFormatConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..9efa36f9a18fafceb4fb184380d73e4271659a4f
index 0000000000000000000000000000000000000000..8b3e9c99312414e87bfe018516c25688c38548d2
--- /dev/null
+++ b/src/main/java/org/dreeam/leaf/config/modules/misc/RegionFormatConfig.java
@@ -0,0 +1,57 @@
@@ -0,0 +1,55 @@
+package org.dreeam.leaf.config.modules.misc;
+
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
+import com.mojang.logging.LogUtils;
+import org.dreeam.leaf.config.ConfigInfo;
+import org.dreeam.leaf.config.ConfigModules;
+import org.dreeam.leaf.config.DoNotLoad;
+import org.dreeam.leaf.config.EnumConfigCategory;
+import org.dreeam.leaf.config.IConfigModule;
+import org.slf4j.Logger;
+import org.stupidcraft.linearpaper.region.EnumRegionFileExtension;
+
+public class RegionFormatConfig implements IConfigModule {
+ @ConfigInfo(baseName = "region_format")
+ public static String regionFormatTypeName = "MCA";
+ @DoNotLoad
+ public static EnumRegionFileExtension regionFormatType = EnumRegionFileExtension.LINEAR;
+ @ConfigInfo(baseName = "linear_compress_level")
+ public static int linearCompressionLevel = 1;
+ @ConfigInfo(baseName = "thrown_on_unknown_extension_detected")
+ public static boolean throwOnUnknownExtension = false;
+ @ConfigInfo(baseName = "flush_interval_seconds")
+ public static int linearFlushFrequency = 5;
+public class RegionFormatConfig extends ConfigModules {
+
+ public String getBasePath() {
+ return EnumConfigCategory.MISC + ".region-format-settings";
+ }
+
+ @DoNotLoad
+ private static final Logger logger = LogUtils.getLogger();
+ @DoNotLoad
+ public static EnumRegionFileExtension regionFormatType;
+
+ public static String regionFormatTypeName = "MCA";
+ public static int linearCompressionLevel = 1;
+ public static boolean throwOnUnknownExtension = false;
+ public static int linearFlushFrequency = 5;
+
+ @Override
+ public EnumConfigCategory getCategory() {
+ return EnumConfigCategory.MISC;
+ }
+
+ @Override
+ public String getBaseName() {
+ return "region_format_settings";
+ }
+
+ @Override
+ public void onLoaded(CommentedFileConfig config) {
+ config.setComment("misc.region_format_settings", """
+ public void onLoaded() {
+ config.addComment(getBasePath(), """
+ Linear is a region file format that uses ZSTD compression instead of
+ ZLIB.
+ This format saves about 50% of disk space.
+ Documentation: https://github.com/xymb-endcrystalme/LinearRegionFileFormatTools
+ Read Documentation before using: https://github.com/xymb-endcrystalme/LinearRegionFileFormatTools
+ Disclaimer: This is an experimental feature, there is potential risk to lose chunk data.
+ So backup your server before switching to Linear.
+ """);
+
+ regionFormatTypeName = config.getString(getBasePath() + ".region-format", regionFormatTypeName,
+ "Available region formats: MCA, LINEAR");
+ linearCompressionLevel = config.getInt(getBasePath() + ".linear-compress-level", linearCompressionLevel);
+ throwOnUnknownExtension = config().getBoolean(getBasePath() + ".throw-on-unknown-extension-detected", throwOnUnknownExtension);
+ linearFlushFrequency = config.getInt(getBasePath() + ".flush-interval-seconds", linearFlushFrequency);
+
+ regionFormatType = EnumRegionFileExtension.fromName(regionFormatTypeName);
+ if (regionFormatType == EnumRegionFileExtension.UNKNOWN) {
+ logger.error("Unknown region file type {} ! Falling back to MCA file.", regionFormatTypeName);
+ logger.error("Unknown region file type {} ! Falling back to MCA format.", regionFormatTypeName);
+ regionFormatType = EnumRegionFileExtension.MCA;
+ }
+
@@ -370,7 +393,7 @@ index 0000000000000000000000000000000000000000..9efa36f9a18fafceb4fb184380d73e42
+}
diff --git a/src/main/java/org/stupidcraft/linearpaper/region/EnumRegionFileExtension.java b/src/main/java/org/stupidcraft/linearpaper/region/EnumRegionFileExtension.java
new file mode 100644
index 0000000000000000000000000000000000000000..d4ce2d17a7ab258cac3b91065ab3f56fba20d1b1
index 0000000000000000000000000000000000000000..8eba172be9bce7cccd27d27bee2d6c6f917a9e4e
--- /dev/null
+++ b/src/main/java/org/stupidcraft/linearpaper/region/EnumRegionFileExtension.java
@@ -0,0 +1,56 @@
@@ -415,7 +438,7 @@ index 0000000000000000000000000000000000000000..d4ce2d17a7ab258cac3b91065ab3f56f
+
+ @Contract(pure = true)
+ public static EnumRegionFileExtension fromExtension(@NotNull String name) {
+ switch (name) {
+ switch (name.toLowerCase()) {
+ case "mca" -> {
+ return MCA;
+ }
@@ -430,13 +453,12 @@ index 0000000000000000000000000000000000000000..d4ce2d17a7ab258cac3b91065ab3f56f
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/stupidcraft/linearpaper/region/IRegionFile.java b/src/main/java/org/stupidcraft/linearpaper/region/IRegionFile.java
new file mode 100644
index 0000000000000000000000000000000000000000..17db1bd619bc417cbd034e204600abbc506256ae
index 0000000000000000000000000000000000000000..6417f5b6daa35044995dd0aa9cfc24acd8ce4287
--- /dev/null
+++ b/src/main/java/org/stupidcraft/linearpaper/region/IRegionFile.java
@@ -0,0 +1,25 @@
@@ -0,0 +1,26 @@
+package org.stupidcraft.linearpaper.region;
+
+import java.io.DataInputStream;
@@ -457,6 +479,7 @@ index 0000000000000000000000000000000000000000..17db1bd619bc417cbd034e204600abbc
+ boolean hasChunk(ChunkPos pos);
+ boolean doesChunkExist(ChunkPos pos) throws Exception;
+ boolean isOversized(int x, int z);
+ boolean recalculateHeader() throws IOException;
+
+ DataOutputStream getChunkDataOutputStream(ChunkPos pos) throws IOException;
+ DataInputStream getChunkDataInputStream(ChunkPos pos) throws IOException;
@@ -464,7 +487,7 @@ index 0000000000000000000000000000000000000000..17db1bd619bc417cbd034e204600abbc
+}
diff --git a/src/main/java/org/stupidcraft/linearpaper/region/IRegionFileFactory.java b/src/main/java/org/stupidcraft/linearpaper/region/IRegionFileFactory.java
new file mode 100644
index 0000000000000000000000000000000000000000..08c9b5d31408ddcb9dce4244cae8dfb22c84d20a
index 0000000000000000000000000000000000000000..70552d63a84a4d3a73348d0dffacd89ca8f5df0f
--- /dev/null
+++ b/src/main/java/org/stupidcraft/linearpaper/region/IRegionFileFactory.java
@@ -0,0 +1,52 @@
@@ -504,7 +527,7 @@ index 0000000000000000000000000000000000000000..08c9b5d31408ddcb9dce4244cae8dfb2
+ switch (EnumRegionFileExtension.fromExtension(extensionName)) {
+ case UNKNOWN -> {
+ if (RegionFormatConfig.throwOnUnknownExtension) {
+ throw new IllegalArgumentException("Unknown region file extension for file: " + fullFileName +"!");
+ throw new IllegalArgumentException("Unknown region file extension for file: " + fullFileName + "!");
+ }
+
+ return new RegionFile(storageKey, path, directory, compressionFormat, dsync);
@@ -520,18 +543,18 @@ index 0000000000000000000000000000000000000000..08c9b5d31408ddcb9dce4244cae8dfb2
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/stupidcraft/linearpaper/region/LinearRegionFile.java b/src/main/java/org/stupidcraft/linearpaper/region/LinearRegionFile.java
new file mode 100644
index 0000000000000000000000000000000000000000..c141fc6e4f4ba9bb9971b4f33886ed206b768e86
index 0000000000000000000000000000000000000000..d2cbdd75f02d377a7680288bb1154d51dbc6bc51
--- /dev/null
+++ b/src/main/java/org/stupidcraft/linearpaper/region/LinearRegionFile.java
@@ -0,0 +1,294 @@
@@ -0,0 +1,299 @@
+package org.stupidcraft.linearpaper.region;
+
+import com.github.luben.zstd.ZstdInputStream;
+import com.github.luben.zstd.ZstdOutputStream;
+import com.mojang.logging.LogUtils;
+
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
@@ -796,6 +819,10 @@ index 0000000000000000000000000000000000000000..c141fc6e4f4ba9bb9971b4f33886ed20
+ flush(); // sync
+ }
+
+ public boolean recalculateHeader() {
+ return false;
+ }
+
+ public void setOversized(int x, int z, boolean something) {
+ }
+
@@ -821,4 +848,3 @@ index 0000000000000000000000000000000000000000..c141fc6e4f4ba9bb9971b4f33886ed20
+ }
+ }
+}
\ No newline at end of file

View File

@@ -75,7 +75,7 @@ index c03608fec96b51e1867f43d8f42e5aefb1520e46..15b21fa3907db1b77ed5b5d1050a37f4
throw new IllegalStateException("Ticking retired scheduler");
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index c5fa13527dc1729f7cbb15067b4edf449c2f6fb1..dd5ef3b8059d38f2e5f4acc2c49607f71c1ce1e5 100644
index b39f743e008a26b8d5ca88b6175b50ffcb8e3c99..8d68a765621d37bd3e1f140a17e3f53bf294cfe7 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -312,6 +312,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa

View File

@@ -5,12 +5,12 @@ Subject: [PATCH] Cache player profileResult
diff --git a/build.gradle.kts b/build.gradle.kts
index 2dde13d18112b3f5a356546a59aca06bf6771a58..0f912a277655a8ddf08b6c1f7717a5226326f9bb 100644
index 8ca21359f9be43d59417448554a9aaebd5140094..6b72333bd753fcbc7fc244bedddbb31a2d20f594 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -21,6 +21,10 @@ dependencies {
}
// Leaf end - Leaf Config
@@ -26,6 +26,10 @@ dependencies {
implementation("org.lz4:lz4-java:1.8.0")
// LinearPaper end
+ // Leaf start - Libraries
+ implementation("com.github.ben-manes.caffeine:caffeine:3.1.8")