From 2b87538d9b8031b59f395335158b04ed2d5f4b6c Mon Sep 17 00:00:00 2001 From: violetc <58360096+s-yh-china@users.noreply.github.com> Date: Tue, 5 Sep 2023 00:07:35 +0800 Subject: [PATCH] Leaves Reload Command --- .../server/0124-Leaves-Reload-Command.patch | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 patches/server/0124-Leaves-Reload-Command.patch diff --git a/patches/server/0124-Leaves-Reload-Command.patch b/patches/server/0124-Leaves-Reload-Command.patch new file mode 100644 index 00000000..79861257 --- /dev/null +++ b/patches/server/0124-Leaves-Reload-Command.patch @@ -0,0 +1,54 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: violetc <58360096+s-yh-china@users.noreply.github.com> +Date: Tue, 5 Sep 2023 00:07:10 +0800 +Subject: [PATCH] Leaves Reload Command + + +diff --git a/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java b/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java +index 258c6c97eb8cc86ee53569377c3c472f87293334..aa69854adfea877d4d8fdc741d6c9f3ca83a12c0 100644 +--- a/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java ++++ b/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java +@@ -14,6 +14,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; + import org.jetbrains.annotations.NotNull; + import top.leavesmc.leaves.command.subcommands.CounterCommand; + import top.leavesmc.leaves.command.subcommands.PeacefulModeSwitchCommand; ++import top.leavesmc.leaves.command.subcommands.ReloadCommand; + import top.leavesmc.leaves.command.subcommands.TickCommand; + import top.leavesmc.leaves.command.subcommands.UpdateCommand; + +@@ -39,6 +40,7 @@ public final class LeavesCommand extends Command { + commands.put(Set.of("peaceful"), new PeacefulModeSwitchCommand()); + commands.put(Set.of("tick"), new TickCommand()); + commands.put(Set.of("counter"), new CounterCommand()); ++ commands.put(Set.of("reload"), new ReloadCommand()); + + return commands.entrySet().stream() + .flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue()))) +diff --git a/src/main/java/top/leavesmc/leaves/command/subcommands/ReloadCommand.java b/src/main/java/top/leavesmc/leaves/command/subcommands/ReloadCommand.java +new file mode 100644 +index 0000000000000000000000000000000000000000..ecf0b1a6d59e662a02458bbc50c7a3f5388cce5f +--- /dev/null ++++ b/src/main/java/top/leavesmc/leaves/command/subcommands/ReloadCommand.java +@@ -0,0 +1,22 @@ ++package top.leavesmc.leaves.command.subcommands; ++ ++import net.minecraft.server.MinecraftServer; ++import org.bukkit.command.Command; ++import org.bukkit.command.CommandSender; ++import top.leavesmc.leaves.LeavesConfig; ++import top.leavesmc.leaves.command.LeavesSubcommand; ++ ++import java.io.File; ++ ++import static net.kyori.adventure.text.Component.text; ++import static net.kyori.adventure.text.format.NamedTextColor.GREEN; ++ ++public class ReloadCommand implements LeavesSubcommand { ++ @Override ++ public boolean execute(CommandSender sender, String subCommand, String[] args) { ++ MinecraftServer server = MinecraftServer.getServer(); ++ LeavesConfig.init((File) server.options.valueOf("leaves-settings")); ++ Command.broadcastCommandMessage(sender, text("Leaves config reload complete.", GREEN)); ++ return false; ++ } ++}