Fix run command failed

This commit is contained in:
方块君 2022-07-22 23:44:28 +08:00
parent b51006edd0
commit bb3725046e

View File

@ -130,7 +130,7 @@ public class SocketClient {
var command = player.data; var command = player.data;
var playerData = ConsolePlus.getInstance().getServer().getPlayerByUid(player.uid); var playerData = ConsolePlus.getInstance().getServer().getPlayerByUid(player.uid);
if (playerData == null) { if (playerData == null) {
sendPacket(new HttpPacket(404, "Player not found."), packet.packetID); sendPacket(new HttpPacket(404, "[Mojo Console] Player not found."), packet.packetID);
return; return;
} }
// Player MessageHandler do not support concurrency // Player MessageHandler do not support concurrency
@ -140,9 +140,9 @@ public class SocketClient {
var resultCollector = new MessageHandler(); var resultCollector = new MessageHandler();
playerData.setMessageHandler(resultCollector); playerData.setMessageHandler(resultCollector);
CommandMap.getInstance().invoke(playerData, playerData, command); CommandMap.getInstance().invoke(playerData, playerData, command);
sendPacket(new HttpPacket(200, resultCollector.getMessage()), packet.packetID); sendPacket(new HttpPacket(200, "success", resultCollector.getMessage()), packet.packetID);
} catch (Exception e) { } catch (Exception e) {
mLogger.warn("Run command failed.", e); mLogger.warn("[Mojo Console] Run command failed.", e);
sendPacket(new HttpPacket(500, "error", e.getLocalizedMessage()), packet.packetID); sendPacket(new HttpPacket(500, "error", e.getLocalizedMessage()), packet.packetID);
} finally { } finally {
playerData.setMessageHandler(null); playerData.setMessageHandler(null);