Skip to content

A utility library for formatting and sending text using Adventure's MiniMessage format, as well as legacy formats. Provides support for both PlaceholderAPI and MiniPlaceholders integrations.

License

Notifications You must be signed in to change notification settings

SytexMC/Stylize

Repository files navigation

Stylize
Static Badge

A highly configurable & lightweight library for text formatting in Paper plugins,
with built-in support for MiniMessages, MiniPlaceholders & PlaceholderAPI.

Getting started

Stylize requires at least Java 17 and Paper 1.18.2 or later.
To add it to your project, include one of the following snippets in your build script.

Gradle (Kotlin DSL)
plugins {
  java
  id("com.gradleup.shadow") version "8.3.3"
}

repositories {
  maven("https://jitpack.io")
}

dependencies {
  implementation("com.github.SytexMC:Stylize:1.1.2")
}

shadowJar {
  // TODO: Change this to my own package name
  relocate("me.sytex.stylize", "my.custom.package.stylize")
}

Gradle (Groovy)
plugins {
  id 'java'
  id 'com.gradleup.shadow' version '8.3.3'
}

repositories {
  maven { url 'https://jitpack.io' }
}

dependencies {
  implementation 'com.github.SytexMC:Stylize:1.1.2'
}

shadowJar {
  // TODO: Change this to my own package name
  relocate("me.sytex.stylize", "my.custom.package.stylize")
}

Usage

Stylize offers two ways to get started, depending on your needs:

  • Easy Setup: If you want to get started quickly, use the stylize() method. This will set up Stylize with the most common options, including support for MiniPlaceholders and PlaceholderAPI.
Stylize stylize = Stylize.stylize();
  • Custom Setup: If you need more control, use the builder() method. This allows you to choose the specific features and options you want to use.
Stylize stylize = Stylize.builder()
.useMiniPlaceholders(true)
.usePlaceholderAPI(true)
.tagResolver(StandardTags.defaults())
.build();

Once you have a Stylize object, you can use it to translate strings into styled components.

  • Translating Strings: The translate() method takes a string and returns a styled component. You can also pass in additional arguments to customize the translation.
stylize.translate(string); // Basic use
stylize.translate(string, player); // For player-specific placeholders
stylize.translate(string, player1, player2); // For relational placeholders
stylize.translate(string, player, tagResolver); // For custom tag resolvers
  • Sending Messages: Stylize also provides methods for sending messages to players in different contexts.
stylize.sendMessage(player, "<green>Hello, world!"); // Send a chat message
stylize.sendActionBar(player, "<blue>Action bar message"); // Send an action bar message
stylize.sendTitle(player, "<red>Big Title", "<gray>Subtitle text"); // Send a title
stylize.sendTitlePart(player, TitlePart.SUBTITLE, "<gold>Some subtitle :)"); // Send a title part

License

Stylize is licensed under the MIT License.

About

A utility library for formatting and sending text using Adventure's MiniMessage format, as well as legacy formats. Provides support for both PlaceholderAPI and MiniPlaceholders integrations.

Topics

Resources

License

Stars

Watchers

Forks

Languages