Skip to content

Commit

Permalink
Add Gale config to Spark profiler & Hide Sentry DSN key in Leaf config
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreeam-qwq committed Sep 1, 2024
1 parent 68b8661 commit 1a9ddb5
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions patches/server/0003-Leaf-Config.patch
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Add per world config
Add config reload

diff --git a/build.gradle.kts b/build.gradle.kts
index a79693afc8c21448a4134f730eff910e1b88e2a8..ca9f19c451155e3b411171f757ed9feed2a43a58 100644
index 1543def648f4264a6e18822343548902ee4e3437..f79281f2cffa43474e830c5cbd9a0117be68323f 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -14,6 +14,13 @@ val alsoShade: Configuration by configurations.creating
Expand Down Expand Up @@ -148,10 +148,10 @@ index 0000000000000000000000000000000000000000..f7ab1ff5f298ff1e5e16fe5396d1e9e6
+}
diff --git a/src/main/java/org/dreeam/leaf/config/LeafConfig.java b/src/main/java/org/dreeam/leaf/config/LeafConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..ac4342cccb578a37fe5364d392c95879227df28b
index 0000000000000000000000000000000000000000..7c25e67cf39229add96de96452ea9601e970fc01
--- /dev/null
+++ b/src/main/java/org/dreeam/leaf/config/LeafConfig.java
@@ -0,0 +1,232 @@
@@ -0,0 +1,260 @@
+package org.dreeam.leaf.config;
+
+import org.jetbrains.annotations.Contract;
Expand All @@ -168,9 +168,12 @@ index 0000000000000000000000000000000000000000..ac4342cccb578a37fe5364d392c95879
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.jar.JarEntry;
Expand All @@ -179,6 +182,7 @@ index 0000000000000000000000000000000000000000..ac4342cccb578a37fe5364d392c95879
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.bukkit.Bukkit;
+import org.bukkit.World;
+
+/*
+ * Yoinked from: https://github.com/xGinko/AnarchyExploitFixes/ & https://github.com/LuminolMC/Luminol
Expand Down Expand Up @@ -344,9 +348,33 @@ index 0000000000000000000000000000000000000000..ac4342cccb578a37fe5364d392c95879
+
+ /* Register Spark profiler extra server configurations */
+
+ private static List<String> buildSparkExtraConfigs() {
+ List<String> extraConfigs = new ArrayList<>(Arrays.asList(
+ "config/leaf-global.yml",
+ "config/gale-global.yml",
+ "config/gale-world-defaults.yml"
+ ));
+
+ for (World world : Bukkit.getWorlds()) {
+ extraConfigs.add(world.getWorldFolder().getName() + "/gale-world.yml"); // Gale world config
+ }
+
+ return extraConfigs;
+ }
+
+ private static String[] buildSparkHiddenPaths() {
+ return new String[]{
+ "misc.sentry-dsn" // Hide Sentry DSN key
+ };
+ }
+
+ public static void regSparkExtraConfig() {
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().spark.enabled || Bukkit.getServer().getPluginManager().getPlugin("spark") != null) {
+ System.setProperty("spark.serverconfigs.extra", "config/leaf-global.yml");
+ String extraConfigs = String.join(",", buildSparkExtraConfigs());
+ String hiddenPaths = String.join(",", buildSparkHiddenPaths());
+
+ System.setProperty("spark.serverconfigs.extra", extraConfigs);
+ System.setProperty("spark.serverconfigs.hiddenpaths", hiddenPaths);
+ }
+ }
+
Expand Down

0 comments on commit 1a9ddb5

Please sign in to comment.