mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-20 15:29:35 +00:00
55 lines
2.7 KiB
Diff
55 lines
2.7 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 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;
|
|
+ }
|
|
+}
|