Search in sources :

Example 1 with ServerChatPacket

use of com.github.steveice10.mc.protocol.packet.ingame.server.ServerChatPacket in project CyanBot by XjCyan1de.

the class ChatToGuiListener method onReceived.

@Override
public void onReceived(PacketReceivedEvent event) {
    final ServerChatPacket packet = event.getPacket();
    if (packet.getType() == MessageType.CHAT || packet.getType() == MessageType.SYSTEM) {
        final String message = packet.getMessage().getFullText();
        if (!chatMessageChache.contains(message)) {
            chatMessageChache.add(message);
            mainFrame.getChat().append(message + "\n");
            mainFrame.getChat().setCaretPosition(mainFrame.getChat().getDocument().getLength());
            Schedule.later(() -> chatMessageChache.remove(message), 3000);
        }
    }
}
Also used : ServerChatPacket(com.github.steveice10.mc.protocol.packet.ingame.server.ServerChatPacket)

Example 2 with ServerChatPacket

use of com.github.steveice10.mc.protocol.packet.ingame.server.ServerChatPacket in project DragonProxy by DragonetMC.

the class PCChatPacketTranslator method translate.

public PEPacket[] translate(UpstreamSession session, ServerChatPacket packet) {
    TextPacket pe = new TextPacket();
    switch(packet.getType()) {
        case NOTIFICATION:
            pe.message = pe.message = MessageTranslator.translate(packet.getMessage());
            pe.type = TYPE_POPUP;
            break;
        case CHAT:
            if (packet.getMessage() instanceof TranslationMessage) {
                pe.type = TYPE_TRANSLATION;
                pe.needsTranslation = true;
                pe.message = MessageTranslator.translationTranslateText((TranslationMessage) packet.getMessage());
                pe.params = MessageTranslator.translationTranslateParams(((TranslationMessage) packet.getMessage()).getTranslationParams());
            } else {
                pe.message = pe.message = MessageTranslator.translate(packet.getMessage());
                pe.type = TYPE_RAW;
            }
            break;
        case SYSTEM:
            if (packet.getMessage() instanceof TranslationMessage) {
                pe.type = TYPE_TRANSLATION;
                pe.needsTranslation = true;
                pe.message = MessageTranslator.translationTranslateText((TranslationMessage) packet.getMessage());
                pe.params = MessageTranslator.translationTranslateParams(((TranslationMessage) packet.getMessage()).getTranslationParams());
            } else {
                pe.message = pe.message = MessageTranslator.translate(packet.getMessage());
                pe.type = TYPE_RAW;
            }
            break;
    }
    return new PEPacket[] { pe };
}
Also used : TextPacket(org.dragonet.protocol.packets.TextPacket) PEPacket(org.dragonet.protocol.PEPacket) TranslationMessage(com.github.steveice10.mc.protocol.data.message.TranslationMessage)

Aggregations

TranslationMessage (com.github.steveice10.mc.protocol.data.message.TranslationMessage)1 ServerChatPacket (com.github.steveice10.mc.protocol.packet.ingame.server.ServerChatPacket)1 PEPacket (org.dragonet.protocol.PEPacket)1 TextPacket (org.dragonet.protocol.packets.TextPacket)1