Improve remote command execution response results

- Ensure that commands return specific messages instead of fixed strings after execution
This commit is contained in:
HongchengQ
2025-12-06 05:08:14 +08:00
committed by Melledy
parent 6974631601
commit b9c4a174f8

View File

@@ -40,11 +40,11 @@ public class RemoteHandler implements Handler {
// Check admin key
if (token.equals(adminKey)) {
Nebula.getCommandManager().invoke(null, command);
var commandResult = Nebula.getCommandManager().invoke(null, command);
Nebula.getLogger().warn("\u001B[38;2;252;186;3mRemote Server (Using Admin Key) sent command: /" + command + "\u001B[0m");
ctx.status(200);
ctx.contentType(ContentType.APPLICATION_JSON);
ctx.result("{\"Code\":200,\"Data\":{},\"Msg\":\"Command executed\"}");
ctx.result("{\"Code\":200,\"Data\":{},\"Msg\":\"" + commandResult.getMessage() + "\"}");
return;
}
@@ -78,11 +78,11 @@ public class RemoteHandler implements Handler {
Nebula.getLogger().info("Remote Player Request [" + player.getUid() + "]: " + finalCommand);
// Execute as console (null sender) but targeting the player
Nebula.getCommandManager().invoke(null, finalCommand);
var commandResult = Nebula.getCommandManager().invoke(null, finalCommand);
ctx.status(200);
ctx.contentType(ContentType.APPLICATION_JSON);
ctx.result("{\"Code\":200,\"Data\":{},\"Msg\":\"Command executed\"}");
ctx.result("{\"Code\":200,\"Data\":{},\"Msg\":\"" + commandResult.getMessage() + "\"}");
return;
}