Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
update config
Browse files Browse the repository at this point in the history
  • Loading branch information
404Setup committed Aug 28, 2024
1 parent 24f5bdc commit 60c1511
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 46 deletions.
22 changes: 16 additions & 6 deletions patches/api/0004-Vine-Config.patch
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ index 0000000000000000000000000000000000000000..b743c171d46ec07cd5c2da71b272fe07
+}
diff --git a/src/main/java/one/tranic/vine/region/Compression.java b/src/main/java/one/tranic/vine/region/Compression.java
new file mode 100644
index 0000000000000000000000000000000000000000..598d967fc91b3301015523a4698312200c17d45f
index 0000000000000000000000000000000000000000..2d8179733bbd2edcaa6acf77a2cb654d5d83a8d3
--- /dev/null
+++ b/src/main/java/one/tranic/vine/region/Compression.java
@@ -0,0 +1,44 @@
@@ -0,0 +1,49 @@
+package one.tranic.vine.region;
+
+public enum Compression {
Expand All @@ -121,7 +121,11 @@ index 0000000000000000000000000000000000000000..598d967fc91b3301015523a469831220
+ ZSTD,
+ BROTLI;
+
+ public static Compression now;
+ private static Compression now;
+
+ public static boolean equals(Compression input) {
+ return input.ordinal() == now.ordinal();
+ }
+
+ @Override
+ public String toString() {
Expand Down Expand Up @@ -151,24 +155,29 @@ index 0000000000000000000000000000000000000000..598d967fc91b3301015523a469831220
+ }
+
+ public static void setNow(final Compression now) {
+ if (Compression.now != null) throw new RuntimeException("Disallow reassignment to \"now\".");
+ one.tranic.vine.config.VineConfig.Feature.Region.compressionFormat = now;
+ Compression.now = now;
+ }
+}
diff --git a/src/main/java/one/tranic/vine/region/Format.java b/src/main/java/one/tranic/vine/region/Format.java
new file mode 100644
index 0000000000000000000000000000000000000000..0e302de56b2a294a975d5b257012c16d78fd57ea
index 0000000000000000000000000000000000000000..cd4967fd8341c33ef88f987a13c1ab3a665408bc
--- /dev/null
+++ b/src/main/java/one/tranic/vine/region/Format.java
@@ -0,0 +1,35 @@
@@ -0,0 +1,40 @@
+package one.tranic.vine.region;
+
+public enum Format {
+ ANVIL,
+ LINEAR,
+ SECTORFILE;
+
+ public static Format now;
+ private static Format now;
+
+ public static boolean equals(Format input) {
+ return input.ordinal() == now.ordinal();
+ }
+
+ @Override
+ public String toString() {
Expand All @@ -192,6 +201,7 @@ index 0000000000000000000000000000000000000000..0e302de56b2a294a975d5b257012c16d
+ }
+
+ public static void setNow(Format now) {
+ if (Format.now != null) throw new RuntimeException("Disallow reassignment to \"now\".");
+ one.tranic.vine.config.VineConfig.Feature.Region.format = now;
+ Format.now = now;
+ }
Expand Down
14 changes: 7 additions & 7 deletions patches/server/0003-Vine-Config.patch
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ index 0000000000000000000000000000000000000000..819da2962087ce70c6b9b4ec758937ef
\ No newline at end of file
diff --git a/src/main/kotlin/one/tranic/vine/config/ConfigUtil.kt b/src/main/kotlin/one/tranic/vine/config/ConfigUtil.kt
new file mode 100644
index 0000000000000000000000000000000000000000..38064202131f042d3d38757afdab76960b4fb232
index 0000000000000000000000000000000000000000..655dcd125a58aec84ee93a90cf087b0b10052830
--- /dev/null
+++ b/src/main/kotlin/one/tranic/vine/config/ConfigUtil.kt
@@ -0,0 +1,148 @@
Expand Down Expand Up @@ -183,7 +183,7 @@ index 0000000000000000000000000000000000000000..38064202131f042d3d38757afdab7696
+ reload()
+ // If SECTORFILE is enabled and BROTLI is selected as the compression format,
+ // initialize the dependent libraries.
+ if (Format.getNow().equals(Format.SECTORFILE) && Compression.getNow().equals(Compression.BROTLI)) {
+ if (Format.equals(Format.SECTORFILE) && Compression.equals(Compression.BROTLI)) {
+ Brotli4jLoader.ensureAvailability()
+ }
+ }
Expand Down Expand Up @@ -471,7 +471,7 @@ index 0000000000000000000000000000000000000000..1912152e305c4aa92e23335990b847b6
\ No newline at end of file
diff --git a/src/main/kotlin/one/tranic/vine/config/module/feature/Region.kt b/src/main/kotlin/one/tranic/vine/config/module/feature/Region.kt
new file mode 100644
index 0000000000000000000000000000000000000000..39cd03eb8475d673609c40fae6d9cb96a99dd92e
index 0000000000000000000000000000000000000000..904816530087bc3938228070eaf2fe05abfbffb6
--- /dev/null
+++ b/src/main/kotlin/one/tranic/vine/config/module/feature/Region.kt
@@ -0,0 +1,87 @@
Expand Down Expand Up @@ -528,20 +528,20 @@ index 0000000000000000000000000000000000000000..39cd03eb8475d673609c40fae6d9cb96
+
+ override fun load() {
+ getString("feature.region.format") {
+ val b = Format.getFormat(it)
+ if (Locker.regionFormat == null) {
+ val b = Format.getFormat(it)
+ Locker.regionFormat = b
+ Format.setNow(b)
+ } else if (Locker.regionFormat != Format.getFormat(it)) {
+ } else if (!b.equals(Locker.regionFormat)) {
+ VineLogger.error("Forbidden to modify the parameter \"feature.region.format\" during runtime!!!")
+ }
+ }
+ getString("feature.region.compression-format") {
+ val b = Compression.getCompression(it)
+ if (Locker.compressionFormat == null) {
+ val b = Compression.getCompression(it)
+ Locker.compressionFormat = b
+ Compression.setNow(b)
+ } else if (Locker.compressionFormat != Compression.getCompression(it)) {
+ } else if (!b.equals(Locker.compressionFormat)) {
+ VineLogger.error("Forbidden to modify the parameter \"feature.region.compression-format\" during runtime!!!")
+ }
+ }
Expand Down
Loading

0 comments on commit 60c1511

Please sign in to comment.