Skip to content

StartupBanner

Basti edited this page Sep 27, 2026 · 2 revisions

Print a MiniMessage-colored splash of ASCII art (or any text) each time your plugin boots. Keeping banners in src/main/resources/banner.txt ensures you can tweak them like any other resource.

Why Use It? 🎯

  • Give admins an immediate status message or gratitude note when the plugin loads.
  • Showcase branding without hand-rolling Adventure components.
  • Keep banner logic out of your onEnable() boilerplate.

Highlights ✨

  • Automatic escaping keeps ASCII art intact, backslashes and < included: every line is MiniMessage-escaped, so styling comes only from color(...).
  • Flexible input sources: resource files, inline strings, or generated lists all work together.
  • Forgiving failure modeβ€”a missing or unreadable resource logs a WARNING and the banner continues with any manual lines.

Limitations ⚠️

  • Console only: each line goes to the console as its own message, without the plugin's name or a log level. Players never see it, and lines logged by other threads can land in between.
  • One style for all lines: color(...) applies to every line, tags inside a line print literally, and a gradient starts over on every line.
  • color(...) takes tags only: anything but existing MiniMessage opening tags, such as an unknown tag (<glod>) or a bare word (gold), logs a WARNING and switches to the default <light_purple>, also after an earlier valid color. Tag arguments aren't checked, so <gradient:#zz> passes and then prints literally at the start of every line.
  • One resource: a second resource(...) replaces the first. It's read from your jar during build(), admins can't replace it from the data folder, and its lines always come first.
  • Encoding: the resource is read as UTF-8. A byte order mark isn't removed (the first line then starts with an invisible character), and invalid bytes become οΏ½.
  • No layout: no wrapping, width check or centering, and every line gets the console's time prefix. Whether colors and special characters show depends on the console and the host.
  • Silent cases: a blank resource path is ignored, and with no lines at all send() does nothing.

Quick Start πŸš€

  1. Drop ASCII art into src/main/resources/banner.txt (or plan inline lines).
  2. Build a banner during onEnable(), set a single color for crisp console output, and append optional lines.
  3. Call .build().send() to print to console before continuing startup logic.

References πŸ“š

Call Purpose
StartupBanner.builder(JavaPlugin) Starts a new builder.
resource(String) Loads text from a resource packaged inside your plugin JAR (UTF-8). Resource lines are printed first.
lines(List<String>) / addLine(String) Provide inline strings to print after the resource lines. lines(...) replaces earlier manual lines; addLine appends. null lines are skipped.
color(String) Applies a MiniMessage color/prefix tag to every line (default <light_purple>); anything that isn't a tag logs a warning and switches to the default, also after an earlier valid color.
build() Reads the resource and returns the StartupBanner.
send() (on StartupBanner) Writes the banner to console immediately; does nothing if there are no lines.

Banner Sources 🧩

  • TurtleLib ships no banner.txt; each plugin puts its own art into its src/main/resources/banner.txt (Timberella and UnderwaterTrees both do).
  • Here's a starter piece of "EXAMPLE" art (generated with the FIGlet small font) you can paste into your own plugin's src/main/resources/banner.txt and tweak:
  _____  __   _   __  __ ___ _    ___
 | __\ \/ /  /_\ |  \/  | _ \ |  | __|
 | _| >  <  / _ \| |\/| |  _/ |__| _|
 |___/_/\_\/_/ \_\_|  |_|_| |____|___|
  • Mix .resource(...) with .addLine(...)/.lines(...) to combine static art and runtime hints.

Examples πŸ§ͺ

import net.kroet.turtlelib.helper.StartupBanner;

public final class ExamplePlugin extends JavaPlugin {
    @Override
    public void onEnable() {
        StartupBanner.builder(this)
            .resource("banner.txt")
            .color("<aqua>")
            .addLine("Thanks for installing!")
            .build()
            .send();
    }
}
StartupBanner.builder(this)
    .color("<gold>")
    .lines(List.of(
        "Custom banner line 1",
        "Line 2 pulled from config or code"
    ))
    .build()
    .send();

Tips & Notes πŸ’‘

  • Keep multi-line art in resource files so version control captures changes cleanly.
  • Stick to single-color tags for console fidelity; gradients often render poorly.
  • Tags written inside banner lines are escaped and print literally; put emphasis tags into color(...) instead (e.g. color("<bold><aqua>")). Each line ends with <reset>.

Relationships to Other Helpers πŸ”—

  • Shares MiniMessage formatting approaches with MessageService, so colors/prefixes stay consistent.
  • Pair with UpdateChecker or ServerMatcher summaries by appending one-off lines that mention updates or compatibility.

Clone this wiki locally