#component #adventure #minecraft #chat #color #click #mini-message

lobsterchat

Minecraft Chat Components and Adventure MiniMessage in Rust

3 releases

0.4.2 Oct 9, 2022
0.4.1 Oct 8, 2022
0.4.0 Oct 8, 2022

#369 in Games

MIT license

35KB
708 lines

LobsterChat

A Minecraft Chat Component and Adventure MiniMessage implementation in Rust.

Examples

Without minimessage

use lobsterchat::component::*;

let text_component: Component = Component::text("Hello, World! ")
                    .color(0xFFAAFF)
                    .click_event(ClickEvent::open_url("https://github.com/Maxuss/lobster"))
                    .append(
                        Component::translatable("my.translation.key")
                        .color(NamedColor::Gold)
                        .hover_event(HoverEvent::ShowText(Component::text("Click for surprise!")))
                        .insert_text("I love lobsterchat!")
                    )
                    .append(
                        Component::keybind("key.sprint")
                        .bold(true)
                        .italic(false)
                    );

println!("{}", text_component.to_string());

With minimessage

use lobsterchat::message::*;
use lobsterchat::component::{Component, Colored, NamedColor};

let component: Component = lobster("<gold><bold>This is some message!</bold> <blue>Some blue text <#AAFFAA>Some hex text!");
let placeholdered: Component = placeholder_lobster(
    "Some normal text. <first> And then <gold><second>.",
    [
        (
            "first",
            Component::text("Some replacement.").color(NamedColor::Gold)
        ),
        (
            "second",
            Component::translatable("translated.text.key")
        )
    ])

Enable minimessage with the minimessage crate feature

Speed:

running 1 test
test tests::benchmark_lobster ... bench:       6,335 ns/iter (+/- 147)

So around 6mcs to convert message into a component.

Features

  • Components:

  • Component types (literal, translatable, etc.)

  • Formatting and colors

  • Click / Hover events in components

  • MiniMessage

  • Named color tags (e.g. <red>, <blue>)

  • Hex color tags (e.g. <#AAFFAA>)

  • Formatting tags (e.g. <bold>, <reset>)

  • Placeholder tags

  • Hover / Click Events

  • Advanced formatting tags (e.g. <rainbow>, <gradient>)

Dependencies

~4MB
~53K SLoC