A Minecraft Component library made for the DockyardMC project. It includes easy to use and learn format to represent text components as strings, similiar to minimessage
repositories {
maven {
name = "devOS"
url = uri("https://mvn.devos.one/releases")
}
}
dependencies {
implementation("io.github.dockyardmc:scroll:2.9")
}repositories {
maven {
name "devOS"
url "https://mvn.devos.one/releases"
}
}
dependencies {
implementation 'io.github.dockyardmc:scroll:2.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)
- Shadow:
<shadow:#hex:alpha>:#hex: 6 digits hex number, must include # at the startalpha: integer from 0 to 255
- Example:
<blue><shadow:#FF0000>Woah red shadow
- Format
<bold><italic><obfuscated><underline><strikethrough>
- Events
<hover:action:'text'>for hover-able text. Formatting applies to inner text as well. Actions:show_text: 1 text argumentshow_item: item id and optional item countshow_entity: entity type id, entity uuid, and optional name (text component)- you can skip type, in this case
show_textwill be used as default. Like this:<hover:'text'>Hover!
<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_clipboardshow_dialogcustom- send custom click action. two arguments:idandpayload
- Other
<font:'file_name'>to change font<transition:#hex1:#hex2:step>- Color Interpolation, step is float between 0 and 1<reset>to reset formatting
Some tags (like <click:custom...>) have multiple arguments. Those are separated by :.
Like this:
<click:custom:'my_id':'my_payload'>Click for custom click!!!<hover:show_item:'minecraft:book':'1'>Hover to see a book (not really)
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)






