use of org.lanternpowered.server.text.chat.LanternChatType in project LanternServer by LanternPowered.
the class ChatTypeRegistryModule method registerDefaults.
@Override
public void registerDefaults() {
register(new LanternChatType("minecraft", "chat", (text, locale) -> new MessagePlayOutChatMessage(new LocalizedText(text, locale), MessagePlayOutChatMessage.Type.CHAT)));
register(new LanternChatType("minecraft", "action_bar", (text, locale) -> new MessagePlayOutTitle.SetActionbarTitle(new LocalizedText(text, locale))));
register(new LanternChatType("minecraft", "system", (text, locale) -> new MessagePlayOutChatMessage(new LocalizedText(text, locale), MessagePlayOutChatMessage.Type.SYSTEM)));
}
use of org.lanternpowered.server.text.chat.LanternChatType in project LanternServer by LanternPowered.
the class LanternWorld method sendMessage.
@Override
public void sendMessage(ChatType type, Text message) {
checkNotNull(type, "chatType");
checkNotNull(message, "message");
if (!this.players.isEmpty()) {
final Map<Locale, Message> networkMessages = new HashMap<>();
for (LanternPlayer player : this.players) {
player.getConnection().send(networkMessages.computeIfAbsent(player.getLocale(), locale -> ((LanternChatType) type).getMessageProvider().apply(message, locale)));
}
}
}
Aggregations