Skip to content

Commit

Permalink
Reorgranise config yml
Browse files Browse the repository at this point in the history
  • Loading branch information
PureGero committed May 28, 2024
1 parent 986e8cc commit a8a718e
Show file tree
Hide file tree
Showing 19 changed files with 1,695 additions and 1,732 deletions.
43 changes: 23 additions & 20 deletions SHREDDEDPAPER_YAML.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,29 @@

```yaml

# The number of threads to use for ticking chunks. `-1` defaults to the number
# of available processors subtract one, or 1, whichever is larger.
# Set to `1` to essentially disable multi-threading.
thread-count: -1
# Multithreading settings
multithreading:

# The size of a region in chunks. Chunks are grouped into regions when
# ticking, and neighbouring regions are locked so any changes into the
# neighbouring region do not step on other threads.
# The larger the value, the more performant the server will be, but the more
# likely the work is not evenly distributed between threads. Too small, and
# threads may accidentally try accessing chunks of another thread.
# A minimum of 8 chunks is recommended, as lightning rods have the largest
# search radius at 8 chunks.
# Must be a power of 2.
region-size: 8

# Whether to run plugins' code without 'folia-supported: true' in sync. This
# will give unsupported plugins a better chance of working, but is not
# guaranteed. If false, or if the plugin is supported, all the plugin's code
# will run asynchronously in the ticking region worker threads.
run-unsupported-plugins-in-sync: true
# The number of threads to use for ticking chunks. `-1` defaults to the number
# of available processors subtract one, or 1, whichever is larger.
# Set to `1` to essentially disable multi-threading.
thread-count: -1

# The size of a region in chunks. Chunks are grouped into regions when
# ticking, and neighbouring regions are locked so any changes into the
# neighbouring region do not step on other threads.
# The larger the value, the more performant the server will be, but the more
# likely the work is not evenly distributed between threads. Too small, and
# threads may accidentally try accessing chunks of another thread.
# A minimum of 8 chunks is recommended, as lightning rods have the largest
# search radius at 8 chunks.
# Must be a power of 2.
region-size: 8

# Whether to run plugins' code without 'folia-supported: true' in sync. This
# will give unsupported plugins a better chance of working, but is not
# guaranteed. If false, or if the plugin is supported, all the plugin's code
# will run asynchronously in the ticking region worker threads.
run-unsupported-plugins-in-sync: true

```
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] ShreddedPaper build changes


diff --git a/build.gradle.kts b/build.gradle.kts
index d23ecfabf6bf1e355fb2efe5abd80236259ce3c4..a3ac4ee572fab52ed8a6af4b69b8ccd3eb555cfb 100644
index d23ecfabf6bf1e355fb2efe5abd80236259ce3c4..bd224e1d9bfc49feca9f0291df839bed9d5842c4 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -13,7 +13,7 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) {
Expand Down Expand Up @@ -38,7 +38,7 @@ index d23ecfabf6bf1e355fb2efe5abd80236259ce3c4..a3ac4ee572fab52ed8a6af4b69b8ccd3
"Build-Time" to Instant.now().toString(),
"Git-Branch" to gitBranch, // Paper
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
index 99597258e8e88cd9e2c901c4ac3ff7faeeabee2b..2fb1e86a62488f54dcdf5144a4911794ceacff0b 100644
index 99597258e8e88cd9e2c901c4ac3ff7faeeabee2b..ed2f3845afed661a5f620efc071cd71c2bc7d613 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
@@ -11,7 +11,7 @@ public final class Versioning {
Expand All @@ -51,7 +51,7 @@ index 99597258e8e88cd9e2c901c4ac3ff7faeeabee2b..2fb1e86a62488f54dcdf5144a4911794

if (stream != null) {
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
index a353eb9f45af7b7f9bfd92a4a89403335b841840..caa6c45936781fd4e4b03abe1ead8f6bf1230c4c 100644
index a353eb9f45af7b7f9bfd92a4a89403335b841840..a3029da5b80d87158119141608e963196d943db4 100644
--- a/src/main/java/org/spigotmc/WatchdogThread.java
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
@@ -155,14 +155,14 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,79 +4,9 @@ Date: Fri, 4 Mar 2022 20:33:33 +1000
Subject: [PATCH] ShreddedPaper config file


diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java
index 0f7d6da8685716604f0749d4f5b60730a44cde73..c2dc50007572dc4a62830e36531131032d32b1a7 100644
--- a/src/main/java/net/minecraft/server/Main.java
+++ b/src/main/java/net/minecraft/server/Main.java
@@ -23,7 +23,6 @@ import joptsimple.util.PathConverter;
import joptsimple.util.PathProperties;
import net.minecraft.CrashReport;
import net.minecraft.DefaultUncaughtExceptionHandler;
-import net.minecraft.SharedConstants;
import net.minecraft.Util;
import net.minecraft.commands.Commands;
import net.minecraft.core.Registry;
@@ -69,6 +68,9 @@ import net.minecraft.SharedConstants;
import org.bukkit.configuration.file.YamlConfiguration;
// CraftBukkit end

+import io.multipaper.shreddedpaper.config.ShreddedPaperConfiguration;
+import io.multipaper.shreddedpaper.config.ShreddedPaperConfigurationLoader;
+
public class Main {

private static final Logger LOGGER = LogUtils.getLogger();
@@ -119,6 +121,8 @@ public class Main {
JvmProfiler.INSTANCE.start(Environment.SERVER);
}

+ ShreddedPaperConfigurationLoader.init((File) optionset.valueOf("shreddedpaper-settings")); // ShreddedPaper
+
// Purpur start - load config files early
org.bukkit.configuration.file.YamlConfiguration purpurConfiguration = io.papermc.paper.configuration.PaperConfigurations.loadLegacyConfigFile((File) optionset.valueOf("purpur-settings"));
org.purpurmc.purpur.PurpurConfig.clampEnchantLevels = purpurConfiguration.getBoolean("settings.enchantment.clamp-levels");
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 6e78500a6265b0192095379704b1d661ef56ba32..5abd5ced015be7de740d504b5c0b0620822f22ac 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -259,6 +259,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
import org.yaml.snakeyaml.error.MarkedYAMLException;

import net.md_5.bungee.api.chat.BaseComponent; // Spigot
+import io.multipaper.shreddedpaper.permissions.ShreddedPaperPermissions;

import javax.annotation.Nullable; // Paper
import javax.annotation.Nonnull; // Paper
@@ -577,6 +578,7 @@ public final class CraftServer implements Server {
this.commandMap.registerServerAliases();
DefaultPermissions.registerCorePermissions();
CraftDefaultPermissions.registerCorePermissions();
+ ShreddedPaperPermissions.registerCorePermissions(); // ShreddedPaper
if (!io.papermc.paper.configuration.GlobalConfiguration.get().misc.loadPermissionsYmlBeforePlugins) this.loadCustomPermissions(); // Paper
this.helpMap.initializeCommands();
this.syncCommands();
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index 6d8e9cf4ee496b8748654e792ce438f512c3d946..7356f7eebb51832c3455eab749ed27201bb741d2 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -184,6 +184,14 @@ public class Main {
.describedAs("Yml file");
// Purpur end

+ // ShreddedPaper start
+ acceptsAll(asList("shreddedpaper", "shreddedpaper-settings"), "File for shreddedpaper settings")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("shreddedpaper.yml"))
+ .describedAs("Yml file");
+ // ShreddedPaper end
+
// Paper start
acceptsAll(asList("server-name"), "Name of the server")
.withRequiredArg()
diff --git a/src/main/java/io/multipaper/shreddedpaper/config/ExceptionableConsumer.java b/src/main/java/io/multipaper/shreddedpaper/config/ExceptionableConsumer.java
new file mode 100644
index 0000000000000000000000000000000000000000..7cdf20efd4f220f55d7b86abce19e84f4512191e
index 0000000000000000000000000000000000000000..df97bb240655934b62cfb1647f2dc32707b48a09
--- /dev/null
+++ b/src/main/java/io/multipaper/shreddedpaper/config/ExceptionableConsumer.java
@@ -0,0 +1,8 @@
Expand All @@ -90,10 +20,10 @@ index 0000000000000000000000000000000000000000..7cdf20efd4f220f55d7b86abce19e84f
+}
diff --git a/src/main/java/io/multipaper/shreddedpaper/config/ShreddedPaperConfiguration.java b/src/main/java/io/multipaper/shreddedpaper/config/ShreddedPaperConfiguration.java
new file mode 100644
index 0000000000000000000000000000000000000000..a198aadad3acdf431321e05f62b392d408246a4c
index 0000000000000000000000000000000000000000..15057bd8191f3fba9952a5c768f4500924f1031c
--- /dev/null
+++ b/src/main/java/io/multipaper/shreddedpaper/config/ShreddedPaperConfiguration.java
@@ -0,0 +1,67 @@
@@ -0,0 +1,39 @@
+package io.multipaper.shreddedpaper.config;
+
+import io.papermc.paper.configuration.ConfigurationPart;
Expand Down Expand Up @@ -121,52 +51,24 @@ index 0000000000000000000000000000000000000000..a198aadad3acdf431321e05f62b392d4
+ ShreddedPaperConfiguration.instance = instance;
+ }
+
+ public VerticalScaling verticalScaling;
+ public Multithreading multithreading;
+
+ public class VerticalScaling extends ConfigurationPart {
+ public class Multithreading extends ConfigurationPart {
+
+ public int threadCount = -1;
+ public int regionSize = 8;
+ public boolean runUnsupportedPluginsInSync = true;
+
+ }
+
+ public HorizontalScaling horizontalScaling;
+
+ public class HorizontalScaling extends ConfigurationPart {
+
+ public DatabaseConnection databaseConnection;
+
+ public class DatabaseConnection extends ConfigurationPart {
+
+ public String databaseAddress = "";
+
+ }
+
+ public SyncSettings syncSettings;
+
+ public class SyncSettings extends ConfigurationPart {
+
+ public Files files;
+
+ public class Files extends ConfigurationPart {
+ public List<String> filesToNotSync = List.of("plugins/bStats");
+ public List<String> filesToOnlyUploadOnServerStop = List.of("plugins/MyPluginDirectory/my_big_database.db");
+ public List<String> filesToSyncInRealTime = List.of("plugins/MyPluginDirectory/userdata");
+ public List<String> filesToSyncOnStartup = List.of("myconfigfile.yml", "plugins/MyPlugin.jar");
+ public boolean logFileSyncs = true;
+ }
+ }
+ }
+
+
+}
diff --git a/src/main/java/io/multipaper/shreddedpaper/config/ShreddedPaperConfigurationLoader.java b/src/main/java/io/multipaper/shreddedpaper/config/ShreddedPaperConfigurationLoader.java
new file mode 100644
index 0000000000000000000000000000000000000000..903f47c87045334f05fae22c48d8dad05897dd08
index 0000000000000000000000000000000000000000..9407d6afa9c13a55be65d4e680f3f1a45ea7da9f
--- /dev/null
+++ b/src/main/java/io/multipaper/shreddedpaper/config/ShreddedPaperConfigurationLoader.java
@@ -0,0 +1,140 @@
@@ -0,0 +1,128 @@
+package io.multipaper.shreddedpaper.config;
+
+import io.papermc.paper.configuration.ConfigurationLoaders;
Expand Down Expand Up @@ -259,19 +161,7 @@ index 0000000000000000000000000000000000000000..903f47c87045334f05fae22c48d8dad0
+ }
+
+ private static void transformLegacyConfig(ConfigurationNode node, ShreddedPaperConfiguration config) {
+ getAndRemove(node, "master-connection.master-address", value -> config.horizontalScaling.databaseConnection.databaseAddress = value.getString());
+ getAndRemove(node, "sync-settings.files.log-file-syncs", value -> config.horizontalScaling.syncSettings.files.logFileSyncs = value.getBoolean());
+ getAndRemove(node, "sync-settings.files.files-to-sync-on-startup", value -> config.horizontalScaling.syncSettings.files.filesToSyncOnStartup = value.getList(String.class));
+ getAndRemove(node, "sync-settings.files.files-to-sync-in-real-time", value -> config.horizontalScaling.syncSettings.files.filesToSyncInRealTime = value.getList(String.class));
+ getAndRemove(node, "sync-settings.files.files-to-only-upload-on-server-stop", value -> config.horizontalScaling.syncSettings.files.filesToOnlyUploadOnServerStop = value.getList(String.class));
+ getAndRemove(node, "sync-settings.files.files-to-not-sync", value -> config.horizontalScaling.syncSettings.files.filesToNotSync = value.getList(String.class));
+
+ getAndRemove(node, "shreddedpaperMasterAddress", value -> config.horizontalScaling.databaseConnection.databaseAddress = value.getString());
+ getAndRemove(node, "logFileSyncing", value -> config.horizontalScaling.syncSettings.files.logFileSyncs = value.getBoolean());
+ getAndRemove(node, "filesToSyncOnStartup", value -> config.horizontalScaling.syncSettings.files.filesToSyncOnStartup = value.getList(String.class));
+ getAndRemove(node, "filesToSyncInRealTime", value -> config.horizontalScaling.syncSettings.files.filesToSyncInRealTime = value.getList(String.class));
+ getAndRemove(node, "filesToOnlyUploadOnServerStop", value -> config.horizontalScaling.syncSettings.files.filesToOnlyUploadOnServerStop = value.getList(String.class));
+ getAndRemove(node, "filesToNotSync", value -> config.horizontalScaling.syncSettings.files.filesToNotSync = value.getList(String.class));
+ // getAndRemove(node, "oldValue.oldie", value -> config.newSection.newValue.newie = value.getString());
+ }
+
+ private static void getAndRemove(ConfigurationNode node, String key, ExceptionableConsumer<ConfigurationNode> consumer) {
Expand Down Expand Up @@ -309,7 +199,7 @@ index 0000000000000000000000000000000000000000..903f47c87045334f05fae22c48d8dad0
+}
diff --git a/src/main/java/io/multipaper/shreddedpaper/permissions/ShreddedPaperCommandPermissions.java b/src/main/java/io/multipaper/shreddedpaper/permissions/ShreddedPaperCommandPermissions.java
new file mode 100644
index 0000000000000000000000000000000000000000..f7d9a1538ec842e453e5add3f9e33f8c43bfa3d2
index 0000000000000000000000000000000000000000..53dcfbdf38f007fc86064ac1a495288d5f25f598
--- /dev/null
+++ b/src/main/java/io/multipaper/shreddedpaper/permissions/ShreddedPaperCommandPermissions.java
@@ -0,0 +1,17 @@
Expand All @@ -332,7 +222,7 @@ index 0000000000000000000000000000000000000000..f7d9a1538ec842e453e5add3f9e33f8c
+}
diff --git a/src/main/java/io/multipaper/shreddedpaper/permissions/ShreddedPaperPermissions.java b/src/main/java/io/multipaper/shreddedpaper/permissions/ShreddedPaperPermissions.java
new file mode 100644
index 0000000000000000000000000000000000000000..91b2e3564d7c737b2006f8c2860ab43846637384
index 0000000000000000000000000000000000000000..4999f297b04d151e8000fdc309081b5cee8b11ae
--- /dev/null
+++ b/src/main/java/io/multipaper/shreddedpaper/permissions/ShreddedPaperPermissions.java
@@ -0,0 +1,16 @@
Expand All @@ -352,3 +242,73 @@ index 0000000000000000000000000000000000000000..91b2e3564d7c737b2006f8c2860ab438
+ parent.recalculatePermissibles();
+ }
+}
diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java
index 0f7d6da8685716604f0749d4f5b60730a44cde73..a7ffbbfd2a9fdeae0953ec8753ce48e93ccce086 100644
--- a/src/main/java/net/minecraft/server/Main.java
+++ b/src/main/java/net/minecraft/server/Main.java
@@ -23,7 +23,6 @@ import joptsimple.util.PathConverter;
import joptsimple.util.PathProperties;
import net.minecraft.CrashReport;
import net.minecraft.DefaultUncaughtExceptionHandler;
-import net.minecraft.SharedConstants;
import net.minecraft.Util;
import net.minecraft.commands.Commands;
import net.minecraft.core.Registry;
@@ -69,6 +68,9 @@ import net.minecraft.SharedConstants;
import org.bukkit.configuration.file.YamlConfiguration;
// CraftBukkit end

+import io.multipaper.shreddedpaper.config.ShreddedPaperConfiguration;
+import io.multipaper.shreddedpaper.config.ShreddedPaperConfigurationLoader;
+
public class Main {

private static final Logger LOGGER = LogUtils.getLogger();
@@ -119,6 +121,8 @@ public class Main {
JvmProfiler.INSTANCE.start(Environment.SERVER);
}

+ ShreddedPaperConfigurationLoader.init((File) optionset.valueOf("shreddedpaper-settings")); // ShreddedPaper
+
// Purpur start - load config files early
org.bukkit.configuration.file.YamlConfiguration purpurConfiguration = io.papermc.paper.configuration.PaperConfigurations.loadLegacyConfigFile((File) optionset.valueOf("purpur-settings"));
org.purpurmc.purpur.PurpurConfig.clampEnchantLevels = purpurConfiguration.getBoolean("settings.enchantment.clamp-levels");
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 6e78500a6265b0192095379704b1d661ef56ba32..87ed749633aba04e6b86eb7ddf09f58884b552a4 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -259,6 +259,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
import org.yaml.snakeyaml.error.MarkedYAMLException;

import net.md_5.bungee.api.chat.BaseComponent; // Spigot
+import io.multipaper.shreddedpaper.permissions.ShreddedPaperPermissions;

import javax.annotation.Nullable; // Paper
import javax.annotation.Nonnull; // Paper
@@ -577,6 +578,7 @@ public final class CraftServer implements Server {
this.commandMap.registerServerAliases();
DefaultPermissions.registerCorePermissions();
CraftDefaultPermissions.registerCorePermissions();
+ ShreddedPaperPermissions.registerCorePermissions(); // ShreddedPaper
if (!io.papermc.paper.configuration.GlobalConfiguration.get().misc.loadPermissionsYmlBeforePlugins) this.loadCustomPermissions(); // Paper
this.helpMap.initializeCommands();
this.syncCommands();
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index 6d8e9cf4ee496b8748654e792ce438f512c3d946..41f00f5af479fd48f1e67150c4cfee3049c7feb9 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -184,6 +184,14 @@ public class Main {
.describedAs("Yml file");
// Purpur end

+ // ShreddedPaper start
+ acceptsAll(asList("shreddedpaper", "shreddedpaper-settings"), "File for shreddedpaper settings")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("shreddedpaper.yml"))
+ .describedAs("Yml file");
+ // ShreddedPaper end
+
// Paper start
acceptsAll(asList("server-name"), "Name of the server")
.withRequiredArg()
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] ShreddedPaper Metrics


diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java
index 8cde30544e14f8fc2dac32966ae3c21f8cf3a551..ead87ad864494358096d59a4dbe2fe2b20e3ae37 100644
index 8cde30544e14f8fc2dac32966ae3c21f8cf3a551..cc152e9a86bcb0dad498d7332f01dcbf44c43995 100644
--- a/src/main/java/com/destroystokyo/paper/Metrics.java
+++ b/src/main/java/com/destroystokyo/paper/Metrics.java
@@ -3,6 +3,7 @@ package com.destroystokyo.paper;
Expand Down
Loading

0 comments on commit a8a718e

Please sign in to comment.