9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-21 07:49:35 +00:00
Files
LeavesMC/patches/server/0114-Leaves-Reload-Command.patch
2024-01-10 13:32:42 +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 9fc807312bd61158f996abb8424ec0c0005d2d42..3d7b012d51fc2774cde688fcde01800a511c6bf2 100644
--- a/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java
+++ b/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java
@@ -15,6 +15,7 @@ import org.jetbrains.annotations.NotNull;
import top.leavesmc.leaves.command.subcommands.ConfigCommand;
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;
@@ -39,6 +40,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;
+ }
+}