Files
PlazmaBukkitMC/patches/server/features/0013-Add-an-option-to-apply-the-configuration-to-the-vani.patch
2025-02-23 22:35:05 +09:00

197 lines
11 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: AlphaKR93 <dev@alpha93.kr>
Date: Wed, 15 May 2024 16:13:17 +0900
Subject: [PATCH] Add an option to apply the configuration to the vanilla
default
diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
index 8c3c7987a269733a0f530e8f22c3f1a005de21ac..20def77109eb9cd98a7677e73b4316544be86283 100644
--- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
+++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
@@ -88,7 +88,7 @@ public class GlobalConfiguration extends ConfigurationPart {
public Component flyingVehicle = Component.translatable("multiplayer.disconnect.flying");
}
- public Component noPermission = Component.text("I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error.", NamedTextColor.RED);
+ public Component noPermission = org.plazmamc.plazma.Options.VANILLAIZE ? Component.translatable("command.unknown.command") : Component.text("I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error.", NamedTextColor.RED);
public boolean useDisplayNameInQuitMessage = false;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 4177a12d333925dd7f3422861847119f344a441b..15527e902484496a6804c879d1de589bed3f8713 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -449,7 +449,19 @@ public final class CraftServer implements Server {
this.configuration = YamlConfiguration.loadConfiguration(this.getConfigFile());
this.configuration.options().copyDefaults(true);
- this.configuration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream(org.plazmamc.plazma.configurations.PlazmaConfigurations.optimize() ? "configurations/bukkit_optimized.yml" : "configurations/bukkit.yml"), Charsets.UTF_8))); // Plazma - Optimize default configurations
+ // Plazma start - Add an option to apply the configuration to the vanilla default
+ String configPath;
+ if (org.plazmamc.plazma.Options.NO_OPTIMIZE) {
+ if (org.plazmamc.plazma.Options.VANILLAIZE) configPath = "configurations/bukkit_vanillaized.yml";
+ else configPath = "configurations/bukkit.yml";
+ } else {
+ if (org.plazmamc.plazma.Options.VANILLAIZE) configPath = "configurations/bukkit_optimized_vanillaized.yml";
+ else configPath = "configurations/bukkit_optimized.yml";
+ }
+ this.configuration.setDefaults(YamlConfiguration.loadConfiguration(
+ new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream(configPath), Charsets.UTF_8)
+ )); // Plazma - Optimize default configurations
+ // Plazma end - Add an option to apply the configuration to the vanilla default
ConfigurationSection legacyAlias = null;
if (!this.configuration.isString("aliases")) {
legacyAlias = this.configuration.getConfigurationSection("aliases");
diff --git a/src/main/java/org/plazmamc/plazma/Options.java b/src/main/java/org/plazmamc/plazma/Options.java
index c608770ea0df26859a09b794e93292f4aa6881b4..063b71b3043a69a90130a81686b6a5f1e5f22fd1 100644
--- a/src/main/java/org/plazmamc/plazma/Options.java
+++ b/src/main/java/org/plazmamc/plazma/Options.java
@@ -8,5 +8,7 @@ public interface Options {
boolean NO_OPTIMIZE = getBoolean("Plazma.disableConfigOptimization");
boolean NO_WARN = getBoolean("Plazma.iKnowWhatIAmDoing");
boolean AGGRESSIVE = getBoolean("Plazma.aggressiveOptimize") && !NO_OPTIMIZE;
+ boolean VANILLAIZE = getBoolean("Plazma.vanillaize") && !AGGRESSIVE;
+ boolean USE_VANILLA = getBoolean("Plazma.useVanillaConfiguration") && !AGGRESSIVE && NO_OPTIMIZE;
}
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 4dbb109d0526afee99b9190fc256585121aac9b5..3835a7aa3e3c60a6f50f1d6e781f280ea8a83fb3 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -193,8 +193,8 @@ public class SpigotConfig
public static String whitelistMessage;
public static String unknownCommandMessage;
public static String serverFullMessage;
- public static String outdatedClientMessage = "Outdated client! Please use {0}";
- public static String outdatedServerMessage = "Outdated server! I\'m still on {0}";
+ public static String outdatedClientMessage = org.plazmamc.plazma.Options.VANILLAIZE ? "<lang:multiplayer.disconnect.outdated_client>" : "Outdated client! Please use {0}";
+ public static String outdatedServerMessage = org.plazmamc.plazma.Options.VANILLAIZE ? "<lang:multiplayer.disconnect.outdated_server>" : "Outdated server! I'm still on {0}";
private static String transform(String s)
{
return ChatColor.translateAlternateColorCodes( '&', s ).replaceAll( "\\\\n", "\n" );
@@ -207,9 +207,9 @@ public class SpigotConfig
SpigotConfig.set( "messages.outdated-server", SpigotConfig.outdatedServerMessage );
}
- SpigotConfig.whitelistMessage = SpigotConfig.transform( SpigotConfig.getString( "messages.whitelist", "You are not whitelisted on this server!" ) );
- SpigotConfig.unknownCommandMessage = SpigotConfig.transform( SpigotConfig.getString( "messages.unknown-command", "Unknown command. Type \"/help\" for help." ) );
- SpigotConfig.serverFullMessage = SpigotConfig.transform( SpigotConfig.getString( "messages.server-full", "The server is full!" ) );
+ SpigotConfig.whitelistMessage = SpigotConfig.transform( SpigotConfig.getString( "messages.whitelist", org.plazmamc.plazma.Options.VANILLAIZE ? "<lang:multiplayer.disconnect.not_whitelisted>" : "You are not whitelisted on this server!" ) ); // Plazma - Add an option to apply the configuration to the vanilla default
+ SpigotConfig.unknownCommandMessage = SpigotConfig.transform( SpigotConfig.getString( "messages.unknown-command", org.plazmamc.plazma.Options.VANILLAIZE ? "<lang:command.unknown.command>" : "Unknown command. Type \"/help\" for help." ) );
+ SpigotConfig.serverFullMessage = SpigotConfig.transform( SpigotConfig.getString( "messages.server-full", org.plazmamc.plazma.Options.VANILLAIZE ? "<lang:multiplayer.disconnect.server_full>" : "The server is full!" ) );
SpigotConfig.outdatedClientMessage = SpigotConfig.transform( SpigotConfig.getString( "messages.outdated-client", SpigotConfig.outdatedClientMessage ) );
SpigotConfig.outdatedServerMessage = SpigotConfig.transform( SpigotConfig.getString( "messages.outdated-server", SpigotConfig.outdatedServerMessage ) );
}
@@ -223,7 +223,7 @@ public class SpigotConfig
SpigotConfig.timeoutTime = SpigotConfig.getInt( "settings.timeout-time", SpigotConfig.timeoutTime );
SpigotConfig.restartOnCrash = SpigotConfig.getBoolean( "settings.restart-on-crash", SpigotConfig.restartOnCrash );
SpigotConfig.restartScript = SpigotConfig.getString( "settings.restart-script", SpigotConfig.restartScript );
- SpigotConfig.restartMessage = SpigotConfig.transform( SpigotConfig.getString( "messages.restart", "Server is restarting" ) );
+ SpigotConfig.restartMessage = SpigotConfig.transform( SpigotConfig.getString( "messages.restart", org.plazmamc.plazma.Options.VANILLAIZE ? "<lang:disconnect.quitting>" : "Server is restarting" ) );
SpigotConfig.commands.put( "restart", new RestartCommand( "restart" ) );
// WatchdogThread.doStart( SpigotConfig.timeoutTime, SpigotConfig.restartOnCrash ); // Paper - moved to after paper config initialization
}
diff --git a/src/main/resources/configurations/bukkit_optimized_vanillaized.yml b/src/main/resources/configurations/bukkit_optimized_vanillaized.yml
new file mode 100644
index 0000000000000000000000000000000000000000..b7ed456b0172caebdf5b548052ff2ae688377020
--- /dev/null
+++ b/src/main/resources/configurations/bukkit_optimized_vanillaized.yml
@@ -0,0 +1,45 @@
+# This is the main configuration file for Bukkit.
+# As you can see, there's actually not that much to configure without any plugins.
+# For a reference for any variable inside this file, check out the Bukkit Wiki at
+# https://www.spigotmc.org/go/bukkit-yml
+#
+# If you need help on this file, feel free to join us on Discord or leave a message
+# on the forums asking for advice.
+#
+# Discord: https://www.spigotmc.org/go/discord
+# Forums: https://www.spigotmc.org/
+# Bug tracker: https://www.spigotmc.org/go/bugs
+
+
+settings:
+ allow-end: true
+ warn-on-overload: true
+ permissions-file: permissions.yml
+ update-folder: update
+ plugin-profiling: false
+ connection-throttle: 4000
+ query-plugins: true
+ deprecated-verbose: default
+ shutdown-message: <lang:multiplayer.disconnect.server_shutdown>
+ minimum-api: none
+ use-map-color-cache: true
+spawn-limits:
+ monsters: 20
+ animals: 5
+ water-animals: 2
+ water-ambient: 2
+ water-underground-creature: 3
+ axolotls: 3
+ ambient: 1
+chunk-gc:
+ period-in-ticks: 400
+ticks-per:
+ animal-spawns: 400
+ monster-spawns: 10
+ water-spawns: 400
+ water-ambient-spawns: 400
+ water-underground-creature-spawns: 400
+ axolotl-spawns: 400
+ ambient-spawns: 400
+ autosave: 6000
+aliases: now-in-commands.yml
diff --git a/src/main/resources/configurations/bukkit_vanillaized.yml b/src/main/resources/configurations/bukkit_vanillaized.yml
new file mode 100644
index 0000000000000000000000000000000000000000..22fe392b9970bb82db293d638b0dd5727bd60e5a
--- /dev/null
+++ b/src/main/resources/configurations/bukkit_vanillaized.yml
@@ -0,0 +1,45 @@
+# This is the main configuration file for Bukkit.
+# As you can see, there's actually not that much to configure without any plugins.
+# For a reference for any variable inside this file, check out the Bukkit Wiki at
+# https://www.spigotmc.org/go/bukkit-yml
+#
+# If you need help on this file, feel free to join us on Discord or leave a message
+# on the forums asking for advice.
+#
+# Discord: https://www.spigotmc.org/go/discord
+# Forums: https://www.spigotmc.org/
+# Bug tracker: https://www.spigotmc.org/go/bugs
+
+
+settings:
+ allow-end: true
+ warn-on-overload: true
+ permissions-file: permissions.yml
+ update-folder: update
+ plugin-profiling: false
+ connection-throttle: 4000
+ query-plugins: true
+ deprecated-verbose: default
+ shutdown-message: <lang:multiplayer.disconnect.server_shutdown>
+ minimum-api: none
+ use-map-color-cache: true
+spawn-limits:
+ monsters: 70
+ animals: 10
+ water-animals: 5
+ water-ambient: 20
+ water-underground-creature: 5
+ axolotls: 5
+ ambient: 15
+chunk-gc:
+ period-in-ticks: 600
+ticks-per:
+ animal-spawns: 400
+ monster-spawns: 1
+ water-spawns: 1
+ water-ambient-spawns: 1
+ water-underground-creature-spawns: 1
+ axolotl-spawns: 1
+ ambient-spawns: 1
+ autosave: 6000
+aliases: now-in-commands.yml