Skip to content

Commit

Permalink
+ MiniMessage support in Text (#57)
Browse files Browse the repository at this point in the history
* + MiniMessage support in Text

* * Changes to MiniMessage method

* * MiniMessage static method
  • Loading branch information
pjesek authored May 29, 2024
1 parent b96c4e0 commit feb0292
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/com/marcusslover/plus/lib/text/Text.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.TextDecoration;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
Expand Down Expand Up @@ -47,6 +48,15 @@ private Text(@NotNull Component component) {
return new Text(component);
}

/**
* Deserializes text using MiniMessage formatting.
* @return MiniMessage formatted text.
*/
public static @NotNull Text mini(String text) {
MiniMessage mm = MiniMessage.miniMessage();
return new Text(mm.deserialize(text));
}

@Deprecated
public static @NotNull List<@NotNull Text> list(@NotNull List<@NotNull Component> lore) {
return lore.stream().map(Text::new).collect(Collectors.toList());
Expand Down

0 comments on commit feb0292

Please sign in to comment.