Skip to content

Commit

Permalink
允许使用reload指令(不推荐)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luohuayu committed Apr 25, 2022
1 parent 0331c98 commit 4ec1a1b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/main/java/catserver/server/utils/LanguageUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class LanguageUtils {
CN.put("versioncheck.new_version", "检查到CatServer有新版本(%s), 请到官网(https://catmc.org)下载更新或在catserver.yml中关闭版本检查");
CN.put("versioncheck.failure", "CatServer更新检查失败, 请检查网络: %s");
CN.put("spark.recommend", "服务端已安装spark插件, 推荐使用spark更好的分析性能使用情况!");
CN.put("command.reload.warn", "在CatServer上使用/reload命令是非常危险的, 如果只需要重载配置文件请使用/catserver reloadall命令!");
CN.put("command.reload.warn.confirm", "如果依然要使用/reload命令, 请增加确认参数: /reload confirm");

EN.put("launch.java_wrong", "Current Java version (%s) is not supported, please replace to Java8");
EN.put("launch.java11_compatibility", "Trying to use Java11 compatibility mode to start (even if the server can start, some mods and plugins may not work, please use Java8 if an error occurs)");
Expand All @@ -31,6 +33,8 @@ public class LanguageUtils {
EN.put("versioncheck.new_version", "Check CatServer has a new version(%s), you can download the update from https://catmc.org or disable the version check in catserver.yml");
EN.put("versioncheck.failure", "CatServer version check failed, please check network: %s");
EN.put("spark.recommend", "Spark plugin has been installed on the server, recommended to use spark to better analyze performance usage!");
EN.put("command.reload.warn", "Using the /reload command on CatServer is very dangerous, if you only need to reload the configuration file please use the /catserver reloadall command!");
EN.put("command.reload.warn.confirm", "If you still want to use the /reload command, please add the confirmation parameter: /reload confirm");

current = ("zh".equals(Locale.getDefault().getLanguage()) ? CN : EN);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/bukkit/command/SimpleCommandMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public SimpleCommandMap(final Server server) {

private void setDefaultCommands() {
register("bukkit", new VersionCommand("version"));
// register("bukkit", new ReloadCommand("reload"));
register("bukkit", new ReloadCommand("reload"));
register("bukkit", new PluginsCommand("plugins"));
register("bukkit", new TimingsCommand("timings"));
register("catserver", new CommandPlugin("plugin"));
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/org/bukkit/command/defaults/ReloadCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
Expand All @@ -24,8 +25,16 @@ public boolean execute(CommandSender sender, String currentAlias, String[] args)

Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues when using some plugins.");
Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server.");
Bukkit.reload();
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Reload complete.");
// CatServer start+
if (args.length == 0) {
Command.broadcastCommandMessage(sender, ChatColor.RED + "------[WARN]------");
Command.broadcastCommandMessage(sender, ChatColor.RED + catserver.server.utils.LanguageUtils.I18nToString("command.reload.warn"));
Command.broadcastCommandMessage(sender, ChatColor.RED + catserver.server.utils.LanguageUtils.I18nToString("command.reload.warn.confirm"));
} else if (Objects.equals(args[0], "confirm")) {
((org.bukkit.craftbukkit.CraftServer) Bukkit.getServer()).reloadConfirm();
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Reload complete.");
}
// CatServer end

return true;
}
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/org/bukkit/craftbukkit/CraftServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,12 @@ public boolean dispatchVanillaCommand(CommandSender sender, String commandLine)

@Override
public void reload() {
if (true) return; // CatServer - disable reload
if (true) return; // CatServer - Disable reload
}

// CatServer - Move from reload method
@Deprecated
public void reloadConfirm() {
reloadCount++;
configuration = YamlConfiguration.loadConfiguration(getConfigFile());
commandsConfiguration = YamlConfiguration.loadConfiguration(getCommandsConfigFile());
Expand Down Expand Up @@ -823,6 +828,7 @@ public void reload() {
enablePlugins(PluginLoadOrder.POSTWORLD);
}

// CatServer start
public void reloadConfig() {
configuration = YamlConfiguration.loadConfiguration(getConfigFile());
commandsConfiguration = YamlConfiguration.loadConfiguration(getCommandsConfigFile());
Expand Down Expand Up @@ -881,6 +887,7 @@ public void reloadConfig() {

overrideAllCommandBlockCommands = commandsConfiguration.getStringList("command-block-overrides").contains("*");
}
// CatServer end

@Override
public void reloadData() {
Expand Down

0 comments on commit 4ec1a1b

Please sign in to comment.