Search in sources :

Example 1 with PrivateChatMessage

use of org.apollo.game.message.impl.PrivateChatMessage in project apollo by apollo-rsps.

the class PrivateChatMessageDecoder method decode.

@Override
public PrivateChatMessage decode(GamePacket packet) {
    GamePacketReader reader = new GamePacketReader(packet);
    String username = NameUtil.decodeBase37(reader.getSigned(DataType.LONG));
    int length = packet.getLength() - Long.BYTES;
    byte[] originalCompressed = new byte[length];
    reader.getBytes(originalCompressed);
    String decompressed = TextUtil.decompress(originalCompressed, length);
    decompressed = TextUtil.filterInvalidCharacters(decompressed);
    decompressed = TextUtil.capitalize(decompressed);
    byte[] recompressed = new byte[length];
    TextUtil.compress(decompressed, recompressed);
    return new PrivateChatMessage(decompressed, recompressed, username);
}
Also used : GamePacketReader(org.apollo.net.codec.game.GamePacketReader) PrivateChatMessage(org.apollo.game.message.impl.PrivateChatMessage)

Example 2 with PrivateChatMessage

use of org.apollo.game.message.impl.PrivateChatMessage in project apollo by apollo-rsps.

the class PrivateChatMessageDecoder method decode.

@Override
public PrivateChatMessage decode(GamePacket packet) {
    GamePacketReader reader = new GamePacketReader(packet);
    String username = NameUtil.decodeBase37(reader.getSigned(DataType.LONG));
    int length = packet.getLength() - Long.BYTES;
    byte[] originalCompressed = new byte[length];
    reader.getBytes(originalCompressed);
    String decompressed = TextUtil.decompress(originalCompressed, length);
    decompressed = TextUtil.filterInvalidCharacters(decompressed);
    decompressed = TextUtil.capitalize(decompressed);
    byte[] recompressed = new byte[length];
    TextUtil.compress(decompressed, recompressed);
    return new PrivateChatMessage(new String(decompressed), recompressed, username);
}
Also used : GamePacketReader(org.apollo.net.codec.game.GamePacketReader) PrivateChatMessage(org.apollo.game.message.impl.PrivateChatMessage)

Aggregations

PrivateChatMessage (org.apollo.game.message.impl.PrivateChatMessage)2 GamePacketReader (org.apollo.net.codec.game.GamePacketReader)2