fix: bruhify showing ?? for characters like the fire emoji 🔥
This commit is contained in:
@@ -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<Component> 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user