From ceb9bfd34de19c3eb5d9fd276ad6ba25db7c7046 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Tue, 22 Apr 2025 09:09:55 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20bruhify=20showing=20`=3F=3F`=20for=20cha?= =?UTF-8?q?racters=20like=20the=20fire=20emoji=20=F0=9F=94=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-number.txt | 2 +- .../chomens_bot/plugins/BruhifyPlugin.java | 31 ++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/build-number.txt b/build-number.txt index 4de13e8a..b9c62954 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -2903 \ No newline at end of file +2906 \ No newline at end of file diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/BruhifyPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/BruhifyPlugin.java index 14fd447b..8c1b7d26 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/BruhifyPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/BruhifyPlugin.java @@ -3,9 +3,14 @@ package me.chayapak1.chomens_bot.plugins; import me.chayapak1.chomens_bot.Bot; import me.chayapak1.chomens_bot.data.listener.Listener; import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.format.TextColor; import net.kyori.adventure.util.HSVLike; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + public class BruhifyPlugin implements Listener { private final Bot bot; @@ -21,21 +26,25 @@ public class BruhifyPlugin implements Listener { @Override public void onTick () { - if (bruhifyText.isEmpty()) return; + if (bruhifyText.isBlank()) return; - int hue = startHue; - final String displayName = bruhifyText; - final int increment = 360 / Math.max(displayName.length(), 20); + final int increment = 360 / Math.max(bruhifyText.length(), 20); - Component component = Component.empty(); + final List components = new ArrayList<>(); - for (final char character : displayName.toCharArray()) { - component = component.append(Component.text(character) - .color(TextColor.color(HSVLike.hsvLike(hue / 360.0f, 1, 1)))); - hue = (hue + increment) % 360; - } + final AtomicInteger hue = new AtomicInteger(startHue); + bruhifyText.codePoints() + .forEach( + character -> { + components.add(Component.text(new String(Character.toChars(character))) + .color(TextColor.color(HSVLike.hsvLike(hue.get() / 360.0f, 1, 1)))); + hue.set((hue.get() + increment) % 360); + } + ); - bot.chat.actionBar(component); + bot.chat.actionBar( + Component.join(JoinConfiguration.noSeparators(), components) + ); startHue = (startHue + increment) % 360; }