Java Code Examples for com.nukkitx.protocol.bedrock.packet.TextPacket#Type

The following examples show how to use com.nukkitx.protocol.bedrock.packet.TextPacket#Type . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextSerializer_v354.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, TextPacket packet) {
    TextPacket.Type type = TextPacket.Type.values()[buffer.readUnsignedByte()];
    packet.setType(type);
    packet.setNeedsTranslation(buffer.readBoolean());
    switch (type) {
        case CHAT:
        case WHISPER:
        case ANNOUNCEMENT:
            packet.setSourceName(BedrockUtils.readString(buffer));
        case RAW:
        case TIP:
        case SYSTEM:
            packet.setMessage(BedrockUtils.readString(buffer));
            break;
        case TRANSLATION:
        case POPUP:
        case JUKEBOX_POPUP:
            packet.setMessage(BedrockUtils.readString(buffer));
            BedrockUtils.readArray(buffer, packet.getParameters(), BedrockUtils::readString);
            break;
    }
    packet.setXuid(BedrockUtils.readString(buffer));
    packet.setPlatformChatId(BedrockUtils.readString(buffer));
}
 
Example 2
Source File: TextSerializer_v388.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, TextPacket packet) {
    TextPacket.Type type = TextPacket.Type.values()[buffer.readUnsignedByte()];
    packet.setType(type);
    packet.setNeedsTranslation(buffer.readBoolean());
    switch (type) {
        case CHAT:
        case WHISPER:
        case ANNOUNCEMENT:
            packet.setSourceName(BedrockUtils.readString(buffer));
        case RAW:
        case TIP:
        case SYSTEM:
            packet.setMessage(BedrockUtils.readString(buffer));
            break;
        case TRANSLATION:
        case POPUP:
        case JUKEBOX_POPUP:
            packet.setMessage(BedrockUtils.readString(buffer));
            BedrockUtils.readArray(buffer, packet.getParameters(), BedrockUtils::readString);
            break;
    }
    packet.setXuid(BedrockUtils.readString(buffer));
    packet.setPlatformChatId(BedrockUtils.readString(buffer));
}
 
Example 3
Source File: TextSerializer_v340.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, TextPacket packet) {
    TextPacket.Type type = TextPacket.Type.values()[buffer.readUnsignedByte()];
    packet.setType(type);
    packet.setNeedsTranslation(buffer.readBoolean());
    switch (type) {
        case CHAT:
        case WHISPER:
        case ANNOUNCEMENT:
            packet.setSourceName(BedrockUtils.readString(buffer));
        case RAW:
        case TIP:
        case SYSTEM:
            packet.setMessage(BedrockUtils.readString(buffer));
            break;
        case TRANSLATION:
        case POPUP:
        case JUKEBOX_POPUP:
            packet.setMessage(BedrockUtils.readString(buffer));
            BedrockUtils.readArray(buffer, packet.getParameters(), BedrockUtils::readString);
            break;
    }
    packet.setXuid(BedrockUtils.readString(buffer));
    packet.setPlatformChatId(BedrockUtils.readString(buffer));
}
 
Example 4
Source File: TextSerializer_v313.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, TextPacket packet) {
    TextPacket.Type type = TextPacket.Type.values()[buffer.readUnsignedByte()];
    packet.setType(type);
    packet.setNeedsTranslation(buffer.readBoolean());
    switch (type) {
        case CHAT:
        case WHISPER:
        case ANNOUNCEMENT:
            packet.setSourceName(BedrockUtils.readString(buffer));
        case RAW:
        case TIP:
        case SYSTEM:
            packet.setMessage(BedrockUtils.readString(buffer));
            break;
        case TRANSLATION:
        case POPUP:
        case JUKEBOX_POPUP:
            packet.setMessage(BedrockUtils.readString(buffer));
            BedrockUtils.readArray(buffer, packet.getParameters(), BedrockUtils::readString);
            break;
    }
    packet.setXuid(BedrockUtils.readString(buffer));
    packet.setPlatformChatId(BedrockUtils.readString(buffer));
}
 
Example 5
Source File: TextSerializer_v361.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, TextPacket packet) {
    TextPacket.Type type = TextPacket.Type.values()[buffer.readUnsignedByte()];
    packet.setType(type);
    packet.setNeedsTranslation(buffer.readBoolean());
    switch (type) {
        case CHAT:
        case WHISPER:
        case ANNOUNCEMENT:
            packet.setSourceName(BedrockUtils.readString(buffer));
        case RAW:
        case TIP:
        case SYSTEM:
            packet.setMessage(BedrockUtils.readString(buffer));
            break;
        case TRANSLATION:
        case POPUP:
        case JUKEBOX_POPUP:
            packet.setMessage(BedrockUtils.readString(buffer));
            BedrockUtils.readArray(buffer, packet.getParameters(), BedrockUtils::readString);
            break;
    }
    packet.setXuid(BedrockUtils.readString(buffer));
    packet.setPlatformChatId(BedrockUtils.readString(buffer));
}
 
Example 6
Source File: TextSerializer_v332.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, TextPacket packet) {
    TextPacket.Type type = TextPacket.Type.values()[buffer.readUnsignedByte()];
    packet.setType(type);
    packet.setNeedsTranslation(buffer.readBoolean());
    switch (type) {
        case CHAT:
        case WHISPER:
        case ANNOUNCEMENT:
            packet.setSourceName(BedrockUtils.readString(buffer));
        case RAW:
        case TIP:
        case SYSTEM:
            packet.setMessage(BedrockUtils.readString(buffer));
            break;
        case TRANSLATION:
        case POPUP:
        case JUKEBOX_POPUP:
            packet.setMessage(BedrockUtils.readString(buffer));
            BedrockUtils.readArray(buffer, packet.getParameters(), BedrockUtils::readString);
            break;
    }
    packet.setXuid(BedrockUtils.readString(buffer));
    packet.setPlatformChatId(BedrockUtils.readString(buffer));
}
 
Example 7
Source File: TextSerializer_v291.java    From Protocol with Apache License 2.0 6 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, TextPacket packet) {
    TextPacket.Type type = TextPacket.Type.values()[buffer.readUnsignedByte()];
    packet.setType(type);
    packet.setNeedsTranslation(buffer.readBoolean());
    switch (type) {
        case CHAT:
        case WHISPER:
        case ANNOUNCEMENT:
            packet.setSourceName(BedrockUtils.readString(buffer));
        case RAW:
        case TIP:
        case SYSTEM:
            packet.setMessage(BedrockUtils.readString(buffer));
            break;
        case TRANSLATION:
        case POPUP:
        case JUKEBOX_POPUP:
            packet.setMessage(BedrockUtils.readString(buffer));
            BedrockUtils.readArray(buffer, packet.getParameters(), BedrockUtils::readString);
            break;
    }
    packet.setXuid(BedrockUtils.readString(buffer));
    packet.setPlatformChatId(BedrockUtils.readString(buffer));
}
 
Example 8
Source File: TextSerializer_v354.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, TextPacket packet) {
    TextPacket.Type type = packet.getType();
    buffer.writeByte(type.ordinal());
    buffer.writeBoolean(packet.isNeedsTranslation());

    switch (type) {
        case CHAT:
        case WHISPER:
        case ANNOUNCEMENT:
            BedrockUtils.writeString(buffer, packet.getSourceName());
        case RAW:
        case TIP:
        case SYSTEM:
            BedrockUtils.writeString(buffer, packet.getMessage());
            break;
        case TRANSLATION:
        case POPUP:
        case JUKEBOX_POPUP:
            BedrockUtils.writeString(buffer, packet.getMessage());
            BedrockUtils.writeArray(buffer, packet.getParameters(), BedrockUtils::writeString);
            break;
    }

    BedrockUtils.writeString(buffer, packet.getXuid());
    BedrockUtils.writeString(buffer, packet.getPlatformChatId());
}
 
Example 9
Source File: TextSerializer_v388.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, TextPacket packet) {
    TextPacket.Type type = packet.getType();
    buffer.writeByte(type.ordinal());
    buffer.writeBoolean(packet.isNeedsTranslation());

    switch (type) {
        case CHAT:
        case WHISPER:
        case ANNOUNCEMENT:
            BedrockUtils.writeString(buffer, packet.getSourceName());
        case RAW:
        case TIP:
        case SYSTEM:
            BedrockUtils.writeString(buffer, packet.getMessage());
            break;
        case TRANSLATION:
        case POPUP:
        case JUKEBOX_POPUP:
            BedrockUtils.writeString(buffer, packet.getMessage());
            BedrockUtils.writeArray(buffer, packet.getParameters(), BedrockUtils::writeString);
            break;
    }

    BedrockUtils.writeString(buffer, packet.getXuid());
    BedrockUtils.writeString(buffer, packet.getPlatformChatId());
}
 
Example 10
Source File: TextSerializer_v340.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, TextPacket packet) {
    TextPacket.Type type = packet.getType();
    buffer.writeByte(type.ordinal());
    buffer.writeBoolean(packet.isNeedsTranslation());

    switch (type) {
        case CHAT:
        case WHISPER:
        case ANNOUNCEMENT:
            BedrockUtils.writeString(buffer, packet.getSourceName());
        case RAW:
        case TIP:
        case SYSTEM:
            BedrockUtils.writeString(buffer, packet.getMessage());
            break;
        case TRANSLATION:
        case POPUP:
        case JUKEBOX_POPUP:
            BedrockUtils.writeString(buffer, packet.getMessage());
            BedrockUtils.writeArray(buffer, packet.getParameters(), BedrockUtils::writeString);
            break;
    }

    BedrockUtils.writeString(buffer, packet.getXuid());
    BedrockUtils.writeString(buffer, packet.getPlatformChatId());
}
 
Example 11
Source File: TextSerializer_v313.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, TextPacket packet) {
    TextPacket.Type type = packet.getType();
    buffer.writeByte(type.ordinal());
    buffer.writeBoolean(packet.isNeedsTranslation());

    switch (type) {
        case CHAT:
        case WHISPER:
        case ANNOUNCEMENT:
            BedrockUtils.writeString(buffer, packet.getSourceName());
        case RAW:
        case TIP:
        case SYSTEM:
            BedrockUtils.writeString(buffer, packet.getMessage());
            break;
        case TRANSLATION:
        case POPUP:
        case JUKEBOX_POPUP:
            BedrockUtils.writeString(buffer, packet.getMessage());
            BedrockUtils.writeArray(buffer, packet.getParameters(), BedrockUtils::writeString);
            break;
    }

    BedrockUtils.writeString(buffer, packet.getXuid());
    BedrockUtils.writeString(buffer, packet.getPlatformChatId());
}
 
Example 12
Source File: TextSerializer_v361.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, TextPacket packet) {
    TextPacket.Type type = packet.getType();
    buffer.writeByte(type.ordinal());
    buffer.writeBoolean(packet.isNeedsTranslation());

    switch (type) {
        case CHAT:
        case WHISPER:
        case ANNOUNCEMENT:
            BedrockUtils.writeString(buffer, packet.getSourceName());
        case RAW:
        case TIP:
        case SYSTEM:
            BedrockUtils.writeString(buffer, packet.getMessage());
            break;
        case TRANSLATION:
        case POPUP:
        case JUKEBOX_POPUP:
            BedrockUtils.writeString(buffer, packet.getMessage());
            BedrockUtils.writeArray(buffer, packet.getParameters(), BedrockUtils::writeString);
            break;
    }

    BedrockUtils.writeString(buffer, packet.getXuid());
    BedrockUtils.writeString(buffer, packet.getPlatformChatId());
}
 
Example 13
Source File: TextSerializer_v332.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, TextPacket packet) {
    TextPacket.Type type = packet.getType();
    buffer.writeByte(type.ordinal());
    buffer.writeBoolean(packet.isNeedsTranslation());

    switch (type) {
        case CHAT:
        case WHISPER:
        case ANNOUNCEMENT:
            BedrockUtils.writeString(buffer, packet.getSourceName());
        case RAW:
        case TIP:
        case SYSTEM:
            BedrockUtils.writeString(buffer, packet.getMessage());
            break;
        case TRANSLATION:
        case POPUP:
        case JUKEBOX_POPUP:
            BedrockUtils.writeString(buffer, packet.getMessage());
            BedrockUtils.writeArray(buffer, packet.getParameters(), BedrockUtils::writeString);
            break;
    }

    BedrockUtils.writeString(buffer, packet.getXuid());
    BedrockUtils.writeString(buffer, packet.getPlatformChatId());
}
 
Example 14
Source File: TextSerializer_v291.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(ByteBuf buffer, TextPacket packet) {
    TextPacket.Type type = packet.getType();
    buffer.writeByte(type.ordinal());
    buffer.writeBoolean(packet.isNeedsTranslation());

    switch (type) {
        case CHAT:
        case WHISPER:
        case ANNOUNCEMENT:
            BedrockUtils.writeString(buffer, packet.getSourceName());
        case RAW:
        case TIP:
        case SYSTEM:
            BedrockUtils.writeString(buffer, packet.getMessage());
            break;
        case TRANSLATION:
        case POPUP:
        case JUKEBOX_POPUP:
            BedrockUtils.writeString(buffer, packet.getMessage());
            BedrockUtils.writeArray(buffer, packet.getParameters(), BedrockUtils::writeString);
            break;
    }

    BedrockUtils.writeString(buffer, packet.getXuid());
    BedrockUtils.writeString(buffer, packet.getPlatformChatId());
}