Search in sources :

Example 1 with MessagePlayOutTitle

use of org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutTitle in project LanternServer by LanternPowered.

the class CodecPlayOutTitle method encode.

@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutTitle message) throws CodecException {
    final ByteBuffer buf = context.byteBufAlloc().buffer();
    if (message instanceof MessagePlayOutTitle.Clear) {
        buf.writeVarInt(CLEAR);
    } else if (message instanceof MessagePlayOutTitle.Reset) {
        buf.writeVarInt(RESET);
    } else if (message instanceof MessagePlayOutTitle.SetTitle) {
        buf.writeVarInt(SET_TITLE);
        buf.write(Types.LOCALIZED_TEXT, ((MessagePlayOutTitle.SetTitle) message).getTitle());
    } else if (message instanceof MessagePlayOutTitle.SetSubtitle) {
        buf.writeVarInt(SET_SUBTITLE);
        buf.write(Types.LOCALIZED_TEXT, ((MessagePlayOutTitle.SetSubtitle) message).getTitle());
    } else if (message instanceof MessagePlayOutTitle.SetActionbarTitle) {
        buf.writeVarInt(SET_ACTIONBAR_TITLE);
        buf.write(Types.LOCALIZED_TEXT, ((MessagePlayOutTitle.SetActionbarTitle) message).getTitle());
    } else {
        final MessagePlayOutTitle.SetTimes message0 = (MessagePlayOutTitle.SetTimes) message;
        buf.writeVarInt(SET_TIMES);
        buf.writeInteger(message0.getFadeIn());
        buf.writeInteger(message0.getStay());
        buf.writeInteger(message0.getFadeOut());
    }
    return buf;
}
Also used : ByteBuffer(org.lanternpowered.server.network.buffer.ByteBuffer) MessagePlayOutTitle(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutTitle)

Aggregations

ByteBuffer (org.lanternpowered.server.network.buffer.ByteBuffer)1 MessagePlayOutTitle (org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutTitle)1