9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-22 08:29:22 +00:00
Files
LeavesMC/patches/server/0117-Leaves-Reload-Command.patch
2023-12-10 21:15:29 +08:00

55 lines
2.6 KiB
Diff

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 5e413b0216289922a49a3de7ff5cd9aef4c3c16e..5109d08998707f7443880b2daff719483dff7a5e 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.UpdateCommand;
import java.util.ArrayList;
@@ -37,6 +38,7 @@ public final class LeavesCommand extends Command {
commands.put(Set.of("update"), new UpdateCommand());
commands.put(Set.of("peaceful"), new PeacefulModeSwitchCommand());
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;
+ }
+}