Created
May 4, 2025 10:07
-
-
Save gepron1x/d999eab2c4f607c813a3adb862616ca0 to your computer and use it in GitHub Desktop.
Adventure MiniMessage Modifying tag example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import net.kyori.adventure.text.Component; | |
import net.kyori.adventure.text.TextComponent; | |
import net.kyori.adventure.text.minimessage.tag.Modifying; | |
import org.jetbrains.annotations.NotNull; | |
import java.util.List; | |
import java.util.Locale; | |
public class SmallCapsTag implements Modifying { | |
private static final char[] ALPHABET = "ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀsᴛᴜᴠᴡxʏᴢ".toCharArray(); | |
@Override | |
public Component apply(@NotNull Component current, int depth) { | |
if (current instanceof TextComponent text) { | |
char[] c = text.content().toLowerCase(Locale.ROOT).toCharArray(); | |
for(int i = 0; i < c.length; i++) { | |
char ch = c[i]; | |
if(ch >= 'a' && ch <= 'z') { | |
c[i] = ALPHABET[ch - 'a']; | |
} | |
} | |
return Component.text(new String(c), text.style()); | |
} | |
return current.children(List.of()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment