Skip to content

Commit

Permalink
Fix GlobalConfigCreator (#385), and not pre
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yh-china committed Dec 27, 2024
1 parent e64ef21 commit bce1d6c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ group=org.leavesmc.leaves
version=1.21.3-R0.1-SNAPSHOT
mcVersion=1.21.3
paperRef=5a60ffb8b1cc88c1480a4c5f5c221291be97527f
preVersion=true
preVersion=false
org.gradle.jvmargs=-Xmx2G
org.gradle.caching=true
org.gradle.parallel=true
11 changes: 6 additions & 5 deletions patches/server/0006-Leaves-Server-Config-And-Command.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1689,10 +1689,10 @@ index 0000000000000000000000000000000000000000..1e109a8b95f7dd25f68f7b3d2115c8cf
+}
diff --git a/src/main/java/org/leavesmc/leaves/config/GlobalConfigCreator.java b/src/main/java/org/leavesmc/leaves/config/GlobalConfigCreator.java
new file mode 100644
index 0000000000000000000000000000000000000000..baa8f15c5ef092f287004b8266b7f7cee1392260
index 0000000000000000000000000000000000000000..dfc38bd1fbec54da52188e9ea860448e14342a99
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/config/GlobalConfigCreator.java
@@ -0,0 +1,83 @@
@@ -0,0 +1,84 @@
+package org.leavesmc.leaves.config;
+
+import org.bukkit.configuration.file.YamlConfiguration;
Expand All @@ -1702,17 +1702,18 @@ index 0000000000000000000000000000000000000000..baa8f15c5ef092f287004b8266b7f7ce
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.Collections;
+
+import static org.leavesmc.leaves.config.GlobalConfigManager.CONFIG_START;
+
+@SuppressWarnings("CallToPrintStackTrace")
+public class GlobalConfigCreator {
+
+ private static YamlConfiguration config;
+
+ @SuppressWarnings("ResultOfMethodCallIgnored")
+ public static void main(String[] args) {
+ config = new YamlConfiguration();
+ config.options().setHeader(Collections.singletonList(LeavesConfig.CONFIG_HEADER));
Expand Down Expand Up @@ -1750,7 +1751,7 @@ index 0000000000000000000000000000000000000000..baa8f15c5ef092f287004b8266b7f7ce
+ }
+
+ private static void initField(@NotNull Field field, @Nullable Object upstreamField, @NotNull String upstreamPath) {
+ if (Modifier.isStatic(field.getModifiers())) {
+ if (upstreamField != null || Modifier.isStatic(field.getModifiers())) {
+ field.setAccessible(true);
+
+ GlobalConfig globalConfig = field.getAnnotation(GlobalConfig.class);
Expand All @@ -1770,7 +1771,7 @@ index 0000000000000000000000000000000000000000..baa8f15c5ef092f287004b8266b7f7ce
+ private static void initConfig(@NotNull Field field, GlobalConfig globalConfig, @Nullable Object upstreamField, @NotNull String upstreamPath) {
+ try {
+ GlobalConfigManager.VerifiedConfig verifiedConfig = GlobalConfigManager.VerifiedConfig.build(globalConfig, field, upstreamField, upstreamPath);
+ config.set(verifiedConfig.path(), verifiedConfig.validator().saveConvert(field.get(null)));
+ config.set(verifiedConfig.path(), verifiedConfig.validator().saveConvert(field.get(upstreamField)));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
Expand Down

0 comments on commit bce1d6c

Please sign in to comment.