9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-20 07:19:35 +00:00
Files
LeavesMC/patches/server/0111-Leaves-Reload-Command.patch
violetc f40d340092 1.20.6 (#216)
---------

Co-authored-by: MC_XiaoHei <xiaohei.xor7studio@foxmail.com>
Co-authored-by: Bluemangoo <chenfy2006@qq.com>
2024-05-20 23:03:56 +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/org/leavesmc/leaves/command/LeavesCommand.java b/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java
index 31473e5a257276d1feb37e98cf52477cd9523712..0f958ccafda1490f1acfc8089c47f6b7de7d4722 100644
--- a/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java
+++ b/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java
@@ -15,6 +15,7 @@ import org.jetbrains.annotations.NotNull;
import org.leavesmc.leaves.command.subcommands.ConfigCommand;
import org.leavesmc.leaves.command.subcommands.CounterCommand;
import org.leavesmc.leaves.command.subcommands.PeacefulModeSwitchCommand;
+import org.leavesmc.leaves.command.subcommands.ReloadCommand;
import org.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/org/leavesmc/leaves/command/subcommands/ReloadCommand.java b/src/main/java/org/leavesmc/leaves/command/subcommands/ReloadCommand.java
new file mode 100644
index 0000000000000000000000000000000000000000..749718287eb5364001176927248a4094afaf8750
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/command/subcommands/ReloadCommand.java
@@ -0,0 +1,22 @@
+package org.leavesmc.leaves.command.subcommands;
+
+import net.minecraft.server.MinecraftServer;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.leavesmc.leaves.LeavesConfig;
+import org.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;
+ }
+}