How to intercept the response to a command?
svaningelgem opened this issue ยท 1 comments
Discussed in #3070
Originally posted by svaningelgem July 1, 2024
So I was trying to get the information for the "help" command:
I was able to intercept this command being sent to the server (I think) with:
protocolManager = ProtocolLibrary.getProtocolManager();
protocolManager.addPacketListener(new PacketAdapter(this, ListenerPriority.HIGHEST, Arrays.asList(
PacketType.Play.Server.COMMANDS,
PacketType.Play.Client.CHAT_COMMAND,
PacketType.Play.Client.CLIENT_COMMAND,
// PacketType.Play.Client.CHAT_COMMAND_SIGNED,
PacketType.Play.Server.COMMANDS,
PacketType.Play.Client.CHAT,
PacketType.Play.Server.CHAT
)) {
@Override
public void onPacketSending(PacketEvent event) {
System.out.println(">>> [onPacketSending] Packet event found: " + event.getPacketType());
}
@Override
public void onPacketReceiving(PacketEvent event) {
System.out.println(">>> [onPacketReceiving] Packet event found: " + event.getPacketType());
}
});
When I issue the "/help" command however, I do get:
[07:22:09 INFO]: [Plugin] [STDOUT] >>> [onPacketReceiving] Packet event found: CHAT_COMMAND[class=ServerboundChatCommandPacket, id=4]
[07:22:09 INFO]: Missue issued server command: /help
But I don't see anything else in the output.
The help command in spigot does this (in 1.20.4 at least):
[.. building the header & pages stringbuilder ..]
sender.sendMessage(header.toString());
sender.sendMessage(page.getLines());
So I was wondering what I need to intercept to be able to read the output...
Thanks!