MineDown-adventure

repository·main·Indexed 43 days ago

https://github.com/phoenix616/minedown

A library for Minecraft developers that enables Markdown-style markup for creating complex chat components using the Kyori Adventure API (version 4.25 or newer). It supports inline formatting, RGB hex colors, gradients, click and hover events, and the rendering of player heads and item sprites.

Tokens
2.2K
Snippets
8
Records
10
Agent score
6%

What's inside MineDown

  1. Overview of MineDown-adventure

    main
    MineDown-adventure is a library that allows you to use Markdown-inspired markup to create Minecraft chat components. It provides a custom syntax that offers the power of modern component messages with the simplicity of legacy formatting codes. Additionally, it supports replacing placeholders in both string-based and component-based messages.
  2. Relocate MineDown using Maven Shade Plugin

    main

    To prevent classpath conflicts with other plugins, relocate the de.themoep.minedown package to a unique path within your plugin's package using the maven-shade-plugin.

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <relocations>
                        <relocation>
                            <pattern>de.themoep.minedown</pattern>
                            <shadedPattern>your.package.path.libraries.minedown</shadedPattern>
                        </relocation>
                    </relocations>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
  3. Requirements for MineDown-adventure

    main

    To use MineDown-adventure, you must have the kyori-adventure chat API installed.

    Version Requirement:

    • kyori-adventure 4.25 or newer

    Platform Setup: If you are not running on a platform that supports Adventure natively (such as Paper or Velocity), you must provide one of the adventure-platform libraries in your project to handle the messages.

  4. Include MineDown-adventure via Maven

    main

    To use the Adventure implementation of MineDown, add the Minebench repository and the minedown-adventure dependency to your pom.xml.

    Note: It is highly recommended to relocate the library into your plugin's package using the maven-shade-plugin to avoid dependency conflicts.

    <repositories>
        <repository>
            <id>minebench-repo</id>
            <url>https://repo.minebench.de/</url>
        </repository>
    </repositories>
    
    <dependencies>
        <dependency>
            <groupId>de.themoep</groupId>
            <artifactId>minedown-adventure</artifactId>
            <version>1.7.6-SNAPSHOT</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
  5. Use MineDown in your plugin

    main

    The primary way to interact with MineDown is through the MineDown class. You can either instantiate a new MineDown object to allow for manual replacements or use the static parse method for a more direct approach. Both methods allow you to convert MineDown-formatted strings into Adventure Component objects suitable for Paper or Velocity plugins.

    // Using an instance with replacements
    player.sendMessage(new MineDown(minedownString).replace(replacements).toComponent());
    
    // Using the static parse method
    player.sendMessage(MineDown.parse(minedownString, replacements));
  6. Use advanced event syntax for complex interactions

    main

    For more granular control, use the [Text](action=value) syntax. This allows you to specify specific ClickEvent.Action and HoverEvent.Action behaviors.

    Note: You can chain multiple advanced settings within a single event definition, but you cannot add multiple different colors or multiple click/hover actions to the same component.

    # Link & Color
    [Text](open_url=https://example.com)
    [Text](color=red)
    [Text](color=#ff00ff)
    [Text](color=#fff-#000) # Gradient
    
    # Formatting & Style
    [Text](format=underline,bold)
    [Text](format=!underline) # Disable specific formatting
    [Text](shadow=#ff00ff)
    [Text](font=custom_font)
    
    # Commands & Clipboard
    [Text](run_command=/command string)
    [Text](suggest_command=/command)
    [Text](copy_to_clipboard=Text to be copied)
    
    # Special Components
    [](player_head=name) # Player head
    [](sprite=item/diamond) # Item/Block sprite
    [Text](translate=translation.key with={value1})
    
    # Hover Events
    [Text](hover=Hover Text)
    [Text](show_text=Hover Text)
    [Text](show_entity=uuid:pig Name)
    [Text](show_item=stone*2 nbt...)
  7. Include legacy BungeeCord-chat library

    main

    If you specifically require the legacy BungeeCord-chat version (available on the legacy branch) instead of the Adventure implementation, use the following dependency configuration:

    <dependency>
        <groupId>de.themoep</groupId>
        <artifactId>minedown</artifactId>
        <version>1.7.1-SNAPSHOT</version>
        <scope>compile</scope>
    </dependency>
  8. Use inline formatting syntax

    main

    MineDown-adventure supports several inline formatting styles for Minecraft text, including legacy color codes, RGB hex colors, gradients, and standard Markdown-like styling for bold, italic, underline, strikethrough, and obfuscation.

    Color legacy: ` &6Text `
    Color: ` &gold&Text `
    RGB Hex Color: ` &#ff00ff&Text `
    RGB Hex Color (Short): ` &#f0f&Text `
    Gradient: ` &#f0f-#fff&Text `
    Rainbow: ` &rainbow&Text `
    Rainbow Phase: ` &rainbow:20&Text `
    Bold: ` **Text** `
    Italic: ` ##Text## `
    Underlined: ` __Text__ `
    Strikethrough: ` ~~Text~~ `
    Obfuscated: ` ??Text?? `
  9. Display player heads and item sprites

    main

    You can render visual components like player heads or item/block sprites using an empty text bracket [] followed by the specific action in the parentheses.

    Player Heads:

    • By name: [](player_head=name)
    • By UUID: [](player_head=83688181-ce68-4136-918b-15e88ec2c705)
    • Without hat layer: [](player_head=name hat=false)
    • Custom texture: [](player_head=name texture=minecraft:entity/player/wide/alex)
    • Base64 profile: [](player_head=name profile={textures=base64encodedstring})

    Sprites:

    • Item/Block: [](sprite=item/diamond)
    • Specific Atlas: [](sprite=item/diamond atlas=blocks)
    [](player_head=name)
    [](sprite=item/diamond)
  10. Use simple event syntax for links and hover text

    main

    You can define click and hover events using a simplified Markdown link syntax: [Text](content). The content part can include colors, formatting, links, or hover text.

    Common patterns:

    • Simple Link: [Text](https://example.com)
    • Simple Command: [Text](/command to run)
    • Link + Hover: [Text](https://example.com Hover Text)
    • Text formatting: [Text](blue underline !bold)
    • Gradient: [Text](#fff-#000)
    • Rainbow: [Text](rainbow)
    • Phased Rainbow: [Text](rainbow:20)
    • Combined: [Text](#0000ff underline https://example.com Hover Text)
    [Text](blue underline !bold)
    [Text](#0000ff underline https://example.com Hover Text)