mirror of
https://github.com/System-End/Discord-MC-Chat.git
synced 2026-04-19 16:28:23 +00:00
Enhance console command response handling and add localized no-response messages
This commit is contained in:
parent
e3216e2bc8
commit
6ec2b17fea
4 changed files with 23 additions and 5 deletions
|
|
@ -241,11 +241,22 @@ public class ConsoleCommand implements Command {
|
|||
|
||||
try {
|
||||
ConsoleResponsePacket response = future.get(CONSOLE_TIMEOUT_SECONDS, TimeUnit.SECONDS);
|
||||
String output = response.response;
|
||||
|
||||
if (sender instanceof JdaCommandSender) {
|
||||
DiscordManager.sendExecuteResultViaWebhook(serverName, response.response);
|
||||
if (output.isBlank()) {
|
||||
String command = "/execute at: " + serverName + " command: log latest.log";
|
||||
output = I18nManager.getDmccTranslation("commands.console.no_response", command);
|
||||
}
|
||||
|
||||
DiscordManager.sendExecuteResultViaWebhook(serverName, output);
|
||||
} else {
|
||||
String[] lines = response.response.split("\n");
|
||||
if (output.isBlank()) {
|
||||
String command = "/execute " + serverName + " log latest.log";
|
||||
output = I18nManager.getDmccTranslation("commands.console.no_response", command);
|
||||
}
|
||||
|
||||
String[] lines = output.split("\n");
|
||||
for (String line : lines) {
|
||||
sender.reply(I18nManager.getDmccTranslation("commands.remote_result_prefix", serverName, line));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,11 @@ commands:
|
|||
no_online_clients: "No DMCC clients are online."
|
||||
dmcc_not_supported: "Executing DMCC commands through \"console\" command is not supported. Please use \"execute\" command."
|
||||
server_not_ready: "Minecraft Server is not ready yet."
|
||||
no_response: |
|
||||
No response received from DMCC Client.
|
||||
|
||||
This can be normal for certain Minecraft commands. If you expected a response, please check the Minecraft server log by executing "{}" command.
|
||||
|
||||
help:
|
||||
description: "Show a list of available commands"
|
||||
help: "Help"
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@ commands:
|
|||
no_online_clients: "没有在线的 DMCC 客户端。"
|
||||
dmcc_not_supported: "通过 \"console\" 命令执行 DMCC 命令不受支持。请使用 \"execute\" 命令。"
|
||||
server_not_ready: "Minecraft 服务器尚未准备就绪。"
|
||||
no_response: |
|
||||
DMCC 客户端没有返回任何响应。
|
||||
|
||||
这对部分 Minecraft 命令属正常现象。如预期应有响应,请执行 "{}" 命令检查 Minecraft 服务器日志。
|
||||
help:
|
||||
description: "显示可用命令列表"
|
||||
help: "帮助"
|
||||
|
|
|
|||
|
|
@ -272,9 +272,7 @@ public class MinecraftEventHandler {
|
|||
}
|
||||
|
||||
// Send any collected command output back to the sender
|
||||
if (!rconConsoleSource.getCommandResponse().isEmpty()) {
|
||||
event.sender().reply(rconConsoleSource.getCommandResponse());
|
||||
}
|
||||
event.sender().reply(rconConsoleSource.getCommandResponse());
|
||||
event.completionFuture().complete(null);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue