use of org.dragonet.protocol.packets.TextPacket 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 };
}
use of org.dragonet.protocol.packets.TextPacket in project DragonProxy by DragonetMC.
the class UpstreamSession method sendChat.
public void sendChat(String chat) {
if (chat.contains("\n")) {
String[] lines = chat.split("\n");
for (String line : lines) sendChat(line);
return;
}
// raw
TextPacket text = new TextPacket();
text.type = TextPacket.TYPE_RAW;
text.message = chat;
sendPacket(text, true);
}
Aggregations