Skip to main content

Developer API

TextEffect provides a public Maven Central API for other plugins.

Maven dependency

<dependency>
<groupId>dev.hxze</groupId>
<artifactId>texteffect-api</artifactId>
<version>{version}</version>
<scope>provided</scope>
</dependency>

Do not shade the API into your plugin. The TextEffect plugin provides the API classes at runtime.

plugin.yml

softdepend:
- TextEffect

Basic usage

import dev.hxze.texteffect.api.TextEffect;
import net.kyori.adventure.text.Component;

Component text = TextEffect.parse("<r>Event Started</r>");
Component golden = TextEffect.golden("Winner!");
Component nebula = TextEffect.apply("Deep Space", "nebula");

Item usage

The item methods are generic so the API does not depend on Bukkit snapshot artifacts.

ItemStack item = TextEffect.applyItemName(item, "<g>Event Trophy</g>");
item = TextEffect.applyItemLore(item, List.of("<r>Won during Blood Moon</r>"));
item = TextEffect.applyItemNameAndLore(item, "<g>Trophy</g>", lore);

Runtime checks

if (TextEffect.isAvailable() && TextEffect.isEnabled()) {
Component animated = TextEffect.parse("<neb>Server Event</neb>");
}

Safety

The public API is designed to fail safely. If TextEffect is not installed, disabled or unavailable, API methods return plain components or the original item instead of throwing errors.

Useful methods

TextEffect.isAvailable();
TextEffect.isEnabled();

TextEffect.parse("<r>Hello</r>");
TextEffect.parseOrPlain("<g>Hello</g>");
TextEffect.stripEffectTags("<neb>Hello</neb>");

TextEffect.apply("Hello", "rainbow");
TextEffect.golden("Winner!");
TextEffect.nebula("Deep Space");

TextEffect.applyItemName(item, "<g>Item Name</g>");
TextEffect.applyItemLore(item, List.of("<r>Lore line</r>"));
TextEffect.applyItemNameAndLore(item, "<g>Name</g>", lore);

Effect definitions

TextEffect.getEffect("rainbow").ifPresent(effect -> {
String name = effect.name();
int id = effect.id();
boolean enabled = effect.enabled();
});