feat: support all OpenNBS hidden features (including rainbow easter egg !!!)

This commit is contained in:
ChomeNS
2025-03-19 18:40:00 +07:00
parent a933653112
commit 9d6fc74a34
8 changed files with 60 additions and 17 deletions

View File

@@ -12,6 +12,8 @@ import me.chayapak1.chomens_bot.util.LoggerUtilities;
import me.chayapak1.chomens_bot.util.MathUtilities;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.util.HSVLike;
import org.cloudburstmc.math.vector.Vector3d;
import org.geysermc.mcprotocollib.network.event.session.DisconnectedEvent;
import org.geysermc.mcprotocollib.protocol.data.game.BossBarColor;
@@ -53,6 +55,9 @@ public class MusicPlayerPlugin extends Bot.Listener {
public int amplify = 1;
public boolean rainbow = false; // nbs easter egg
private float rainbowHue = 0F;
public String instrument = "off";
private int urlLimit = 0;
@@ -228,6 +233,8 @@ public class MusicPlayerPlugin extends Bot.Listener {
public BotBossBar addBossBar () {
if (currentSong == null) return null;
rainbow = false;
final BotBossBar bossBar = new BotBossBar(
Component.empty(),
BOTH_SELECTOR,
@@ -293,8 +300,15 @@ public class MusicPlayerPlugin extends Bot.Listener {
}
public Component generateBossBar () {
NamedTextColor nameColor;
if (pitch > 0) {
TextColor nameColor;
if (rainbow) {
final int increment = 360 / 20;
nameColor = TextColor.color(HSVLike.hsvLike(rainbowHue / 360.0f, 1, 1));
rainbowHue = (rainbowHue + increment) % 360;
bossBarColor = BossBarColor.YELLOW;
} else if (pitch > 0) {
nameColor = NamedTextColor.LIGHT_PURPLE;
bossBarColor = BossBarColor.PURPLE;
} else if (pitch < 0) {
@@ -367,6 +381,11 @@ public class MusicPlayerPlugin extends Bot.Listener {
while (currentSong.reachedNextNote()) {
final Note note = currentSong.getNextNote();
if (note.isRainbowToggle) {
rainbow = !rainbow;
continue;
}
if (note.volume == 0) continue;
double key = note.shiftedPitch;