Search in sources :

Example 1 with MessagePlayOutScoreboardScore

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

the class CodecPlayOutScoreboardScore method encode.

@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutScoreboardScore message) throws CodecException {
    ByteBuffer buf = context.byteBufAlloc().buffer();
    buf.writeString(message.getScoreName());
    int action = message instanceof MessagePlayOutScoreboardScore.Remove ? 1 : 0;
    buf.writeByte((byte) action);
    buf.writeString(message.getObjectiveName());
    if (action == 0) {
        buf.writeVarInt(((MessagePlayOutScoreboardScore.CreateOrUpdate) message).getValue());
    }
    return buf;
}
Also used : MessagePlayOutScoreboardScore(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutScoreboardScore) ByteBuffer(org.lanternpowered.server.network.buffer.ByteBuffer)

Aggregations

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