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()) };
}
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));
}
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);
}
}
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);
}
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));
}
Aggregations