Search in sources :

Example 1 with Action

use of net.glowstone.net.message.play.game.TitleMessage.Action in project Glowstone by GlowstoneMC.

the class TitleCodec method decode.

@Override
public TitleMessage decode(ByteBuf buffer) throws IOException {
    int actionId = ByteBufUtils.readVarInt(buffer);
    Action action = Action.getAction(actionId);
    switch(action) {
        case TITLE:
        case SUBTITLE:
        case ACTION:
            String text = ByteBufUtils.readUTF8(buffer);
            return new TitleMessage(action, TextMessage.decode(text));
        case TIMES:
            int fadeIn = buffer.readInt();
            int stay = buffer.readInt();
            int fadeOut = buffer.readInt();
            return new TitleMessage(action, fadeIn, stay, fadeOut);
        default:
            return new TitleMessage(action);
    }
}
Also used : Action(net.glowstone.net.message.play.game.TitleMessage.Action) TitleMessage(net.glowstone.net.message.play.game.TitleMessage)

Aggregations

TitleMessage (net.glowstone.net.message.play.game.TitleMessage)1 Action (net.glowstone.net.message.play.game.TitleMessage.Action)1