Search in sources :

Example 1 with TextMessage

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

the class TitleMessage method fromTitle.

public static TitleMessage[] fromTitle(Title title) {
    TextMessage titleMessage = asTextMessage(BaseComponent.toLegacyText(title.getTitle()));
    TextMessage subTitleMessage = title.getSubtitle() != null ? asTextMessage(BaseComponent.toLegacyText(title.getSubtitle())) : asTextMessage(null);
    return new TitleMessage[] { new TitleMessage(Action.TITLE, titleMessage), new TitleMessage(Action.SUBTITLE, subTitleMessage), new TitleMessage(Action.TIMES, title.getFadeIn(), title.getStay(), title.getFadeOut()) };
}
Also used : TextMessage(net.glowstone.util.TextMessage)

Example 2 with TextMessage

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

the class GlowPlayer method setPlayerListHeaderFooter.

@Override
public void setPlayerListHeaderFooter(BaseComponent[] header, BaseComponent[] footer) {
    TextMessage h = TextMessage.decode(ComponentSerializer.toString(header)), f = TextMessage.decode(ComponentSerializer.toString(footer));
    session.send(new UserListHeaderFooterMessage(h, f));
}
Also used : TextMessage(net.glowstone.util.TextMessage)

Example 3 with TextMessage

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

the class CombatEventCodec method decode.

@Override
public CombatEventMessage decode(ByteBuf buffer) throws IOException {
    int eventId = ByteBufUtils.readVarInt(buffer);
    Event event = Event.getAction(eventId);
    switch(event) {
        case END_COMBAT:
            {
                int duration = ByteBufUtils.readVarInt(buffer);
                int entityID = buffer.readInt();
                return new CombatEventMessage(event, duration, entityID);
            }
        case ENTITY_DEAD:
            int playerID = ByteBufUtils.readVarInt(buffer);
            int entityID = buffer.readInt();
            TextMessage message = GlowBufUtils.readChat(buffer);
            return new CombatEventMessage(event, playerID, entityID, message);
        default:
            return new CombatEventMessage(event);
    }
}
Also used : CombatEventMessage(net.glowstone.net.message.play.player.CombatEventMessage) Event(net.glowstone.net.message.play.player.CombatEventMessage.Event) TextMessage(net.glowstone.util.TextMessage)

Example 4 with TextMessage

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

the class ChatCodec method decode.

@Override
public ChatMessage decode(ByteBuf buf) throws IOException {
    TextMessage message = GlowBufUtils.readChat(buf);
    int mode = buf.readByte();
    return new ChatMessage(message, mode);
}
Also used : ChatMessage(net.glowstone.net.message.play.game.ChatMessage) TextMessage(net.glowstone.util.TextMessage)

Example 5 with TextMessage

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

the class GlowPlayer method sendActionBar.

@Override
public void sendActionBar(String message) {
    // "old" formatting workaround because apparently "new" styling doesn't work as of 01/18/2015
    JSONObject json = new JSONObject();
    json.put("text", message);
    session.send(new ChatMessage(new TextMessage(json), 2));
}
Also used : JSONObject(org.json.simple.JSONObject) 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