Skip to content

DockyardMC/Scroll

Repository files navigation

Scroll Banner


Maven metadata URL Static Badge

wakatime Discord Static Badge

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

Installation

Kotlin DSL

repositories {
    maven {
        name = "devOS"
        url = uri("https://mvn.devos.one/releases")
    }
}

dependencies {
    implementation("io.github.dockyardmc:scroll:2.9")
}

Gradle Groovy

repositories {
  maven {
    name "devOS"
    url "https://mvn.devos.one/releases"
  }
}

dependencies {
  implementation 'io.github.dockyardmc:scroll:2.9'
}

Usage

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
)

obrazek

Keybind Component (Reads the current keybinds from client)

val keybindComponent = KeybindComponent(
    keybind = "key.jump"
    // ..other styling
)

obrazek

Translatable Component (Reads the language file from client)

val translatableComponent = TranslatableComponent(
    translate = "advancements.husbandry.safely_harvest_honey.description"
    // ..other styling
)

obrazek


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)
))

obrazek


String to Components

You can also write your components using string format

val component = "<yellow>HE'S <red><bold>ALLERGIC<yellow> TO BEANS!".toComponent()

obrazek

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 start
      • alpha: 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 argument
      • show_item: item id and optional item count
      • show_entity: entity type id, entity uuid, and optional name (text component)
      • you can skip type, in this case show_text will be used as default. Like this: <hover:'text'>Hover!
    • <click:action:'text'> for clickable text. Actions are following
      • open_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
      • show_dialog
      • custom - send custom click action. two arguments: id and payload
  • 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 :(

⚠️ Currently, there is no support for custom tags


Sanitization & Escapes

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"


Serialization

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)


⚠️ There is currently no integration with either vanilla minecraft server components or adventure/minimessage

About

Minecraft component library built for DockyardMC

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages