Search in sources :

Example 1 with GamePacketReader

use of org.apollo.net.codec.game.GamePacketReader in project apollo by apollo-rsps.

the class PrivacyOptionMessageDecoder method decode.

@Override
public PrivacyOptionMessage decode(GamePacket packet) {
    GamePacketReader reader = new GamePacketReader(packet);
    int publicChatState = (int) reader.getUnsigned(DataType.BYTE);
    int privateChatState = (int) reader.getUnsigned(DataType.BYTE);
    int tradeChatState = (int) reader.getUnsigned(DataType.BYTE);
    return new PrivacyOptionMessage(publicChatState, privateChatState, tradeChatState);
}
Also used : GamePacketReader(org.apollo.net.codec.game.GamePacketReader) PrivacyOptionMessage(org.apollo.game.message.impl.PrivacyOptionMessage)

Example 2 with GamePacketReader

use of org.apollo.net.codec.game.GamePacketReader in project apollo by apollo-rsps.

the class ItemOnObjectMessageDecoder method decode.

@Override
public ItemOnObjectMessage decode(GamePacket packet) {
    GamePacketReader reader = new GamePacketReader(packet);
    int interfaceId = (int) reader.getUnsigned(DataType.SHORT);
    int objectId = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
    int y = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
    int slot = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
    int x = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
    int itemId = (int) reader.getUnsigned(DataType.SHORT);
    return new ItemOnObjectMessage(interfaceId, itemId, slot, objectId, x, y);
}
Also used : GamePacketReader(org.apollo.net.codec.game.GamePacketReader) ItemOnObjectMessage(org.apollo.game.message.impl.ItemOnObjectMessage)

Example 3 with GamePacketReader

use of org.apollo.net.codec.game.GamePacketReader in project apollo by apollo-rsps.

the class PlayerDesignMessageDecoder method decode.

@Override
public PlayerDesignMessage decode(GamePacket packet) {
    GamePacketReader reader = new GamePacketReader(packet);
    int genderIntValue = (int) reader.getUnsigned(DataType.BYTE);
    int[] style = new int[7];
    for (int i = 0; i < style.length; i++) {
        style[i] = (int) reader.getUnsigned(DataType.BYTE);
    }
    int[] color = new int[5];
    for (int i = 0; i < color.length; i++) {
        color[i] = (int) reader.getUnsigned(DataType.BYTE);
    }
    Gender gender = genderIntValue == Gender.MALE.toInteger() ? Gender.MALE : Gender.FEMALE;
    return new PlayerDesignMessage(new Appearance(gender, style, color));
}
Also used : PlayerDesignMessage(org.apollo.game.message.impl.PlayerDesignMessage) GamePacketReader(org.apollo.net.codec.game.GamePacketReader) Gender(org.apollo.game.model.entity.setting.Gender) Appearance(org.apollo.game.model.Appearance)

Example 4 with GamePacketReader

use of org.apollo.net.codec.game.GamePacketReader in project apollo by apollo-rsps.

the class PublicChatMessageDecoder method decode.

@Override
public PublicChatMessage decode(GamePacket packet) {
    GamePacketReader reader = new GamePacketReader(packet);
    int effects = (int) reader.getUnsigned(DataType.BYTE, DataTransformation.SUBTRACT);
    int color = (int) reader.getUnsigned(DataType.BYTE, DataTransformation.SUBTRACT);
    int length = packet.getLength() - 2;
    byte[] originalCompressed = new byte[length];
    reader.getBytesReverse(DataTransformation.ADD, originalCompressed);
    String uncompressed = TextUtil.decompress(originalCompressed, length);
    uncompressed = TextUtil.filterInvalidCharacters(uncompressed);
    uncompressed = TextUtil.capitalize(uncompressed);
    byte[] recompressed = new byte[length];
    TextUtil.compress(uncompressed, recompressed);
    return new PublicChatMessage(uncompressed, recompressed, color, effects);
}
Also used : GamePacketReader(org.apollo.net.codec.game.GamePacketReader) PublicChatMessage(org.apollo.game.message.impl.PublicChatMessage)

Example 5 with GamePacketReader

use of org.apollo.net.codec.game.GamePacketReader in project apollo by apollo-rsps.

the class RemoveFriendMessageDecoder method decode.

@Override
public RemoveFriendMessage decode(GamePacket packet) {
    GamePacketReader reader = new GamePacketReader(packet);
    String username = NameUtil.decodeBase37(reader.getSigned(DataType.LONG));
    return new RemoveFriendMessage(username);
}
Also used : GamePacketReader(org.apollo.net.codec.game.GamePacketReader) RemoveFriendMessage(org.apollo.game.message.impl.RemoveFriendMessage)

Aggregations

GamePacketReader (org.apollo.net.codec.game.GamePacketReader)97 ItemActionMessage (org.apollo.game.message.impl.ItemActionMessage)10 ItemOptionMessage (org.apollo.game.message.impl.ItemOptionMessage)10 NpcActionMessage (org.apollo.game.message.impl.NpcActionMessage)10 PlayerActionMessage (org.apollo.game.message.impl.PlayerActionMessage)10 Position (org.apollo.game.model.Position)10 ObjectActionMessage (org.apollo.game.message.impl.ObjectActionMessage)6 AddFriendMessage (org.apollo.game.message.impl.AddFriendMessage)2 AddIgnoreMessage (org.apollo.game.message.impl.AddIgnoreMessage)2 ArrowKeyMessage (org.apollo.game.message.impl.ArrowKeyMessage)2 ButtonMessage (org.apollo.game.message.impl.ButtonMessage)2 DialogueContinueMessage (org.apollo.game.message.impl.DialogueContinueMessage)2 EnteredAmountMessage (org.apollo.game.message.impl.EnteredAmountMessage)2 FlaggedMouseEventMessage (org.apollo.game.message.impl.FlaggedMouseEventMessage)2 FlashingTabClickedMessage (org.apollo.game.message.impl.FlashingTabClickedMessage)2 ItemOnItemMessage (org.apollo.game.message.impl.ItemOnItemMessage)2 ItemOnNpcMessage (org.apollo.game.message.impl.ItemOnNpcMessage)2 ItemOnObjectMessage (org.apollo.game.message.impl.ItemOnObjectMessage)2 MagicOnItemMessage (org.apollo.game.message.impl.MagicOnItemMessage)2 MagicOnNpcMessage (org.apollo.game.message.impl.MagicOnNpcMessage)2