Skip to content

Commit

Permalink
Linear region file format
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yh-china committed Jan 14, 2024
1 parent 6b7f2c5 commit 360d66c
Show file tree
Hide file tree
Showing 2 changed files with 1,076 additions and 32 deletions.
113 changes: 81 additions & 32 deletions patches/server/0005-Leaves-Server-Config-And-Command.patch
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ index 01d907e3266095bb33d3a73dc56004fd79043943..06c00aa070334deeae96524b35ff1295
.withRequiredArg()
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..f6821b1f760dcf2a504c8bdf845e469f7041537a
index 0000000000000000000000000000000000000000..82376b6a310ccdc9d813e20482ea7841c7ea7cf1
--- /dev/null
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -0,0 +1,815 @@
@@ -0,0 +1,864 @@
+package top.leavesmc.leaves;
+
+import com.destroystokyo.paper.util.SneakyThrow;
Expand Down Expand Up @@ -226,9 +226,9 @@ index 0000000000000000000000000000000000000000..f6821b1f760dcf2a504c8bdf845e469f
+ MinecraftServer.getServer().server.getCommandMap().getKnownCommands().remove(name);
+ }
+
+ // Leaves - modify start
+ // Leaves start - modify
+
+ // Leaves - modify - fakeplayer start
+ // Leaves start - modify - fakeplayer
+
+ @GlobalConfig(name = "enable", category = {"modify", "fakeplayer"}, verify = FakeplayerVerify.class)
+ public static boolean fakeplayerSupport = true;
Expand Down Expand Up @@ -283,9 +283,9 @@ index 0000000000000000000000000000000000000000..f6821b1f760dcf2a504c8bdf845e469f
+ }
+ }
+
+ // Leaves - modify - fakeplayer end
+ // Leaves end - modify - fakeplayer
+
+ // Leaves - modify - minecraft-old start
+ // Leaves start - modify - minecraft-old
+
+ @GlobalConfig(name = "shears-in-dispenser-can-zero-amount", category = {"modify", "minecraft-old"})
+ public static boolean shearsInDispenserCanZeroAmount = false;
Expand Down Expand Up @@ -336,9 +336,9 @@ index 0000000000000000000000000000000000000000..f6821b1f760dcf2a504c8bdf845e469f
+ }
+ }
+
+ // Leaves - modify - minecraft-old end
+ // Leaves end - modify - minecraft-old
+
+ // Leaves - modify - elytra-aeronautics start
+ // Leaves start - modify - elytra-aeronautics
+
+ @GlobalConfig(name = "no-chunk-load", category = {"modify", "elytra-aeronautics"})
+ public static boolean elytraAeronauticsNoChunk = false;
Expand All @@ -358,7 +358,7 @@ index 0000000000000000000000000000000000000000..f6821b1f760dcf2a504c8bdf845e469f
+ @GlobalConfig(name = "message-end", category = {"modify", "elytra-aeronautics"}, verify = ConfigVerify.StringConfigVerify.class)
+ public static String elytraAeronauticsNoChunkEndMes = "Flight exit cruise mode";
+
+ // Leaves - modify - elytra-aeronautics end
+ // Leaves end - modify - elytra-aeronautics
+
+ @GlobalConfig(name = "redstone-shears-wrench", category = "modify")
+ public static boolean redstoneShearsWrench = true;
Expand Down Expand Up @@ -537,29 +537,29 @@ index 0000000000000000000000000000000000000000..f6821b1f760dcf2a504c8bdf845e469f
+ }
+ }
+
+ // Leaves - modify removed start
+ // Leaves start - modify - removed
+
+ @RemovedConfig
+ @GlobalConfig(name = "tick-command", category = "modify")
+ public static boolean tickCommand = false;
+
+ // Leaves - modify removed end
+ // Leaves end - modify - removed
+
+ // Leaves - modify end
+ // Leaves end - modify
+
+ // Leaves - performance start
+ // Leaves start - performance
+
+ // Leaves - performance fix start
+ // Leaves start - performance - fix
+
+ @GlobalConfig(name = "fix-paper-6045", category = {"performance", "fix"})
+ public static boolean fixPaper6045 = true;
+
+ @GlobalConfig(name = "fix-paper-9372", category = {"performance", "fix"})
+ public static boolean fixPaper9372 = true;
+
+ // Leaves - performance fix end
+ // Leaves end - performance - fix
+
+ // Leaves - performance remove start
+ // Leaves start - performance - remove
+
+ @GlobalConfig(name = "tick-guard-lambda", category = {"performance", "remove"})
+ public static boolean removeTickGuardLambda = true;
Expand All @@ -576,7 +576,7 @@ index 0000000000000000000000000000000000000000..f6821b1f760dcf2a504c8bdf845e469f
+ @GlobalConfig(name = "damage-lambda", category = {"performance", "remove"})
+ public static boolean removeDamageLambda = true;
+
+ // Leaves - performance remove end
+ // Leaves end - performance - remove
+
+ @GlobalConfig(name = "optimized-dragon-respawn", category = "performance")
+ public static boolean optimizedDragonRespawn = false;
Expand Down Expand Up @@ -683,7 +683,7 @@ index 0000000000000000000000000000000000000000..f6821b1f760dcf2a504c8bdf845e469f
+ @GlobalConfig(name = "fix-villagers-dont-release-memory", category = "performance")
+ public static boolean villagersDontReleaseMemoryFix = false;
+
+ // Leaves - performance removed start
+ // Leaves start - performance - removed
+
+ @RemovedConfig
+ @GlobalConfig(name = "async-pathfinding", category = "performance")
Expand All @@ -697,13 +697,13 @@ index 0000000000000000000000000000000000000000..f6821b1f760dcf2a504c8bdf845e469f
+ @GlobalConfig(name = "async-entity-tracker", category = "performance")
+ public static boolean asyncEntityTracker = false;
+
+ // Leaves - performance removed end
+ // Leaves end - performance - removed
+
+ // Leaves - performance end
+ // Leaves end - performance
+
+ // Leaves - protocol start
+ // Leaves start - protocol
+
+ // Leaves - protocol bladeren start
+ // Leaves start - protocol - bladeren
+
+ @GlobalConfig(name = "protocol", category = {"protocol", "bladeren"})
+ public static boolean bladerenLeavesProtocol = true;
Expand All @@ -729,9 +729,9 @@ index 0000000000000000000000000000000000000000..f6821b1f760dcf2a504c8bdf845e469f
+ }
+ }
+
+ // Leaves - protocol bladeren end
+ // Leaves end - protocol - bladeren
+
+ // Leaves - protocol syncmatica start
+ // Leaves start - protocol - syncmatica
+
+ @GlobalConfig(name = "enable", category = {"protocol", "syncmatica"}, verify = SyncmaticaVerify.class)
+ public static boolean syncmaticaProtocol = false;
Expand All @@ -752,7 +752,7 @@ index 0000000000000000000000000000000000000000..f6821b1f760dcf2a504c8bdf845e469f
+ }
+ }
+
+ // Leaves - protocol syncmatica end
+ // Leaves end - protocol - syncmatica
+
+ @GlobalConfig(name = "pca-sync-protocol", category = "protocol")
+ public static boolean pcaSyncProtocol = false;
Expand Down Expand Up @@ -809,11 +809,11 @@ index 0000000000000000000000000000000000000000..f6821b1f760dcf2a504c8bdf845e469f
+ @GlobalConfig(name = "leaves-carpet-support", category = "protocol")
+ public static boolean leavesCarpetSupport = false;
+
+ // Leaves - protocol end
+ // Leaves end - protocol
+
+ // Leaves - misc start
+ // Leaves start - misc
+
+ // Leaves - misc auto-update start
+ // Leaves start - misc - auto-update
+
+ @GlobalConfig(name = "enable", category = {"misc", "auto-update"}, lock = true, verify = AutoUpdateVerify.class)
+ public static boolean autoUpdate = false;
Expand All @@ -831,9 +831,9 @@ index 0000000000000000000000000000000000000000..f6821b1f760dcf2a504c8bdf845e469f
+ @GlobalConfig(name = "time", category = {"misc", "auto-update"}, lock = true, verify = ConfigVerify.ListConfigVerify.class)
+ public static List<String> autoUpdateTime = List.of("14:00", "2:00");
+
+ // Leaves - misc auto-update end
+ // Leaves end - misc - auto-update
+
+ // Leaves - misc extra-yggdrasil-service start
+ // Leaves start - misc - extra-yggdrasil-service
+
+ @GlobalConfig(name = "enable", category = {"misc", "extra-yggdrasil-service"}, verify = ExtraYggdrasilVerify.class)
+ public static boolean extraYggdrasilService = false;
Expand Down Expand Up @@ -863,7 +863,7 @@ index 0000000000000000000000000000000000000000..f6821b1f760dcf2a504c8bdf845e469f
+ }
+ }
+
+ // Leaves - misc extra-yggdrasil-service end
+ // Leaves end - misc - extra-yggdrasil-service
+
+ @GlobalConfig(name = "disable-method-profiler", category = "misc")
+ public static boolean disableMethodProfiler = true;
Expand Down Expand Up @@ -895,7 +895,56 @@ index 0000000000000000000000000000000000000000..f6821b1f760dcf2a504c8bdf845e469f
+ @GlobalConfig(name = "bstats-privacy-mode", category = "misc")
+ public static boolean bstatsPrivacyMode = false;
+
+ // Leaves - misc end
+ // Leaves end - misc
+
+ // Leaves start - region
+ public static top.leavesmc.leaves.region.RegionFileFormat regionFormatName = top.leavesmc.leaves.region.RegionFileFormat.ANVIL;
+ @GlobalConfig(name = "format", category = "region", lock = true, verify = RegionFormatVerify.class)
+ public static String regionFormat = "ANVIL";
+
+ private static class RegionFormatVerify extends ConfigVerify.StringConfigVerify {
+ @Override
+ public String check(String old, String value) {
+ top.leavesmc.leaves.region.RegionFileFormat format = top.leavesmc.leaves.region.RegionFileFormat.fromString(value);
+ if (format == top.leavesmc.leaves.region.RegionFileFormat.INVALID) {
+ return "Unknown region format " + value;
+ }
+ regionFormatName = format;
+ return null;
+ }
+ }
+
+ @GlobalConfig(name = "flush-frequency", category = {"region", "linear"}, lock = true, verify = ConfigVerify.IntConfigVerify.class)
+ public static int linearFlushFrequency = 10;
+
+ @GlobalConfig(name = "flush-max-threads", category = {"region", "linear"}, lock = true, verify = ConfigVerify.IntConfigVerify.class)
+ public static int linearFlushThreads = 1;
+
+ public static int getLinearFlushThreads() {
+ if (linearFlushThreads < 0) {
+ return Math.max(Runtime.getRuntime().availableProcessors() + linearFlushThreads, 1);
+ } else {
+ return Math.max(linearFlushThreads, 1);
+ }
+ }
+
+ @GlobalConfig(name = "compression-level", category = {"region", "linear"}, lock = true, verify = LinearCompressVerify.class)
+ public static int linearCompressionLevel = 1;
+
+ private static class LinearCompressVerify extends ConfigVerify.IntConfigVerify {
+ @Override
+ public String check(Integer old, Integer value) {
+ if (value < 1 || value > 22) {
+ return "linear.compression-level need between 1 and 22";
+ }
+ return null;
+ }
+ }
+
+ @GlobalConfig(name = "crash-on-broken-symlink", category = {"region", "linear"}, lock = true)
+ public static boolean linearCrashOnBrokenSymlink = true;
+
+ // Leaves end - region
+}
diff --git a/src/main/java/top/leavesmc/leaves/command/CommandArgument.java b/src/main/java/top/leavesmc/leaves/command/CommandArgument.java
new file mode 100644
Expand Down
Loading

0 comments on commit 360d66c

Please sign in to comment.