Search in sources :

Example 6 with TextMessage

use of net.glowstone.util.TextMessage in project Glowstone by GlowstoneMC.

the class GlowPlayer method setPlayerListName.

@Override
public void setPlayerListName(String name) {
    // update state
    playerListName = name;
    // send update message
    TextMessage displayName = null;
    if (playerListName != null && !playerListName.isEmpty()) {
        displayName = new TextMessage(playerListName);
    }
    updateUserListEntries(UserListItemMessage.displayNameOne(getUniqueId(), displayName));
}
Also used : TextMessage(net.glowstone.util.TextMessage)

Example 7 with TextMessage

use of net.glowstone.util.TextMessage in project Glowstone by GlowstoneMC.

the class BossBarCodec method decode.

@Override
public BossBarMessage decode(ByteBuf buffer) throws IOException {
    UUID uuid = GlowBufUtils.readUuid(buffer);
    Action action = Action.fromInt(ByteBufUtils.readVarInt(buffer));
    switch(action) {
        case ADD:
            TextMessage title = GlowBufUtils.readChat(buffer);
            float health = buffer.readFloat();
            Color color = Color.fromInt(ByteBufUtils.readVarInt(buffer));
            Division division = Division.fromInt(ByteBufUtils.readVarInt(buffer));
            byte flags = buffer.readByte();
            return new BossBarMessage(uuid, action, title, health, color, division, flags);
        case REMOVE:
            return new BossBarMessage(uuid, action);
        case UPDATE_HEALTH:
            health = buffer.readFloat();
            return new BossBarMessage(uuid, action, health);
        case UPDATE_TITLE:
            title = GlowBufUtils.readChat(buffer);
            return new BossBarMessage(uuid, action, title);
        case UPDATE_STYLE:
            color = Color.fromInt(ByteBufUtils.readVarInt(buffer));
            division = Division.fromInt(ByteBufUtils.readVarInt(buffer));
            return new BossBarMessage(uuid, action, color, division);
        case UPDATE_FLAGS:
            flags = buffer.readByte();
            return new BossBarMessage(uuid, action, flags);
    }
    //INFO: This return is dead code. We would NPE before on the action line.
    return null;
}
Also used : Action(net.glowstone.net.message.play.player.BossBarMessage.Action) Color(net.glowstone.net.message.play.player.BossBarMessage.Color) Division(net.glowstone.net.message.play.player.BossBarMessage.Division) UUID(java.util.UUID) TextMessage(net.glowstone.util.TextMessage) BossBarMessage(net.glowstone.net.message.play.player.BossBarMessage)

Example 8 with TextMessage

use of net.glowstone.util.TextMessage in project Glowstone by GlowstoneMC.

the class UpdateSignCodec method decode.

@Override
public UpdateSignMessage decode(ByteBuf buf) throws IOException {
    BlockVector pos = GlowBufUtils.readBlockPosition(buf);
    TextMessage[] message = new TextMessage[4];
    for (int i = 0; i < message.length; ++i) {
        message[i] = GlowBufUtils.readChat(buf);
    }
    return new UpdateSignMessage(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), message);
}
Also used : BlockVector(org.bukkit.util.BlockVector) TextMessage(net.glowstone.util.TextMessage) UpdateSignMessage(net.glowstone.net.message.play.game.UpdateSignMessage)

Example 9 with TextMessage

use of net.glowstone.util.TextMessage in project Glowstone by GlowstoneMC.

the class UserListHeaderFooterCodec method decode.

@Override
public UserListHeaderFooterMessage decode(ByteBuf buffer) throws IOException {
    TextMessage header = GlowBufUtils.readChat(buffer);
    TextMessage footer = GlowBufUtils.readChat(buffer);
    return new UserListHeaderFooterMessage(header, footer);
}
Also used : UserListHeaderFooterMessage(net.glowstone.net.message.play.game.UserListHeaderFooterMessage) TextMessage(net.glowstone.util.TextMessage)

Aggregations

TextMessage (net.glowstone.util.TextMessage)9 UUID (java.util.UUID)1 ChatMessage (net.glowstone.net.message.play.game.ChatMessage)1 UpdateSignMessage (net.glowstone.net.message.play.game.UpdateSignMessage)1 UserListHeaderFooterMessage (net.glowstone.net.message.play.game.UserListHeaderFooterMessage)1 BossBarMessage (net.glowstone.net.message.play.player.BossBarMessage)1 Action (net.glowstone.net.message.play.player.BossBarMessage.Action)1 Color (net.glowstone.net.message.play.player.BossBarMessage.Color)1 Division (net.glowstone.net.message.play.player.BossBarMessage.Division)1 CombatEventMessage (net.glowstone.net.message.play.player.CombatEventMessage)1 Event (net.glowstone.net.message.play.player.CombatEventMessage.Event)1 BlockVector (org.bukkit.util.BlockVector)1 JSONObject (org.json.simple.JSONObject)1