Skip to content

Minecraft component library built for DockyardMC

Notifications You must be signed in to change notification settings

DockyardMC/Scroll

Repository files navigation

wakatime

Scroll 📜

A Minecraft Component library made for the DockyardMC project

<yellow>A Minecraft <rainbow><u>Component Library<yellow> for the <#3d91ff><bold>DockyardMC<yellow> project!

obrazek


Installation

Kotlin DSL

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

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

Gradle Groovy

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

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

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)
  • 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 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
  • 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 :(

⚠️ 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