mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@88a3a870 Configurable xp orb merge group count (#12503) PaperMC/Paper@53d1d04e Disable Item Obfuscation for entity related stacks (#12297) PaperMC/Paper@c98cd658 Add configuration interface to expose certain config values (#12273) PaperMC/Paper@42a2a6c2 Supports the ability for commands to be registered internally (#12520) PaperMC/Paper@753cff7c Improvements for Dump paper commands (#12512) PaperMC/Paper@e2da5d2f Registry API for supported Mob Variants (#12417) PaperMC/Paper@ab0253fe Expand PlayerDeathEvent API (#12221) PaperMC/Paper@cbcf75a5 Update visual fire handling with TriState support (#12303) PaperMC/Paper@6c3964d2 Properly save level data async (#12530) PaperMC/Paper@d2ad2e66 Add missing EntityLookup#getAllMapped from Moonrise PaperMC/Paper@358e72ec Remove simplify remote item matching stuff for now PaperMC/Paper@04ffca0b Also remove CraftPlayer methods PaperMC/Paper@a2525819 Update mache PaperMC/Paper@d683970d Add FishHookStateChangeEvent (#12165) PaperMC/Paper@369ad170 Cached tag parser for itemstack reading (#12547) PaperMC/Paper@841d6342 Fix ItemStack#addUnsafeEnchantment ignored for missing enchantment component (#12549) PaperMC/Paper@c000b352 fix(bukkit-brig-forwarding-map): Invert isEmpty method (#12555) PaperMC/Paper@28d7df75 Backport HeroesOfTheVillage datafixer fix PaperMC/Paper@f1dbed07 Implement BlocksAttack DamageReduction and ItemDamage (#12538) PaperMC/Paper@cc38032b Deprecate TeleportCause CHORUS_FRUIT for CONSUMABLE_EFFECT (#12546) PaperMC/Paper@35878677 [ci/skip] Fix format and mentions for ItemDamageFunction (#12560) PaperMC/Paper@7171d299 [ci/skip] Mention CAN_PLACE/CAN_BREAK component in ItemMeta (#12559) PaperMC/Paper@6f73e62e Add getPickItemStack (#12552) PaperMC/Paper@ce0fa4c4 Replace old version command with brigadier equivalent (#12502) PaperMC/Paper@fa360aa8 Add some missing annotations and an incorrect one (#12204) PaperMC/Paper@113b18ee Update paperweight and Gradle wrapper (#12573) PaperMC/Paper@f303a076 fix: Don't hardcode checks for translation registries (#12571) PaperMC/Paper@87349c31 Fix CombatTracker stale on death (#12562) PaperMC/Paper@b70bca6b Revert "fix: Don't hardcode checks for translation registries (#12571)" Purpur Changes: PurpurMC/Purpur@93011bc1 Add configuration setting to re-add End void rings (#1656) PurpurMC/Purpur@c2f48591 [ci/skip] only set default world config values once PurpurMC/Purpur@6f5bbae5 [ci/skip] move some code around PurpurMC/Purpur@5c1a9835 fix issue with `shift-right-click-repairs-mending-points` PurpurMC/Purpur@3156e446 check damage value of tool correctly PurpurMC/Purpur@a9fe4f25 Updated Upstream (Paper) PurpurMC/Purpur@9d0aa8eb Updated Upstream (Paper) PurpurMC/Purpur@603c7557 Updated Upstream (Paper) PurpurMC/Purpur@eca78060 Updated Upstream (Paper) PurpurMC/Purpur@e4e9cfdf Updated Upstream (Paper) PurpurMC/Purpur@3de2fc7d Updated Upstream (Paper) PurpurMC/Purpur@09f547de add `mob-griefing-override` config options (#1661) PurpurMC/Purpur@1dd9bd0c Updated Upstream (Paper) PurpurMC/Purpur@7a8aa86a finish updating gradle PurpurMC/Purpur@fd78b90f bandaid fix: increase the daemon heap for now
173 lines
9.6 KiB
Diff
173 lines
9.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
|
Date: Wed, 23 Nov 2022 21:05:47 +0100
|
|
Subject: [PATCH] Gale configuration
|
|
|
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
|
Gale - https://galemc.org
|
|
|
|
This patch is based on the following patch:
|
|
"Paper config files"
|
|
By: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
As part of: Paper (https://github.com/PaperMC/Paper)
|
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/configuration/Configurations.java b/src/main/java/io/papermc/paper/configuration/Configurations.java
|
|
index d0c4037c3cc60c54ea4c60ffc2c227107fecd01c..c01f3bd5022371b71f2bdc00ebf9d1340afe86d2 100644
|
|
--- a/src/main/java/io/papermc/paper/configuration/Configurations.java
|
|
+++ b/src/main/java/io/papermc/paper/configuration/Configurations.java
|
|
@@ -95,7 +95,7 @@ public abstract class Configurations<G, W> {
|
|
};
|
|
}
|
|
|
|
- static <T> CheckedFunction<ConfigurationNode, T, SerializationException> reloader(Class<T> type, T instance) {
|
|
+ public static <T> CheckedFunction<ConfigurationNode, T, SerializationException> reloader(Class<T> type, T instance) { // Gale - Gale configuration
|
|
return node -> {
|
|
ObjectMapper.Factory factory = (ObjectMapper.Factory) Objects.requireNonNull(node.options().serializers().get(type));
|
|
ObjectMapper.Mutable<T> mutable = (ObjectMapper.Mutable<T>) factory.get(type);
|
|
@@ -169,7 +169,7 @@ public abstract class Configurations<G, W> {
|
|
final YamlConfigurationLoader loader = result.loader();
|
|
final ConfigurationNode node = loader.load();
|
|
if (result.isNewFile()) { // add version to new files
|
|
- node.node(Configuration.VERSION_FIELD).raw(this.worldConfigVersion());
|
|
+ node.node(Configuration.VERSION_FIELD).raw(getWorldConfigurationCurrentVersion()); // Gale - Gale configuration
|
|
} else {
|
|
this.verifyWorldConfigVersion(contextMap, node);
|
|
}
|
|
@@ -231,7 +231,7 @@ public abstract class Configurations<G, W> {
|
|
.build();
|
|
final ConfigurationNode worldNode = worldLoader.load();
|
|
if (newFile) { // set the version field if new file
|
|
- worldNode.node(Configuration.VERSION_FIELD).set(this.worldConfigVersion());
|
|
+ worldNode.node(Configuration.VERSION_FIELD).set(getWorldConfigurationCurrentVersion()); // Gale - Gale configuration
|
|
} else {
|
|
this.verifyWorldConfigVersion(contextMap, worldNode);
|
|
}
|
|
@@ -357,4 +357,25 @@ public abstract class Configurations<G, W> {
|
|
return "ContextKey{" + this.name + "}";
|
|
}
|
|
}
|
|
+
|
|
+ // Gale start - Gale configuration
|
|
+
|
|
+ public static final String legacyWorldsSectionKey = "__________WORLDS__________";
|
|
+ public static final String legacyWorldDefaultsSectionKey = "__defaults__";
|
|
+
|
|
+ @Deprecated
|
|
+ public org.bukkit.configuration.file.YamlConfiguration createLegacyObject(final net.minecraft.server.MinecraftServer server) {
|
|
+ org.bukkit.configuration.file.YamlConfiguration global = org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(this.globalFolder.resolve(this.globalConfigFileName).toFile());
|
|
+ org.bukkit.configuration.ConfigurationSection worlds = global.createSection(legacyWorldsSectionKey);
|
|
+ worlds.set(legacyWorldDefaultsSectionKey, org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(this.globalFolder.resolve(this.defaultWorldConfigFileName).toFile()));
|
|
+ for (ServerLevel level : server.getAllLevels()) {
|
|
+ worlds.set(level.getWorld().getName(), org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(getWorldConfigFile(level).toFile()));
|
|
+ }
|
|
+ return global;
|
|
+ }
|
|
+
|
|
+ public abstract int getWorldConfigurationCurrentVersion();
|
|
+
|
|
+ // Gale end - Gale configuration
|
|
+
|
|
}
|
|
diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
|
|
index 266932720ae0af0f17df18ad1570b29631ed2c2a..58d250bfd14690ed79ca7716b584cc3f91d0e7e6 100644
|
|
--- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
|
|
+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
|
|
@@ -334,7 +334,7 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
|
|
}
|
|
}
|
|
|
|
- private static ContextMap createWorldContextMap(ServerLevel level) {
|
|
+ public static ContextMap createWorldContextMap(ServerLevel level) { // Gale - Gale configuration
|
|
return createWorldContextMap(level.levelStorageAccess.levelDirectory.path(), level.serverLevelData.getLevelName(), level.dimension().location(), level.spigotConfig, level.registryAccess(), level.getGameRules());
|
|
}
|
|
|
|
@@ -437,17 +437,6 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
|
|
return Files.exists(legacyConfig) && Files.isRegularFile(legacyConfig);
|
|
}
|
|
|
|
- @Deprecated
|
|
- public YamlConfiguration createLegacyObject(final MinecraftServer server) {
|
|
- YamlConfiguration global = YamlConfiguration.loadConfiguration(this.globalFolder.resolve(this.globalConfigFileName).toFile());
|
|
- ConfigurationSection worlds = global.createSection("__________WORLDS__________");
|
|
- worlds.set("__defaults__", YamlConfiguration.loadConfiguration(this.globalFolder.resolve(this.defaultWorldConfigFileName).toFile()));
|
|
- for (ServerLevel level : server.getAllLevels()) {
|
|
- worlds.set(level.getWorld().getName(), YamlConfiguration.loadConfiguration(getWorldConfigFile(level).toFile()));
|
|
- }
|
|
- return global;
|
|
- }
|
|
-
|
|
@Deprecated
|
|
public static YamlConfiguration loadLegacyConfigFile(File configFile) throws Exception {
|
|
YamlConfiguration config = new YamlConfiguration();
|
|
@@ -470,9 +459,16 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
|
|
}
|
|
|
|
// Symlinks are not correctly checked in createDirectories
|
|
- static void createDirectoriesSymlinkAware(Path path) throws IOException {
|
|
+ public static void createDirectoriesSymlinkAware(Path path) throws IOException { // Gale - Gale configuration
|
|
if (!Files.isDirectory(path)) {
|
|
Files.createDirectories(path);
|
|
}
|
|
}
|
|
+
|
|
+ // Gale start - Gale configuration
|
|
+ @Override
|
|
+ public int getWorldConfigurationCurrentVersion() {
|
|
+ return WorldConfiguration.CURRENT_VERSION;
|
|
+ }
|
|
+ // Gale end - Gale configuration
|
|
}
|
|
diff --git a/src/main/java/io/papermc/paper/configuration/mapping/InnerClassFieldDiscoverer.java b/src/main/java/io/papermc/paper/configuration/mapping/InnerClassFieldDiscoverer.java
|
|
index 05339a176083af667c16f77d76dc1878dafce3f0..9ca55cba185b9de566f911b08d671bee50bca075 100644
|
|
--- a/src/main/java/io/papermc/paper/configuration/mapping/InnerClassFieldDiscoverer.java
|
|
+++ b/src/main/java/io/papermc/paper/configuration/mapping/InnerClassFieldDiscoverer.java
|
|
@@ -46,7 +46,19 @@ public final class InnerClassFieldDiscoverer implements FieldDiscoverer<Map<Fiel
|
|
return new InnerClassFieldDiscoverer(overrides);
|
|
}
|
|
|
|
- public static FieldDiscoverer<?> globalConfig() {
|
|
+ // Gale start - Gale configuration
|
|
+ public static FieldDiscoverer<?> galeWorldConfig(io.papermc.paper.configuration.Configurations.ContextMap contextMap) {
|
|
+ final Map<Class<?>, Object> overrides = Map.of(
|
|
+ org.galemc.gale.configuration.GaleWorldConfiguration.class, new org.galemc.gale.configuration.GaleWorldConfiguration(
|
|
+ contextMap.require(io.papermc.paper.configuration.PaperConfigurations.SPIGOT_WORLD_CONFIG_CONTEXT_KEY).get(),
|
|
+ contextMap.require(io.papermc.paper.configuration.Configurations.WORLD_KEY)
|
|
+ )
|
|
+ );
|
|
+ return new InnerClassFieldDiscoverer(overrides);
|
|
+ }
|
|
+ // Gale end - Gale configuration
|
|
+
|
|
+ public static FieldDiscoverer<?> globalConfig() { // Gale - Gale configuration
|
|
return new InnerClassFieldDiscoverer(Collections.emptyMap());
|
|
}
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index 1da86b25e3b89c79d4f3920c8d2ef10ee2757f65..c92adb939892e1054f7b2d24070f43e6104dda2b 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -1073,6 +1073,7 @@ public final class CraftServer implements Server {
|
|
|
|
org.spigotmc.SpigotConfig.init((File) this.console.options.valueOf("spigot-settings")); // Spigot
|
|
this.console.paperConfigurations.reloadConfigs(this.console);
|
|
+ this.console.galeConfigurations.reloadConfigs(this.console); // Gale - Gale configuration
|
|
for (ServerLevel world : this.console.getAllLevels()) {
|
|
// world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty
|
|
world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean))
|
|
@@ -2967,6 +2968,14 @@ public final class CraftServer implements Server {
|
|
return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console);
|
|
}
|
|
|
|
+ // Gale start - Gale configuration - API
|
|
+ @Override
|
|
+ public YamlConfiguration getGaleConfig()
|
|
+ {
|
|
+ return CraftServer.this.console.galeConfigurations.createLegacyObject(CraftServer.this.console);
|
|
+ }
|
|
+ // Gale end - Gale configuration - API
|
|
+
|
|
@Override
|
|
public void restart() {
|
|
CraftServer.this.restart();
|