A Minecraft Component library made for the DockyardMC project
<yellow>A Minecraft <rainbow><u>Component Library<yellow> for the <#3d91ff><bold>DockyardMC<yellow> project!
repositories {
maven {
name = "devOS"
url = uri("https://mvn.devos.one/releases")
}
}
dependencies {
implementation("io.github.dockyardmc:scroll:1.9")
}
repositories {
maven {
name "devOS"
url "https://mvn.devos.one/releases"
}
}
dependencies {
implementation 'io.github.dockyardmc:scroll:1.9'
}
You can create a different type of components using the following syntax
Normal Text Component
val textComponent = TextComponent(
text = "woah red bold text",
color = TextColor.RED,
bold = true
// ..other styling
)
Keybind Component (Reads the current keybinds from client)
val keybindComponent = KeybindComponent(
keybind = "key.jump"
// ..other styling
)
Translatable Component (Reads the language file from client)
val translatableComponent = TranslatableComponent(
translate = "advancements.husbandry.safely_harvest_honey.description"
// ..other styling
)
You can also create component that contains other components
val bigBoiComponent = Components.new(mutableListOf(
TextComponent(text = "Im looking to "),
TextComponent(text = "buy ", color = TextColor.YELLOW, bold = true),
TextComponent(text = "your "),
TextComponent(text = "finest potions ", color = "#9436ff", italics = true)
TextComponent(text = "so I can jump high when I press "),
KeybindComponent(keybind = "key.jump", color = TextColor.YELLOW, underlined = true)
))
You can also write your components using string format
val component = "<yellow>HE'S <red><bold>ALLERGIC<yellow> TO BEANS!".toComponent()
The following tags are valid:
- Colors:
<color>
for predefined color (ex. red, orange, lime, aqua)<#hex>
for custom hex color (must include the # at the start)
- Format
<bold>
<italic>
<obfuscated>
<underline>
<strikethrough>
- Events
<hover|'text''>
for hover-able text. Formatting applies to inner text as well<click|action|'text'>
for clickable text. Actions are followingopen_url
- following text needs to start with "https://"run_command
- following text needs to start with "/"suggest_command
- following text needs to start with "/"copy_to_clipboard
- Other
<font|'file_name'>
to change font<rainbow>
to make the text after rainbow. (Resets when another color is applied or when is reached)<transition|#hex1|#hex2|step>
- Color Interpolation, step is float between 0 and 1<reset>
to reset formatting
In some cases (format and reset) you can use shortened versions
<b>
is short of<bold>
<i>
is short of<italic>
<o>
is short of<obfuscated>
<u>
is short of<underline>
<s>
is short of<strikethrough>
<r>
is short of<reset>
You also end tags by prefixing the tag with /
<bold>this is bold :D</bold> this is not :(
You can escape tag by putting \\
at the begging of it
<lime>Please login using /login \\<password>
will result to "Please login using /login <password>"
You can sanitize string using String.scrollSanitized()
This is recommended for any player input
"Player123: omg <red>red color and <bold>bold woah".scrollSanitized()
would result to "Player123: omg \\<red>red color and \\<bold>bold woah"
You can convert string to Component using "string".toComponent()
method or using StringToComponentSerializer().serialize("string")
You can convert component to NBT using Component.toNbt()
or using ComponentToNbtSerializer.serialize(component)
. This will give you instance of Hephaistos NBT Compound
You can convert component to Json using Component.toJson()
or using ComponentToJsonSerializer.serialize(component)
You can convert Json to component using JsonToComponentSerializer.serialize(json)