mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-22 16:29:16 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@2ef589c okaaay let's go PaperMC/Paper@d0028b7 you saw nothing PaperMC/Paper@e080b20 Bundles are no longer experimental (thanks lynx) PaperMC/Paper@d280061 First batch of server patches PaperMC/Paper@3585434 first 100! PaperMC/Paper@6b27267 oops PaperMC/Paper@152e82c Some work PaperMC/Paper@9e92fed More work? PaperMC/Paper@f1649d7 Work it PaperMC/Paper@9d63c81 Work work work PaperMC/Paper@dc5af48 Breakpoint before projectile mess PaperMC/Paper@7c04a31 Update projectile launch to 1.21.2 PaperMC/Paper@a400929 242 PaperMC/Paper@8851d25 Fluid Flowing ifLoaded patch PaperMC/Paper@f677393 Skip Improve-exact-choice-recipe-ingredients for now PaperMC/Paper@5e262c1 298 PaperMC/Paper@aa37f72 Patches PaperMC/Paper@af125d2 Patch PaperMC/Paper@6bfc6db Patch PaperMC/Paper@09b625e 400 PaperMC/Paper@1f8b537 440 PaperMC/Paper@f5177aa Some more work PaperMC/Paper@2810f50 503 PaperMC/Paper@0bb4d1d 553 PaperMC/Paper@4db2503 Work work work work PaperMC/Paper@cbf6416 A bunch of patches PaperMC/Paper@6456b5d A bunch more 637 PaperMC/Paper@cb79de8 moooore PaperMC/Paper@1dc1425 MOOOOORE PaperMC/Paper@d52e2d2 MOOOOOOOORE PaperMC/Paper@4baf9ab MOOOOOOOOOOORE PaperMC/Paper@dd87f9f fix gruesome copyright violation PaperMC/Paper@5a6011c MOOOOOOOOOOOOOORE PaperMC/Paper@5d19e2b good luck americans PaperMC/Paper@457d035 Patches, patches, patches PaperMC/Paper@80de05f Patch me this, patch me that PaperMC/Paper@26f7b4c Patch PaperMC/Paper@89bf081 Patch PaperMC/Paper@7d4cce9 Patch PaperMC/Paper@b237528 Readd wrongly removed diff PaperMC/Paper@fc05430 963 PaperMC/Paper@9047541 Upstream update PaperMC/Paper@d67e55d Checkpoint PaperMC/Paper@fe142cd Anti Xray PaperMC/Paper@35e01d7 Update work 989 PaperMC/Paper@7616ebc 1000 PaperMC/Paper@6a31574 1020 PaperMC/Paper@227caac Wrong attempt at Tag lifecycle PaperMC/Paper@afbb0d8 1037 PaperMC/Paper@b06e0b0 Work on compile errors PaperMC/Paper@9c83387 Compile issues 1 PaperMC/Paper@0f011a3 Some more compile issues PaperMC/Paper@6fb86bb Compiler issues v2 PaperMC/Paper@918ca96 Compiler issues v3 PaperMC/Paper@bb124f4 Compiler issues v4 PaperMC/Paper@0a8fd78 Compiler issue v5 PaperMC/Paper@e19f484 Test compile fixes PaperMC/Paper@3518974 fix some issues PaperMC/Paper@6df21e6 Start Moonrise update PaperMC/Paper@47258a7 Move common diffs to MCUtils PaperMC/Paper@ecf4d97 Begin fixing issues PaperMC/Paper@8e569ba Merge patches PaperMC/Paper@3b31621 Implement config hooks in PaperHooks PaperMC/Paper@e9c58f5 Implement chunk tick iteration optimisations PaperMC/Paper@2a95ad1 Implement explosion optimisations PaperMC/Paper@16d2c9d Implement Starlight PaperMC/Paper@3d7b570 Implement chunk system PaperMC/Paper@1d341df Fix some compile errors from patches PaperMC/Paper@6daedd7 Prepare rebase PaperMC/Paper@75e3409 Complete rebase, start review PaperMC/Paper@f1a11a6 Finish mixin diff review PaperMC/Paper@a911f4a Prepare rebase PaperMC/Paper@35ef293 Finish rebase PaperMC/Paper@9ecf77e Fix compile issues PaperMC/Paper@62e3bcd Review patch-to-patch diff PaperMC/Paper@b711764 Rebase fixups PaperMC/Paper@2e76d3f Specify mainCapabilityAttribute for paper-api PaperMC/Paper@e4efb59 fix compile issues PaperMC/Paper@683ce20 Fix Anti-Xray using wrong data in chunk deserialize PaperMC/Paper@e92607c Fix MSPT command PaperMC/Paper@dcd81a8 Fix crafting (and server icon) PaperMC/Paper@61136fe Add max minecarft speed gamerule config PaperMC/Paper@ba1ee87 Revert "Add max minecarft speed gamerule config" PaperMC/Paper@cf03bed Add startup flag to disable gamerule limits PaperMC/Paper@be2edea Fix boats/minecarts not dropping when destroyed PaperMC/Paper@b14d336 Apply watchdoge patches PaperMC/Paper@2946dbb Update WorldServer#serverlevelData mapping PaperMC/Paper@98af0e0 update generator PaperMC/Paper@20507b4 Apply more patches PaperMC/Paper@7162ff0 fix item meta PaperMC/Paper@7d67d3f fix DamageTypeTags init PaperMC/Paper@0971875 re-add improve perf of mass crafts PaperMC/Paper@bcf52fe Delete some old patches PaperMC/Paper@348c855 Readd last API patch (with TODO) PaperMC/Paper@b630564 More patches PaperMC/Paper@3cb16c9 Add back per player mob spawning PaperMC/Paper@fe7b741 Another one PaperMC/Paper@12ed021 Update material tags and entity effect PaperMC/Paper@02bca1e Remove timings impl PaperMC/Paper@4d87302 Fix NPE and StackOverflowError for dispensers PaperMC/Paper@f8f230a Remove unnecessary AT PaperMC/Paper@29bf7be Fix unused parameter in PlayerList#remove PaperMC/Paper@9e35192 Execute spark tasks during tick sleep (#11525) PaperMC/Paper@e35f199 Use declaration order for state holder property iteration PaperMC/Paper@6288adb Remove leftover missed timings calls (#11527) PaperMC/Paper@99b1bf9 Use new ClientboundPlayerRotationPacket for setting player rotation PaperMC/Paper@40211a0 Update Gradle wrapper to 8.10.2 PaperMC/Paper@49eae0d remove some leftovers PaperMC/Paper@d576cfc cleanup bugfix patch PaperMC/Paper@1196ab5 Avoid issues with certain tasks not processing during sleep (#11526) PaperMC/Paper@fe2f3d4 Fix portal exit resulting in bad teleport transition PaperMC/Paper@9f1fa0b Fix item gravity on inactive items, remove dumb active skipping PaperMC/Paper@1a1d0cf Use target pitch in teleport (generally the same thing) PaperMC/Paper@8ba3073 fix "is_freezing" damage type tag PaperMC/Paper@1523212 don't resend effects when PlayerItemConsumeEvent is cancelled PaperMC/Paper@1330880 Add Friction API to minecarts PaperMC/Paper@580a610 Allow using old ender pearl behavior & apply ender pearl exploit patch (#11524) PaperMC/Paper@40a960d Rebuild patches
1276 lines
65 KiB
Diff
1276 lines
65 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: "kfian294ma4@gmail.com" <kfian294ma4@gmail.com>
|
|
Date: Sun, 5 Sep 2021 18:01:34 +0100
|
|
Subject: [PATCH] Sakura Configuration Files
|
|
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/configuration/Configurations.java b/src/main/java/io/papermc/paper/configuration/Configurations.java
|
|
index 87e5f614ba988547a827486740db217e28585773..0375c9eb296ba7e8ed64e8d00dbc13a581dd4f90 100644
|
|
--- a/src/main/java/io/papermc/paper/configuration/Configurations.java
|
|
+++ b/src/main/java/io/papermc/paper/configuration/Configurations.java
|
|
@@ -96,7 +96,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) { // Sakura - package-protected -> public
|
|
return node -> {
|
|
ObjectMapper.Factory factory = (ObjectMapper.Factory) Objects.requireNonNull(node.options().serializers().get(type));
|
|
ObjectMapper.Mutable<T> mutable = (ObjectMapper.Mutable<T>) factory.get(type);
|
|
@@ -231,7 +231,7 @@ public abstract class Configurations<G, W> {
|
|
.path(worldConfigFile)
|
|
.build();
|
|
final ConfigurationNode worldNode = worldLoader.load();
|
|
- if (newFile) { // set the version field if new file
|
|
+ if (newFile && this instanceof PaperConfigurations) { // Sakura - hack this into working // set the version field if new file
|
|
worldNode.node(Configuration.VERSION_FIELD).set(this.worldConfigVersion());
|
|
} else {
|
|
this.verifyWorldConfigVersion(contextMap, worldNode);
|
|
diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
|
|
index 1029b6de6f36b08bf634b4056ef5701383f6f258..4b4087c316460c8ae262b62746430f521a9cc1a2 100644
|
|
--- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
|
|
+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
|
|
@@ -165,7 +165,7 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
|
|
.defaultOptions(PaperConfigurations::defaultOptions);
|
|
}
|
|
|
|
- private static ConfigurationOptions defaultOptions(ConfigurationOptions options) {
|
|
+ public static ConfigurationOptions defaultOptions(ConfigurationOptions options) { // Sakura - sakura configuration files
|
|
return options.serializers(builder -> builder
|
|
.register(MapSerializer.TYPE, new MapSerializer(false))
|
|
.register(new EnumValueSerializer())
|
|
@@ -459,7 +459,7 @@ 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 { // Sakura - package-protected -> public
|
|
if (!Files.isDirectory(path)) {
|
|
Files.createDirectories(path);
|
|
}
|
|
diff --git a/src/main/java/me/samsuik/sakura/command/BaseSubCommand.java b/src/main/java/me/samsuik/sakura/command/BaseSubCommand.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..87d8fd1fe60dfea4ce697048a34d9bb888cb6d4b
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/command/BaseSubCommand.java
|
|
@@ -0,0 +1,45 @@
|
|
+package me.samsuik.sakura.command;
|
|
+
|
|
+import org.bukkit.command.Command;
|
|
+import org.bukkit.command.CommandSender;
|
|
+import org.checkerframework.checker.nullness.qual.NonNull;
|
|
+import org.checkerframework.framework.qual.DefaultQualifier;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+
|
|
+import java.util.ArrayList;
|
|
+import java.util.List;
|
|
+
|
|
+@DefaultQualifier(NonNull.class)
|
|
+public abstract class BaseSubCommand extends Command {
|
|
+ public BaseSubCommand(String name) {
|
|
+ super(name);
|
|
+ this.description = "Sakura Command " + name;
|
|
+ this.setPermission("bukkit.command." + name);
|
|
+ }
|
|
+
|
|
+ public abstract void execute(CommandSender sender, String[] args);
|
|
+
|
|
+ public void tabComplete(List<String> list, String[] args) throws IllegalArgumentException {}
|
|
+
|
|
+ @Override
|
|
+ @Deprecated
|
|
+ public final boolean execute(CommandSender sender, String label, String[] args) {
|
|
+ if (this.testPermission(sender)) {
|
|
+ this.execute(sender, args);
|
|
+ }
|
|
+
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ @NotNull
|
|
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
|
|
+ List<String> completions = new ArrayList<>(0);
|
|
+
|
|
+ if (this.testPermissionSilent(sender)) {
|
|
+ this.tabComplete(completions, args);
|
|
+ }
|
|
+
|
|
+ return completions;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/me/samsuik/sakura/command/SakuraCommand.java b/src/main/java/me/samsuik/sakura/command/SakuraCommand.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..f46883c6206b56af1b9f125b9b361e7efc666b49
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/command/SakuraCommand.java
|
|
@@ -0,0 +1,86 @@
|
|
+package me.samsuik.sakura.command;
|
|
+
|
|
+import net.kyori.adventure.text.Component;
|
|
+import net.kyori.adventure.text.format.NamedTextColor;
|
|
+import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
+import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
|
+import net.minecraft.server.MinecraftServer;
|
|
+import org.bukkit.command.Command;
|
|
+import org.bukkit.command.CommandSender;
|
|
+import org.checkerframework.checker.nullness.qual.NonNull;
|
|
+import org.checkerframework.framework.qual.DefaultQualifier;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+
|
|
+import java.util.ArrayList;
|
|
+import java.util.Arrays;
|
|
+import java.util.Collections;
|
|
+import java.util.List;
|
|
+import java.util.stream.Stream;
|
|
+
|
|
+@DefaultQualifier(NonNull.class)
|
|
+public final class SakuraCommand extends Command {
|
|
+ private static final Component HEADER_MESSAGE = MiniMessage.miniMessage().deserialize("""
|
|
+ <dark_purple>.</dark_purple>
|
|
+ <dark_purple>| <white>This is the main command for <gradient:red:light_purple:0.5>Sakura</gradient>.
|
|
+ <dark_purple>| <white>All exclusive commands are listed below."""
|
|
+ );
|
|
+
|
|
+ private static final String COMMAND_MSG = "<dark_purple>| <dark_gray>*</dark_gray> /<light_purple><command>";
|
|
+
|
|
+ public SakuraCommand(String name) {
|
|
+ super(name);
|
|
+ this.description = "";
|
|
+ this.usageMessage = "/sakura";
|
|
+ this.setPermission("bukkit.command.sakura");
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
|
+ if (args.length > 0) {
|
|
+ List<Command> commands = new ArrayList<>(SakuraCommands.COMMANDS.values());
|
|
+
|
|
+ // This part is copied from the VersionCommand SubCommand in paper
|
|
+ Command internalVersion = MinecraftServer.getServer().server.getCommandMap().getCommand("version");
|
|
+ if (internalVersion != null) {
|
|
+ commands.add(internalVersion);
|
|
+ }
|
|
+
|
|
+ for (Command base : commands) {
|
|
+ if (base.getName().equalsIgnoreCase(args[0])) {
|
|
+ return base.execute(sender, commandLabel, Arrays.copyOfRange(args, 1, args.length));
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ this.sendHelpMessage(sender);
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ private void sendHelpMessage(CommandSender sender) {
|
|
+ sender.sendMessage(HEADER_MESSAGE);
|
|
+
|
|
+ Stream<Command> uniqueCommands = SakuraCommands.COMMANDS.values()
|
|
+ .stream()
|
|
+ .filter(command -> command != this);
|
|
+
|
|
+ uniqueCommands.forEach((command) -> {
|
|
+ sender.sendRichMessage(COMMAND_MSG, Placeholder.unparsed("command", command.getName()));
|
|
+ });
|
|
+
|
|
+ sender.sendMessage(Component.text("'", NamedTextColor.DARK_PURPLE));
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ @Override
|
|
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
|
|
+ if (!this.testPermissionSilent(sender)) {
|
|
+ return Collections.emptyList();
|
|
+ }
|
|
+
|
|
+ return SakuraCommands.COMMANDS.values().stream()
|
|
+ .filter(command -> command != this)
|
|
+ .map(Command::getName)
|
|
+ .filter(name -> args.length <= 1 || name.startsWith(args[args.length - 1]))
|
|
+ .toList();
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/me/samsuik/sakura/command/SakuraCommands.java b/src/main/java/me/samsuik/sakura/command/SakuraCommands.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..3e85c19db0655034c203eaab8d2e6b5504da5da8
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/command/SakuraCommands.java
|
|
@@ -0,0 +1,22 @@
|
|
+package me.samsuik.sakura.command;
|
|
+
|
|
+import me.samsuik.sakura.command.subcommands.ConfigCommand;
|
|
+import net.minecraft.server.MinecraftServer;
|
|
+import org.bukkit.command.Command;
|
|
+
|
|
+import java.util.HashMap;
|
|
+import java.util.Map;
|
|
+
|
|
+public final class SakuraCommands {
|
|
+ static final Map<String, Command> COMMANDS = new HashMap<>();
|
|
+ static {
|
|
+ COMMANDS.put("sakura", new SakuraCommand("sakura"));
|
|
+ COMMANDS.put("config", new ConfigCommand("config"));
|
|
+ }
|
|
+
|
|
+ public static void registerCommands(MinecraftServer server) {
|
|
+ COMMANDS.forEach((s, command) -> {
|
|
+ server.server.getCommandMap().register(s, "sakura", command);
|
|
+ });
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/me/samsuik/sakura/command/subcommands/ConfigCommand.java b/src/main/java/me/samsuik/sakura/command/subcommands/ConfigCommand.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..c41f188fdaf510a127771b1782e957058b8cc355
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/command/subcommands/ConfigCommand.java
|
|
@@ -0,0 +1,33 @@
|
|
+package me.samsuik.sakura.command.subcommands;
|
|
+
|
|
+import me.samsuik.sakura.command.BaseSubCommand;
|
|
+import net.minecraft.server.MinecraftServer;
|
|
+import org.bukkit.command.Command;
|
|
+import org.bukkit.command.CommandSender;
|
|
+import org.bukkit.craftbukkit.CraftServer;
|
|
+import org.checkerframework.checker.nullness.qual.NonNull;
|
|
+import org.checkerframework.framework.qual.DefaultQualifier;
|
|
+
|
|
+import static net.kyori.adventure.text.Component.text;
|
|
+import static net.kyori.adventure.text.format.NamedTextColor.GREEN;
|
|
+import static net.kyori.adventure.text.format.NamedTextColor.RED;
|
|
+
|
|
+@DefaultQualifier(NonNull.class)
|
|
+public final class ConfigCommand extends BaseSubCommand {
|
|
+ public ConfigCommand(String name) {
|
|
+ super(name);
|
|
+ this.description = "Command for reloading the sakura configuration file";
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void execute(CommandSender sender, String[] args) {
|
|
+ Command.broadcastCommandMessage(sender, text("Please note that this command is not supported and may cause issues.", RED));
|
|
+ Command.broadcastCommandMessage(sender, text("If you encounter any issues please use the /stop command to restart your server.", RED));
|
|
+
|
|
+ MinecraftServer server = ((CraftServer) sender.getServer()).getServer();
|
|
+ server.sakuraConfigurations.reloadConfigs(server);
|
|
+ server.server.reloadCount++;
|
|
+
|
|
+ Command.broadcastCommandMessage(sender, text("Sakura config reload complete.", GREEN));
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/me/samsuik/sakura/configuration/GlobalConfiguration.java b/src/main/java/me/samsuik/sakura/configuration/GlobalConfiguration.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..1b49023726fc80231ba952c555923228130a2bdb
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/configuration/GlobalConfiguration.java
|
|
@@ -0,0 +1,62 @@
|
|
+package me.samsuik.sakura.configuration;
|
|
+
|
|
+import com.mojang.logging.LogUtils;
|
|
+import io.papermc.paper.configuration.Configuration;
|
|
+import io.papermc.paper.configuration.ConfigurationPart;
|
|
+import io.papermc.paper.configuration.type.number.IntOr;
|
|
+import org.bukkit.Material;
|
|
+import org.slf4j.Logger;
|
|
+import org.spongepowered.configurate.objectmapping.meta.Comment;
|
|
+import org.spongepowered.configurate.objectmapping.meta.Setting;
|
|
+
|
|
+@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic", "RedundantSuppression"})
|
|
+public final class GlobalConfiguration extends ConfigurationPart {
|
|
+
|
|
+ private static final Logger LOGGER = LogUtils.getClassLogger();
|
|
+ static final int CURRENT_VERSION = 3;// (when you change the version, change the comment, so it conflicts on rebases): rename filter bad nbt from spawn eggs
|
|
+
|
|
+ private static GlobalConfiguration instance;
|
|
+ public static GlobalConfiguration get() {
|
|
+ return instance;
|
|
+ }
|
|
+
|
|
+ static void set(GlobalConfiguration instance) {
|
|
+ GlobalConfiguration.instance = instance;
|
|
+ }
|
|
+
|
|
+ @Setting(Configuration.VERSION_FIELD)
|
|
+ public int version = CURRENT_VERSION;
|
|
+
|
|
+ public Messages messages;
|
|
+ public class Messages extends ConfigurationPart {
|
|
+ public String durableBlockInteraction = "<dark_gray>(<light_purple>S</light_purple>) <white>This block has <gray><remaining></gray> of <gray><durability>";
|
|
+ public String fpsSettingChange = "<dark_gray>(<light_purple>S</light_purple>) <gray><state> <yellow><name>";
|
|
+ }
|
|
+
|
|
+ public Fps fps;
|
|
+ public class Fps extends ConfigurationPart {
|
|
+ public Material material = Material.PINK_STAINED_GLASS_PANE;
|
|
+ }
|
|
+
|
|
+ public Players players;
|
|
+ public class Players extends ConfigurationPart {
|
|
+ public IntOr.Default bucketStackSize = IntOr.Default.USE_DEFAULT;
|
|
+ }
|
|
+
|
|
+ public Environment environment;
|
|
+ public class Environment extends ConfigurationPart {
|
|
+ @Comment("This is only intended for plot worlds. Will affect chunk generation on servers.")
|
|
+ public boolean calculateBiomeNoiseOncePerChunkSection = false;
|
|
+
|
|
+ public MobSpawnerDefaults mobSpawnerDefaults = new MobSpawnerDefaults();
|
|
+ public class MobSpawnerDefaults extends ConfigurationPart {
|
|
+ public int minSpawnDelay = 200;
|
|
+ public int maxSpawnDelay = 800;
|
|
+ public int spawnCount = 4;
|
|
+ public int maxNearbyEntities = 6;
|
|
+ public int requiredPlayerRange = 16;
|
|
+ public int spawnRange = 4;
|
|
+ }
|
|
+ }
|
|
+
|
|
+}
|
|
diff --git a/src/main/java/me/samsuik/sakura/configuration/SakuraConfigurations.java b/src/main/java/me/samsuik/sakura/configuration/SakuraConfigurations.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..9460afc669594ddb53b097ae105abb29da3a7e10
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/configuration/SakuraConfigurations.java
|
|
@@ -0,0 +1,241 @@
|
|
+package me.samsuik.sakura.configuration;
|
|
+
|
|
+import com.google.common.collect.Table;
|
|
+import com.mojang.logging.LogUtils;
|
|
+import io.leangen.geantyref.TypeToken;
|
|
+import io.papermc.paper.configuration.*;
|
|
+import io.papermc.paper.configuration.mapping.InnerClassFieldDiscoverer;
|
|
+import io.papermc.paper.configuration.serializer.*;
|
|
+import io.papermc.paper.configuration.serializer.collections.FastutilMapSerializer;
|
|
+import io.papermc.paper.configuration.serializer.collections.MapSerializer;
|
|
+import io.papermc.paper.configuration.serializer.collections.TableSerializer;
|
|
+import io.papermc.paper.configuration.serializer.registry.RegistryHolderSerializer;
|
|
+import io.papermc.paper.configuration.serializer.registry.RegistryValueSerializer;
|
|
+import io.papermc.paper.configuration.transformation.Transformations;
|
|
+import io.papermc.paper.configuration.type.BooleanOrDefault;
|
|
+import io.papermc.paper.configuration.type.Duration;
|
|
+import io.papermc.paper.configuration.type.DurationOrDisabled;
|
|
+import io.papermc.paper.configuration.type.number.DoubleOr;
|
|
+import io.papermc.paper.configuration.type.number.IntOr;
|
|
+import it.unimi.dsi.fastutil.objects.Reference2IntMap;
|
|
+import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
|
|
+import it.unimi.dsi.fastutil.objects.Reference2LongMap;
|
|
+import it.unimi.dsi.fastutil.objects.Reference2LongOpenHashMap;
|
|
+import me.samsuik.sakura.configuration.transformation.ConfigurationTransformations;
|
|
+import me.samsuik.sakura.configuration.transformation.global.V1_RelocateMessages;
|
|
+import me.samsuik.sakura.configuration.transformation.global.V2_ConvertIconToMaterial;
|
|
+import me.samsuik.sakura.configuration.transformation.world.*;
|
|
+import net.minecraft.core.RegistryAccess;
|
|
+import net.minecraft.core.registries.Registries;
|
|
+import net.minecraft.resources.ResourceLocation;
|
|
+import net.minecraft.server.MinecraftServer;
|
|
+import net.minecraft.server.level.ServerLevel;
|
|
+import net.minecraft.world.entity.EntityType;
|
|
+import net.minecraft.world.item.Item;
|
|
+import net.minecraft.world.level.block.Block;
|
|
+import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
|
+import org.checkerframework.checker.nullness.qual.Nullable;
|
|
+import org.jspecify.annotations.NullMarked;
|
|
+import org.slf4j.Logger;
|
|
+import org.spongepowered.configurate.ConfigurateException;
|
|
+import org.spongepowered.configurate.ConfigurationNode;
|
|
+import org.spongepowered.configurate.ConfigurationOptions;
|
|
+import org.spongepowered.configurate.NodePath;
|
|
+import org.spongepowered.configurate.objectmapping.FieldDiscoverer;
|
|
+import org.spongepowered.configurate.objectmapping.ObjectMapper;
|
|
+import org.spongepowered.configurate.transformation.ConfigurationTransformation;
|
|
+import org.spongepowered.configurate.transformation.TransformAction;
|
|
+import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
|
+
|
|
+import java.io.IOException;
|
|
+import java.lang.reflect.Type;
|
|
+import java.nio.file.Path;
|
|
+import java.util.Map;
|
|
+import java.util.function.Function;
|
|
+
|
|
+import static io.leangen.geantyref.GenericTypeReflector.erase;
|
|
+
|
|
+@NullMarked
|
|
+@SuppressWarnings("Convert2Diamond")
|
|
+public final class SakuraConfigurations extends Configurations<GlobalConfiguration, WorldConfiguration> {
|
|
+
|
|
+ private static final Logger LOGGER = LogUtils.getClassLogger();
|
|
+ static final String GLOBAL_CONFIG_FILE_NAME = "sakura-global.yml";
|
|
+ static final String WORLD_DEFAULTS_CONFIG_FILE_NAME = "sakura-world-defaults.yml";
|
|
+ static final String WORLD_CONFIG_FILE_NAME = "sakura-world.yml";
|
|
+ public static final String CONFIG_DIR = "config";
|
|
+
|
|
+ private static final String GLOBAL_HEADER = String.format("""
|
|
+ This is the global configuration file for Sakura.
|
|
+ As you can see, there's a lot to configure. Some options may impact gameplay, so use
|
|
+ with caution, and make sure you know what each option does before configuring.
|
|
+
|
|
+ The world configuration options have been moved inside
|
|
+ their respective world folder. The files are named %s""", WORLD_CONFIG_FILE_NAME);
|
|
+
|
|
+ private static final String WORLD_DEFAULTS_HEADER = """
|
|
+ This is the world defaults configuration file for Sakura.
|
|
+ As you can see, there's a lot to configure. Some options may impact gameplay, so use
|
|
+ with caution, and make sure you know what each option does before configuring.
|
|
+
|
|
+ Configuration options here apply to all worlds, unless you specify overrides inside
|
|
+ the world-specific config file inside each world folder.""";
|
|
+
|
|
+ private static final Function<ContextMap, String> WORLD_HEADER = map -> String.format("""
|
|
+ This is a world configuration file for Sakura.
|
|
+ This file may start empty but can be filled with settings to override ones in the %s/%s
|
|
+
|
|
+ World: %s (%s)""",
|
|
+ SakuraConfigurations.CONFIG_DIR,
|
|
+ SakuraConfigurations.WORLD_DEFAULTS_CONFIG_FILE_NAME,
|
|
+ map.require(WORLD_NAME),
|
|
+ map.require(WORLD_KEY)
|
|
+ );
|
|
+
|
|
+ public SakuraConfigurations(final Path globalFolder) {
|
|
+ super(globalFolder, GlobalConfiguration.class, WorldConfiguration.class, GLOBAL_CONFIG_FILE_NAME, WORLD_DEFAULTS_CONFIG_FILE_NAME, WORLD_CONFIG_FILE_NAME);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ protected YamlConfigurationLoader.Builder createLoaderBuilder() {
|
|
+ return super.createLoaderBuilder()
|
|
+ .defaultOptions(PaperConfigurations::defaultOptions);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ protected ObjectMapper.Factory.Builder createGlobalObjectMapperFactoryBuilder() {
|
|
+ return defaultGlobalFactoryBuilder(super.createGlobalObjectMapperFactoryBuilder());
|
|
+ }
|
|
+
|
|
+ private static ObjectMapper.Factory.Builder defaultGlobalFactoryBuilder(ObjectMapper.Factory.Builder builder) {
|
|
+ return builder.addDiscoverer(InnerClassFieldDiscoverer.globalConfig());
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ protected YamlConfigurationLoader.Builder createGlobalLoaderBuilder() {
|
|
+ return super.createGlobalLoaderBuilder()
|
|
+ .defaultOptions(SakuraConfigurations::defaultGlobalOptions);
|
|
+ }
|
|
+
|
|
+ private static ConfigurationOptions defaultGlobalOptions(ConfigurationOptions options) {
|
|
+ return options
|
|
+ .header(GLOBAL_HEADER)
|
|
+ .serializers(builder -> builder
|
|
+ .register(new PacketClassSerializer())
|
|
+ );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public GlobalConfiguration initializeGlobalConfiguration(final RegistryAccess registryAccess) throws ConfigurateException {
|
|
+ GlobalConfiguration configuration = super.initializeGlobalConfiguration(registryAccess);
|
|
+ GlobalConfiguration.set(configuration);
|
|
+ return configuration;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ protected ObjectMapper.Factory.Builder createWorldObjectMapperFactoryBuilder(final ContextMap contextMap) {
|
|
+ return super.createWorldObjectMapperFactoryBuilder(contextMap)
|
|
+ .addNodeResolver(new NestedSetting.Factory())
|
|
+ .addDiscoverer(createWorldConfigFieldDiscoverer(contextMap));
|
|
+ }
|
|
+
|
|
+ private static FieldDiscoverer<?> createWorldConfigFieldDiscoverer(final ContextMap contextMap) {
|
|
+ final Map<Class<?>, Object> overrides = Map.of(
|
|
+ WorldConfiguration.class, createWorldConfigInstance(contextMap)
|
|
+ );
|
|
+ return new InnerClassFieldDiscoverer(overrides);
|
|
+ }
|
|
+
|
|
+ private static WorldConfiguration createWorldConfigInstance(ContextMap contextMap) {
|
|
+ return new WorldConfiguration(contextMap.require(Configurations.WORLD_KEY));
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ protected YamlConfigurationLoader.Builder createWorldConfigLoaderBuilder(final ContextMap contextMap) {
|
|
+ final RegistryAccess access = contextMap.require(REGISTRY_ACCESS);
|
|
+ return super.createWorldConfigLoaderBuilder(contextMap)
|
|
+ .defaultOptions(options -> options
|
|
+ .header(contextMap.require(WORLD_NAME).equals(WORLD_DEFAULTS) ? WORLD_DEFAULTS_HEADER : WORLD_HEADER.apply(contextMap))
|
|
+ .serializers(serializers -> serializers
|
|
+ .register(new TypeToken<Reference2IntMap<?>>() {}, new FastutilMapSerializer.SomethingToPrimitive<Reference2IntMap<?>>(Reference2IntOpenHashMap::new, Integer.TYPE))
|
|
+ .register(new TypeToken<Reference2LongMap<?>>() {}, new FastutilMapSerializer.SomethingToPrimitive<Reference2LongMap<?>>(Reference2LongOpenHashMap::new, Long.TYPE))
|
|
+ .register(new TypeToken<Table<?, ?, ?>>() {}, new TableSerializer())
|
|
+ .register(StringRepresentableSerializer::isValidFor, new StringRepresentableSerializer())
|
|
+ .register(new RegistryValueSerializer<>(new TypeToken<EntityType<?>>() {}, access, Registries.ENTITY_TYPE, true))
|
|
+ .register(new RegistryValueSerializer<>(Item.class, access, Registries.ITEM, true))
|
|
+ .register(new RegistryValueSerializer<>(Block.class, access, Registries.BLOCK, true))
|
|
+ .register(new RegistryHolderSerializer<>(new TypeToken<ConfiguredFeature<?, ?>>() {}, access, Registries.CONFIGURED_FEATURE, false))
|
|
+ )
|
|
+ );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ protected void applyWorldConfigTransformations(final ContextMap contextMap, final ConfigurationNode node, final @Nullable ConfigurationNode defaultsNode) throws ConfigurateException {
|
|
+ ConfigurationTransformations.worldTransformations(node);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ protected void applyGlobalConfigTransformations(final ConfigurationNode node) throws ConfigurateException {
|
|
+ ConfigurationTransformations.globalTransformations(node);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public WorldConfiguration createWorldConfig(final ContextMap contextMap) {
|
|
+ final String levelName = contextMap.require(WORLD_NAME);
|
|
+ try {
|
|
+ return super.createWorldConfig(contextMap);
|
|
+ } catch (IOException exception) {
|
|
+ throw new RuntimeException("Could not create world config for " + levelName, exception);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ protected boolean isConfigType(final Type type) {
|
|
+ return ConfigurationPart.class.isAssignableFrom(erase(type));
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ protected int globalConfigVersion() {
|
|
+ return GlobalConfiguration.CURRENT_VERSION;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ protected int worldConfigVersion() {
|
|
+ return WorldConfiguration.CURRENT_VERSION;
|
|
+ }
|
|
+
|
|
+ public void reloadConfigs(MinecraftServer server) {
|
|
+ try {
|
|
+ this.initializeGlobalConfiguration(reloader(this.globalConfigClass, GlobalConfiguration.get()));
|
|
+ this.initializeWorldDefaultsConfiguration(server.registryAccess());
|
|
+ for (ServerLevel level : server.getAllLevels()) {
|
|
+ this.createWorldConfig(createWorldContextMap(level), reloader(this.worldConfigClass, level.sakuraConfig()));
|
|
+ }
|
|
+ } catch (Exception ex) {
|
|
+ throw new RuntimeException("Could not reload sakura configuration files", ex);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ private static ContextMap createWorldContextMap(ServerLevel level) {
|
|
+ return createWorldContextMap(level.convertable.levelDirectory.path(), level.serverLevelData.getLevelName(), level.dimension().location(), level.registryAccess());
|
|
+ }
|
|
+
|
|
+ public static ContextMap createWorldContextMap(Path dir, String levelName, ResourceLocation worldKey, RegistryAccess registryAccess) {
|
|
+ return ContextMap.builder()
|
|
+ .put(WORLD_DIRECTORY, dir)
|
|
+ .put(WORLD_NAME, levelName)
|
|
+ .put(WORLD_KEY, worldKey)
|
|
+ .put(REGISTRY_ACCESS, registryAccess)
|
|
+ .build();
|
|
+ }
|
|
+
|
|
+ public static SakuraConfigurations setup(final Path configDir) {
|
|
+ try {
|
|
+ PaperConfigurations.createDirectoriesSymlinkAware(configDir);
|
|
+ return new SakuraConfigurations(configDir);
|
|
+ } catch (final IOException ex) {
|
|
+ throw new RuntimeException("Could not setup PaperConfigurations", ex);
|
|
+ }
|
|
+ }
|
|
+
|
|
+}
|
|
diff --git a/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..3ccd52a58996b60ec860fb50a509b92739f45b28
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java
|
|
@@ -0,0 +1,236 @@
|
|
+package me.samsuik.sakura.configuration;
|
|
+
|
|
+import com.mojang.logging.LogUtils;
|
|
+import io.papermc.paper.configuration.Configuration;
|
|
+import io.papermc.paper.configuration.ConfigurationPart;
|
|
+import io.papermc.paper.configuration.NestedSetting;
|
|
+import io.papermc.paper.configuration.PaperConfigurations;
|
|
+import io.papermc.paper.configuration.type.number.DoubleOr;
|
|
+import io.papermc.paper.configuration.type.number.IntOr;
|
|
+import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
|
|
+import me.samsuik.sakura.entity.merge.MergeLevel;
|
|
+import me.samsuik.sakura.explosion.durable.DurableMaterial;
|
|
+import me.samsuik.sakura.physics.PhysicsVersion;
|
|
+import net.minecraft.Util;
|
|
+import net.minecraft.resources.ResourceLocation;
|
|
+import net.minecraft.world.entity.EntityType;
|
|
+import net.minecraft.world.entity.item.FallingBlockEntity;
|
|
+import net.minecraft.world.item.Item;
|
|
+import net.minecraft.world.level.block.Block;
|
|
+import net.minecraft.world.level.block.Blocks;
|
|
+import org.slf4j.Logger;
|
|
+import org.spongepowered.configurate.objectmapping.meta.Comment;
|
|
+import org.spongepowered.configurate.objectmapping.meta.Setting;
|
|
+
|
|
+import java.util.List;
|
|
+import java.util.Map;
|
|
+
|
|
+@SuppressWarnings({"FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic", "RedundantSuppression"})
|
|
+public final class WorldConfiguration extends ConfigurationPart {
|
|
+
|
|
+ private static final Logger LOGGER = LogUtils.getClassLogger();
|
|
+ static final int CURRENT_VERSION = 6; // (when you change the version, change the comment, so it conflicts on rebases): rename filter bad nbt from spawn eggs
|
|
+
|
|
+ private transient final ResourceLocation worldKey;
|
|
+ WorldConfiguration(ResourceLocation worldKey) {
|
|
+ this.worldKey = worldKey;
|
|
+ }
|
|
+
|
|
+ public boolean isDefault() {
|
|
+ return this.worldKey.equals(PaperConfigurations.WORLD_DEFAULTS_KEY);
|
|
+ }
|
|
+
|
|
+ @Setting(Configuration.VERSION_FIELD)
|
|
+ public int version = CURRENT_VERSION;
|
|
+
|
|
+ public Cannons cannons;
|
|
+ public class Cannons extends ConfigurationPart {
|
|
+ public MergeLevel mergeLevel = MergeLevel.STRICT;
|
|
+ public boolean tntAndSandAffectedByBubbleColumns = true;
|
|
+
|
|
+ @NestedSetting({"treat-collidable-blocks-as-full", "while-moving"})
|
|
+ public boolean treatAllBlocksAsFullWhenMoving = false;
|
|
+ @NestedSetting({"treat-collidable-blocks-as-full", "moving-faster-than"})
|
|
+ public double treatAllBlocksAsFullWhenMovingFasterThan = 64.0;
|
|
+ public boolean loadChunks = false;
|
|
+
|
|
+ public Restrictions restrictions = new Restrictions();
|
|
+ public class Restrictions extends ConfigurationPart {
|
|
+ @Comment("The amount of blocks that can be travelled before changing direction is restricted")
|
|
+ public IntOr.Disabled leftShootingThreshold = IntOr.Disabled.DISABLED;
|
|
+ @Comment(
|
|
+ "Maximum amount of blocks that a cannon can adjust\n" +
|
|
+ "It is recommended that this value kept sane and is more than 64 blocks"
|
|
+ )
|
|
+ public IntOr.Disabled maxAdjustDistance = IntOr.Disabled.DISABLED;
|
|
+ }
|
|
+
|
|
+ public Tnt tnt = new Tnt();
|
|
+ public class Tnt extends ConfigurationPart {
|
|
+ public boolean forcePositionUpdates;
|
|
+ }
|
|
+
|
|
+ public Sand sand = new Sand();
|
|
+ public class Sand extends ConfigurationPart {
|
|
+ public boolean despawnInsideMovingPistons = true;
|
|
+ public boolean concreteSolidifyInWater = true;
|
|
+
|
|
+ @NestedSetting({"prevent-stacking", "against-border"})
|
|
+ public boolean preventAgainstBorder = false;
|
|
+ @NestedSetting({"prevent-stacking", "world-height"})
|
|
+ public boolean preventAtWorldHeight = false;
|
|
+
|
|
+ public boolean isFallingBlockInBounds(FallingBlockEntity entity) {
|
|
+ return (!this.preventAgainstBorder || !ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.isCollidingWithBorder(entity.level().getWorldBorder(), entity.getBoundingBox().inflate(0.01)))
|
|
+ && (!this.preventAtWorldHeight || entity.blockPosition().getY() < entity.level().getMaxY() - 1);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public Explosion explosion = new Explosion();
|
|
+ public class Explosion extends ConfigurationPart {
|
|
+ public boolean optimiseProtectedRegions = true;
|
|
+ public boolean avoidRedundantBlockSearches = false;
|
|
+ public Map<Block, DurableMaterial> durableMaterials = Util.make(new Reference2ObjectOpenHashMap<>(), map -> {
|
|
+ map.put(Blocks.OBSIDIAN, new DurableMaterial(4, Blocks.COBBLESTONE.getExplosionResistance()));
|
|
+ map.put(Blocks.ANVIL, new DurableMaterial(3, Blocks.END_STONE.getExplosionResistance()));
|
|
+ map.put(Blocks.CHIPPED_ANVIL, new DurableMaterial(3, Blocks.END_STONE.getExplosionResistance()));
|
|
+ map.put(Blocks.DAMAGED_ANVIL, new DurableMaterial(3, Blocks.END_STONE.getExplosionResistance()));
|
|
+ });
|
|
+ public boolean protectScaffoldingFromCreepers = false;
|
|
+ public boolean allowNonTntBreakingDurableBlocks = false;
|
|
+ public boolean destroyWaterloggedBlocks = false;
|
|
+ public boolean explodeLava = false;
|
|
+ public boolean consistentRadius = false;
|
|
+ public boolean explosionsHurtPlayers = true;
|
|
+ public boolean explosionsDropItems = true;
|
|
+ public boolean useBlockCacheAcrossExplosions = false;
|
|
+ }
|
|
+
|
|
+ public Mechanics mechanics = new Mechanics();
|
|
+ public class Mechanics extends ConfigurationPart {
|
|
+ public TNTSpread tntSpread = TNTSpread.ALL;
|
|
+ public boolean tntFlowsInWater = true;
|
|
+ public boolean fallingBlockParity = false;
|
|
+ public PhysicsVersion physicsVersion = PhysicsVersion.LATEST;
|
|
+
|
|
+ public enum TNTSpread {
|
|
+ ALL, Y, NONE;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public Technical technical;
|
|
+ public class Technical extends ConfigurationPart {
|
|
+ public boolean dispenserRandomItemSelection = true;
|
|
+ @Comment(
|
|
+ "Only tick hoppers when items are able to be moved\n" +
|
|
+ "This can cause issues with redstone contraptions that rely on DUD's to detect when hoppers fail to move items."
|
|
+ )
|
|
+ public boolean optimiseIdleHopperTicking = true;
|
|
+
|
|
+ public Redstone redstone = new Redstone();
|
|
+ public class Redstone extends ConfigurationPart {
|
|
+ public boolean redstoneCache = false;
|
|
+ public boolean fluidsBreakRedstone = true;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public Players players;
|
|
+ public class Players extends ConfigurationPart {
|
|
+ public Combat combat = new Combat();
|
|
+ public class Combat extends ConfigurationPart {
|
|
+ public boolean legacyCombatMechanics = false;
|
|
+ public boolean allowSweepAttacks = true;
|
|
+ public boolean shieldDamageReduction = false;
|
|
+ public boolean oldEnchantedGoldenApple = false;
|
|
+ public boolean oldSoundsAndParticleEffects = false;
|
|
+ public boolean fastHealthRegen = true;
|
|
+ public IntOr.Default maxArmourDamage = IntOr.Default.USE_DEFAULT;
|
|
+ }
|
|
+
|
|
+ public Knockback knockback = new Knockback();
|
|
+ public class Knockback extends ConfigurationPart {
|
|
+ public DoubleOr.Default knockbackVertical = DoubleOr.Default.USE_DEFAULT;
|
|
+ public double knockbackVerticalLimit = 0.4;
|
|
+ public boolean verticalKnockbackRequireGround = true;
|
|
+ public double baseKnockback = 0.4;
|
|
+ @Comment("Knockback caused by sweeping edge")
|
|
+ public double sweepingEdgeKnockback = 0.4;
|
|
+
|
|
+ public Sprinting sprinting = new Sprinting();
|
|
+ public class Sprinting extends ConfigurationPart {
|
|
+ public boolean requireFullAttack = true;
|
|
+ public double extraKnockback = 0.5;
|
|
+ @Comment("Delay between extra knockback hits in milliseconds")
|
|
+ public IntOr.Default knockbackDelay = IntOr.Default.USE_DEFAULT;
|
|
+ }
|
|
+
|
|
+ @NestedSetting({"projectiles", "fishing-hooks-apply-knockback"})
|
|
+ public boolean fishingHooksApplyKnockback;
|
|
+
|
|
+ @Comment("Knockback resistance attribute modifier")
|
|
+ public double knockbackResistanceModifier = 1.0;
|
|
+ @Comment("Received by attacking a shielded enemy")
|
|
+ public double shieldHitKnockback = 0.5;
|
|
+ }
|
|
+
|
|
+ @Comment("Prevents players swimming using elytra or riptide to enter holes")
|
|
+ public boolean posesShrinkCollisionBox = true;
|
|
+ public boolean fishingHooksPullEntities = true;
|
|
+ }
|
|
+
|
|
+ public Entity entity;
|
|
+ public class Entity extends ConfigurationPart {
|
|
+ @Comment("Only modify if you know what you're doing")
|
|
+ public boolean disableMobAi = false;
|
|
+ public boolean waterSensitivity = true;
|
|
+ public boolean instantDeathAnimation = false;
|
|
+ public boolean ironGolemsTakeFalldamage = false;
|
|
+
|
|
+ public Items items = new Items();
|
|
+ public class Items extends ConfigurationPart {
|
|
+ public List<Item> explosionResistantItems = List.of();
|
|
+ }
|
|
+
|
|
+ @Comment("Entity travel distance limits")
|
|
+ public Map<EntityType<?>, Integer> chunkTravelLimit = Util.make(new Reference2ObjectOpenHashMap<>(), map -> {
|
|
+ map.put(EntityType.ENDER_PEARL, 8);
|
|
+ });
|
|
+
|
|
+ public ThrownPotion thrownPotion = new ThrownPotion();
|
|
+ public class ThrownPotion extends ConfigurationPart {
|
|
+ public double horizontalSpeed = 1.0;
|
|
+ public double verticalSpeed = 1.0;
|
|
+ public boolean allowBreakingInsideEntities = false;
|
|
+ }
|
|
+
|
|
+ public EnderPearl enderPearl = new EnderPearl();
|
|
+ public class EnderPearl extends ConfigurationPart {
|
|
+ public boolean useOutlineForCollision = false;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public Environment environment;
|
|
+ public class Environment extends ConfigurationPart {
|
|
+ public boolean allowWaterInTheNether = false;
|
|
+ public boolean disableFastNetherLava = false;
|
|
+
|
|
+ public BlockGeneration blockGeneration = new BlockGeneration();
|
|
+ public class BlockGeneration extends ConfigurationPart {
|
|
+ public boolean legacyBlockFormation = false;
|
|
+ }
|
|
+
|
|
+ public Crops crops = new Crops();
|
|
+ public class Crops extends ConfigurationPart {
|
|
+ public boolean useRandomChanceToGrow = false;
|
|
+ }
|
|
+
|
|
+ public MobSpawner mobSpawner = new MobSpawner();
|
|
+ public class MobSpawner extends ConfigurationPart {
|
|
+ public boolean checkSpawnConditions = true;
|
|
+ public boolean requireNearbyPlayer = true;
|
|
+ public boolean ignoreEntityLimit = false;
|
|
+ }
|
|
+ }
|
|
+
|
|
+}
|
|
diff --git a/src/main/java/me/samsuik/sakura/configuration/transformation/ConfigurationTransformations.java b/src/main/java/me/samsuik/sakura/configuration/transformation/ConfigurationTransformations.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..154ab96b537efc3505cd85935150ddbe7ca1126f
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/configuration/transformation/ConfigurationTransformations.java
|
|
@@ -0,0 +1,46 @@
|
|
+package me.samsuik.sakura.configuration.transformation;
|
|
+
|
|
+import io.papermc.paper.configuration.transformation.Transformations;
|
|
+import me.samsuik.sakura.configuration.transformation.global.V1_RelocateMessages;
|
|
+import me.samsuik.sakura.configuration.transformation.global.V2_ConvertIconToMaterial;
|
|
+import me.samsuik.sakura.configuration.transformation.world.*;
|
|
+import org.spongepowered.configurate.ConfigurateException;
|
|
+import org.spongepowered.configurate.ConfigurationNode;
|
|
+import org.spongepowered.configurate.NodePath;
|
|
+import org.spongepowered.configurate.transformation.ConfigurationTransformation;
|
|
+import org.spongepowered.configurate.transformation.TransformAction;
|
|
+
|
|
+import java.util.List;
|
|
+
|
|
+public final class ConfigurationTransformations {
|
|
+ private static final List<NodePath> REMOVED_GLOBAL_PATHS = List.of(
|
|
+ NodePath.path("cannons")
|
|
+ );
|
|
+
|
|
+ public static void worldTransformations(final ConfigurationNode node) throws ConfigurateException {
|
|
+ final ConfigurationTransformation.VersionedBuilder versionedBuilder = Transformations.versionedBuilder();
|
|
+ V2_VerticalKnockbackUseDefault.apply(versionedBuilder);
|
|
+ V3_RenameKnockback.apply(versionedBuilder);
|
|
+ V4_RenameNonStrictMergeLevel.apply(versionedBuilder);
|
|
+ V5_CombineLoadChunksOptions.apply(versionedBuilder);
|
|
+ V6_FixIncorrectExtraKnockback.apply(versionedBuilder);
|
|
+ // ADD FUTURE VERSIONED TRANSFORMS TO versionedBuilder HERE
|
|
+ versionedBuilder.build().apply(node);
|
|
+ }
|
|
+
|
|
+ public static void globalTransformations(final ConfigurationNode node) throws ConfigurateException {
|
|
+ final ConfigurationTransformation.Builder builder = ConfigurationTransformation.builder();
|
|
+ for (final NodePath path : REMOVED_GLOBAL_PATHS) {
|
|
+ builder.addAction(path, TransformAction.remove());
|
|
+ }
|
|
+ builder.build().apply(node);
|
|
+
|
|
+ final ConfigurationTransformation.VersionedBuilder versionedBuilder = Transformations.versionedBuilder();
|
|
+ V1_RelocateMessages.apply(versionedBuilder);
|
|
+ V2_ConvertIconToMaterial.apply(versionedBuilder);
|
|
+ // ADD FUTURE VERSIONED TRANSFORMS TO versionedBuilder HERE
|
|
+ versionedBuilder.build().apply(node);
|
|
+ }
|
|
+
|
|
+ private ConfigurationTransformations() {}
|
|
+}
|
|
diff --git a/src/main/java/me/samsuik/sakura/configuration/transformation/global/V1_RelocateMessages.java b/src/main/java/me/samsuik/sakura/configuration/transformation/global/V1_RelocateMessages.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..6c72577e3fac9324ebe786e8d23969c3082ed618
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/configuration/transformation/global/V1_RelocateMessages.java
|
|
@@ -0,0 +1,31 @@
|
|
+package me.samsuik.sakura.configuration.transformation.global;
|
|
+
|
|
+import org.spongepowered.configurate.NodePath;
|
|
+import org.spongepowered.configurate.transformation.ConfigurationTransformation;
|
|
+import org.spongepowered.configurate.transformation.TransformAction;
|
|
+
|
|
+import java.util.Map;
|
|
+
|
|
+import static org.spongepowered.configurate.NodePath.path;
|
|
+
|
|
+public final class V1_RelocateMessages {
|
|
+ private static final int VERSION = 2; // targeted version is always ahead by one
|
|
+ private static final Map<NodePath, NodePath> RELOCATION = Map.of(
|
|
+ path("fps", "message"), path("messages", "fps-setting-change"),
|
|
+ path("players", "potato-message"), path("messages", "durable-block-interaction")
|
|
+ );
|
|
+
|
|
+ private V1_RelocateMessages() {}
|
|
+
|
|
+ public static void apply(ConfigurationTransformation.VersionedBuilder builder) {
|
|
+ ConfigurationTransformation.Builder transformationBuilder = ConfigurationTransformation.builder();
|
|
+ for (Map.Entry<NodePath, NodePath> entry : RELOCATION.entrySet()) {
|
|
+ transformationBuilder.addAction(entry.getKey(), relocate(entry.getValue()));
|
|
+ }
|
|
+ builder.addVersion(VERSION, transformationBuilder.build());
|
|
+ }
|
|
+
|
|
+ private static TransformAction relocate(NodePath path) {
|
|
+ return (node, object) -> path.array();
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/me/samsuik/sakura/configuration/transformation/global/V2_ConvertIconToMaterial.java b/src/main/java/me/samsuik/sakura/configuration/transformation/global/V2_ConvertIconToMaterial.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..c6f8bfeb83a7d108cd32caa0c88629aa49de81ff
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/configuration/transformation/global/V2_ConvertIconToMaterial.java
|
|
@@ -0,0 +1,28 @@
|
|
+package me.samsuik.sakura.configuration.transformation.global;
|
|
+
|
|
+import org.checkerframework.checker.nullness.qual.Nullable;
|
|
+import org.spongepowered.configurate.ConfigurateException;
|
|
+import org.spongepowered.configurate.ConfigurationNode;
|
|
+import org.spongepowered.configurate.NodePath;
|
|
+import org.spongepowered.configurate.transformation.ConfigurationTransformation;
|
|
+import org.spongepowered.configurate.transformation.TransformAction;
|
|
+
|
|
+public final class V2_ConvertIconToMaterial implements TransformAction {
|
|
+ private static final int VERSION = 3; // targeted version is always ahead by one
|
|
+ private static final NodePath PATH = NodePath.path("fps", "material");
|
|
+ private static final V2_ConvertIconToMaterial INSTANCE = new V2_ConvertIconToMaterial();
|
|
+
|
|
+ private V2_ConvertIconToMaterial() {}
|
|
+
|
|
+ public static void apply(ConfigurationTransformation.VersionedBuilder builder) {
|
|
+ builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(PATH, INSTANCE).build());
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Object @Nullable [] visitPath(NodePath path, ConfigurationNode value) throws ConfigurateException {
|
|
+ if (value.raw() instanceof String stringValue) {
|
|
+ value.raw(stringValue.toUpperCase());
|
|
+ }
|
|
+ return null;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/me/samsuik/sakura/configuration/transformation/world/V2_VerticalKnockbackUseDefault.java b/src/main/java/me/samsuik/sakura/configuration/transformation/world/V2_VerticalKnockbackUseDefault.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..97d5224ef110cb2fa4f44a90a54a1611dc0182d9
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/configuration/transformation/world/V2_VerticalKnockbackUseDefault.java
|
|
@@ -0,0 +1,31 @@
|
|
+package me.samsuik.sakura.configuration.transformation.world;
|
|
+
|
|
+import io.papermc.paper.configuration.type.number.DoubleOr;
|
|
+import org.checkerframework.checker.nullness.qual.Nullable;
|
|
+import org.spongepowered.configurate.ConfigurateException;
|
|
+import org.spongepowered.configurate.ConfigurationNode;
|
|
+import org.spongepowered.configurate.NodePath;
|
|
+import org.spongepowered.configurate.transformation.ConfigurationTransformation;
|
|
+import org.spongepowered.configurate.transformation.TransformAction;
|
|
+
|
|
+import static org.spongepowered.configurate.NodePath.path;
|
|
+
|
|
+public final class V2_VerticalKnockbackUseDefault implements TransformAction {
|
|
+ private static final int VERSION = 2;
|
|
+ private static final NodePath PATH = path("players", "knockback", "knockback-vertical");
|
|
+ private static final V2_VerticalKnockbackUseDefault INSTANCE = new V2_VerticalKnockbackUseDefault();
|
|
+
|
|
+ private V2_VerticalKnockbackUseDefault() {}
|
|
+
|
|
+ public static void apply(ConfigurationTransformation.VersionedBuilder builder) {
|
|
+ builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(PATH, INSTANCE).build());
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Object @Nullable [] visitPath(NodePath path, ConfigurationNode value) throws ConfigurateException {
|
|
+ if (value.getDouble() == 0.4) {
|
|
+ value.set(DoubleOr.Default.USE_DEFAULT);
|
|
+ }
|
|
+ return null;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/me/samsuik/sakura/configuration/transformation/world/V3_RenameKnockback.java b/src/main/java/me/samsuik/sakura/configuration/transformation/world/V3_RenameKnockback.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..efba1f83cb079d0e75904adc439b715d17793979
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/configuration/transformation/world/V3_RenameKnockback.java
|
|
@@ -0,0 +1,27 @@
|
|
+package me.samsuik.sakura.configuration.transformation.world;
|
|
+
|
|
+import org.spongepowered.configurate.NodePath;
|
|
+import org.spongepowered.configurate.transformation.ConfigurationTransformation;
|
|
+
|
|
+import java.util.Map;
|
|
+
|
|
+import static org.spongepowered.configurate.NodePath.path;
|
|
+import static org.spongepowered.configurate.transformation.TransformAction.*;
|
|
+
|
|
+public final class V3_RenameKnockback {
|
|
+ private static final int VERSION = 3;
|
|
+ private static final Map<NodePath, String> RENAME = Map.of(
|
|
+ path("players", "knockback", "vertical-limit-require-ground"), "vertical-knockback-require-ground",
|
|
+ path("players", "knockback", "knockback-horizontal"), "base-knockback"
|
|
+ );
|
|
+
|
|
+ private V3_RenameKnockback() {}
|
|
+
|
|
+ public static void apply(ConfigurationTransformation.VersionedBuilder builder) {
|
|
+ ConfigurationTransformation.Builder transformationBuilder = ConfigurationTransformation.builder();
|
|
+ for (Map.Entry<NodePath, String> entry : RENAME.entrySet()) {
|
|
+ transformationBuilder.addAction(entry.getKey(), rename(entry.getValue()));
|
|
+ }
|
|
+ builder.addVersion(VERSION, transformationBuilder.build());
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/me/samsuik/sakura/configuration/transformation/world/V4_RenameNonStrictMergeLevel.java b/src/main/java/me/samsuik/sakura/configuration/transformation/world/V4_RenameNonStrictMergeLevel.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..198eb5f030ec5def4d93dec51dde352261654bb5
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/configuration/transformation/world/V4_RenameNonStrictMergeLevel.java
|
|
@@ -0,0 +1,35 @@
|
|
+package me.samsuik.sakura.configuration.transformation.world;
|
|
+
|
|
+import org.checkerframework.checker.nullness.qual.Nullable;
|
|
+import org.spongepowered.configurate.ConfigurateException;
|
|
+import org.spongepowered.configurate.ConfigurationNode;
|
|
+import org.spongepowered.configurate.NodePath;
|
|
+import org.spongepowered.configurate.transformation.ConfigurationTransformation;
|
|
+import org.spongepowered.configurate.transformation.TransformAction;
|
|
+
|
|
+import java.util.Locale;
|
|
+
|
|
+import static org.spongepowered.configurate.NodePath.path;
|
|
+
|
|
+public final class V4_RenameNonStrictMergeLevel implements TransformAction {
|
|
+ private static final int VERSION = 4;
|
|
+ private static final String OLD_LEVEL_NAME = "NON_STRICT";
|
|
+ private static final String NEW_LEVEL_NAME = "LENIENT";
|
|
+ private static final NodePath PATH = path("cannons", "merge-level");
|
|
+ private static final V4_RenameNonStrictMergeLevel INSTANCE = new V4_RenameNonStrictMergeLevel();
|
|
+
|
|
+ private V4_RenameNonStrictMergeLevel() {}
|
|
+
|
|
+ public static void apply(ConfigurationTransformation.VersionedBuilder builder) {
|
|
+ builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(PATH, INSTANCE).build());
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Object @Nullable [] visitPath(NodePath path, ConfigurationNode value) throws ConfigurateException {
|
|
+ String level = value.getString();
|
|
+ if (level != null && OLD_LEVEL_NAME.equals(level.toUpperCase(Locale.ENGLISH))) {
|
|
+ value.set(NEW_LEVEL_NAME);
|
|
+ }
|
|
+ return null;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/me/samsuik/sakura/configuration/transformation/world/V5_CombineLoadChunksOptions.java b/src/main/java/me/samsuik/sakura/configuration/transformation/world/V5_CombineLoadChunksOptions.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..3d647a3db0862232f158d823da9a797d4e0d5608
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/configuration/transformation/world/V5_CombineLoadChunksOptions.java
|
|
@@ -0,0 +1,44 @@
|
|
+package me.samsuik.sakura.configuration.transformation.world;
|
|
+
|
|
+import org.checkerframework.checker.nullness.qual.Nullable;
|
|
+import org.spongepowered.configurate.ConfigurateException;
|
|
+import org.spongepowered.configurate.ConfigurationNode;
|
|
+import org.spongepowered.configurate.NodePath;
|
|
+import org.spongepowered.configurate.transformation.ConfigurationTransformation;
|
|
+import org.spongepowered.configurate.transformation.TransformAction;
|
|
+
|
|
+import java.util.List;
|
|
+
|
|
+import static org.spongepowered.configurate.NodePath.path;
|
|
+
|
|
+public final class V5_CombineLoadChunksOptions implements TransformAction {
|
|
+ private static final int VERSION = 5;
|
|
+ private static final List<String> ENTITY_PATHS = List.of("tnt", "sand");
|
|
+ private static final String OLD_NAME = "loads-chunks";
|
|
+ private static final String NAME = "load-chunks";
|
|
+ private static final NodePath PATH = path("cannons");
|
|
+ private static final V5_CombineLoadChunksOptions INSTANCE = new V5_CombineLoadChunksOptions();
|
|
+
|
|
+ private V5_CombineLoadChunksOptions() {}
|
|
+
|
|
+ public static void apply(ConfigurationTransformation.VersionedBuilder builder) {
|
|
+ builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(PATH, INSTANCE).build());
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Object @Nullable [] visitPath(NodePath path, ConfigurationNode value) throws ConfigurateException {
|
|
+ boolean shouldLoadChunks = false;
|
|
+
|
|
+ for (String entity : ENTITY_PATHS) {
|
|
+ NodePath entityPath = NodePath.path(entity, OLD_NAME);
|
|
+ if (value.hasChild(entityPath)) {
|
|
+ ConfigurationNode node = value.node(entityPath);
|
|
+ shouldLoadChunks |= node.getBoolean();
|
|
+ node.raw(null);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ value.node(NAME).set(shouldLoadChunks);
|
|
+ return null;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/me/samsuik/sakura/configuration/transformation/world/V6_FixIncorrectExtraKnockback.java b/src/main/java/me/samsuik/sakura/configuration/transformation/world/V6_FixIncorrectExtraKnockback.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..f9fdf1a87420c78136deccf8822f5cf177b41aed
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/configuration/transformation/world/V6_FixIncorrectExtraKnockback.java
|
|
@@ -0,0 +1,30 @@
|
|
+package me.samsuik.sakura.configuration.transformation.world;
|
|
+
|
|
+import org.checkerframework.checker.nullness.qual.Nullable;
|
|
+import org.spongepowered.configurate.ConfigurateException;
|
|
+import org.spongepowered.configurate.ConfigurationNode;
|
|
+import org.spongepowered.configurate.NodePath;
|
|
+import org.spongepowered.configurate.transformation.ConfigurationTransformation;
|
|
+import org.spongepowered.configurate.transformation.TransformAction;
|
|
+
|
|
+import static org.spongepowered.configurate.NodePath.path;
|
|
+
|
|
+public final class V6_FixIncorrectExtraKnockback implements TransformAction {
|
|
+ private static final int VERSION = 6;
|
|
+ private static final NodePath PATH = path("players", "knockback", "sprinting", "extra-knockback");
|
|
+ private static final V6_FixIncorrectExtraKnockback INSTANCE = new V6_FixIncorrectExtraKnockback();
|
|
+
|
|
+ private V6_FixIncorrectExtraKnockback() {}
|
|
+
|
|
+ public static void apply(ConfigurationTransformation.VersionedBuilder builder) {
|
|
+ builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(PATH, INSTANCE).build());
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Object @Nullable [] visitPath(NodePath path, ConfigurationNode value) throws ConfigurateException {
|
|
+ if (value.getDouble() == 1.0) {
|
|
+ value.set(0.5);
|
|
+ }
|
|
+ return null;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/me/samsuik/sakura/explosion/durable/DurableMaterial.java b/src/main/java/me/samsuik/sakura/explosion/durable/DurableMaterial.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..4024f9738e039ffffd560a07a2210f758879d3c0
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/explosion/durable/DurableMaterial.java
|
|
@@ -0,0 +1,7 @@
|
|
+package me.samsuik.sakura.explosion.durable;
|
|
+
|
|
+import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
|
+
|
|
+@ConfigSerializable
|
|
+public record DurableMaterial(int durability, float resistance) {
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index 7933d6900dac67a24fb5f9378097dbde34be30b1..3a47504876cf718935786d7b858cb6d53bd61ddb 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -327,6 +327,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
public final double[] recentTps = new double[ 3 ];
|
|
// Spigot end
|
|
public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations; // Paper - add paper configuration files
|
|
+ public final me.samsuik.sakura.configuration.SakuraConfigurations sakuraConfigurations; // Sakura
|
|
public boolean isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
|
|
|
|
public volatile Thread shutdownThread; // Paper
|
|
@@ -511,6 +512,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this));
|
|
// CraftBukkit end
|
|
this.paperConfigurations = services.paperConfigurations(); // Paper - add paper configuration files
|
|
+ // Sakura start
|
|
+ final var sakuraConfigDirPath = ((File) options.valueOf("sakura-settings-directory")).toPath();
|
|
+ this.sakuraConfigurations = me.samsuik.sakura.configuration.SakuraConfigurations.setup(sakuraConfigDirPath);
|
|
+ // Sakura end
|
|
}
|
|
|
|
private void readScoreboard(DimensionDataStorage persistentStateManager) {
|
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
index 17a158ff6ce6520b69a5a0032ba4c05449dd0cf8..282a0f91e41a0dcdeb48111a64a83b480efb2acd 100644
|
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
@@ -236,6 +236,11 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
|
this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark
|
|
com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics
|
|
com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now
|
|
+ // Sakura start - sakura configuration files
|
|
+ sakuraConfigurations.initializeGlobalConfiguration(this.registryAccess());
|
|
+ sakuraConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess());
|
|
+ me.samsuik.sakura.command.SakuraCommands.registerCommands(this);
|
|
+ // Sakura end - sakura configuration files
|
|
|
|
this.setPvpAllowed(dedicatedserverproperties.pvp);
|
|
this.setFlightAllowed(dedicatedserverproperties.allowFlight);
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
index 5964d601c05176f48167cc92057a59e52a4da92b..32742470eea2ec86c0fff02aa157bfcc89530ad3 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -590,7 +590,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
|
|
// Add env and gen to constructor, IWorldDataServer -> WorldDataServer
|
|
public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
|
|
- super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess(), iworlddataserver.getGameRules())), executor); // Paper - create paper world configs; Async-Anti-Xray: Pass executor
|
|
+ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess(), iworlddataserver.getGameRules())), () -> minecraftserver.sakuraConfigurations.createWorldConfig(me.samsuik.sakura.configuration.SakuraConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), minecraftserver.registryAccess())), executor); // Sakura - sakura configuration files // Paper - create paper world configs; Async-Anti-Xray: Pass executor
|
|
this.pvpMode = minecraftserver.isPvpAllowed();
|
|
this.convertable = convertable_conversionsession;
|
|
this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile());
|
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
|
index 022de445bbbb869c38be4972c98dcf1c665539ec..d95292d388efa4c504440347f1e5dfc2b87b8afe 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -172,6 +172,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
|
return this.paperConfig;
|
|
}
|
|
// Paper end - add paper world config
|
|
+ // Sakura start - sakura configuration files
|
|
+ private final me.samsuik.sakura.configuration.WorldConfiguration sakuraConfig;
|
|
+ public final me.samsuik.sakura.configuration.WorldConfiguration sakuraConfig() {
|
|
+ return this.sakuraConfig;
|
|
+ }
|
|
+ // Sakura end - sakura configuration files
|
|
|
|
public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray
|
|
public static BlockPos lastPhysicsProblem; // Spigot
|
|
@@ -830,7 +836,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
|
}
|
|
// Paper end - optimise random ticking
|
|
|
|
- protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config & Anti-Xray
|
|
+ protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, java.util.function.Supplier<me.samsuik.sakura.configuration.WorldConfiguration> sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura - sakura configuration files // Paper - create paper world config & Anti-Xray
|
|
// Paper start - getblock optimisations - cache world height/sections
|
|
final DimensionType dimType = holder.value();
|
|
this.minY = dimType.minY();
|
|
@@ -842,6 +848,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
|
// Paper end - getblock optimisations - cache world height/sections
|
|
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
|
|
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config
|
|
+ this.sakuraConfig = sakuraWorldConfigCreator.get(); // Sakura - sakura configuration files
|
|
this.generator = gen;
|
|
this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env);
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index 9f9eefc7346838a9effcda861cecd098092efb0f..2205444180ae615b50a3cbae6bf5fa31504aeff0 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -1074,6 +1074,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.sakuraConfigurations.reloadConfigs(this.console); // Sakura - sakura configuration files; missing comment above :<
|
|
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))
|
|
@@ -1105,6 +1106,7 @@ public final class CraftServer implements Server {
|
|
this.reloadData();
|
|
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
|
|
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
|
|
+ me.samsuik.sakura.command.SakuraCommands.registerCommands(this.console); // Sakura - sakura configuration files
|
|
this.spark.registerCommandBeforePlugins(this); // Paper - spark
|
|
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
|
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
index a7524d3853d5b67b6385d2b74832b9267503dfe6..cab99463b969b6414d506c73c71e7e81f39c5541 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
@@ -176,6 +176,14 @@ public class Main {
|
|
.describedAs("Jar file");
|
|
// Paper end
|
|
|
|
+ // Sakura start - sakura configuration files
|
|
+ acceptsAll(asList("sakura-dir", "sakura-settings-directory"), "Directory for Sakura settings")
|
|
+ .withRequiredArg()
|
|
+ .ofType(File.class)
|
|
+ .defaultsTo(new File(me.samsuik.sakura.configuration.SakuraConfigurations.CONFIG_DIR))
|
|
+ .describedAs("Config directory");
|
|
+ // Sakura end - sakura configuration files
|
|
+
|
|
// Paper start
|
|
acceptsAll(asList("server-name"), "Name of the server")
|
|
.withRequiredArg()
|