refactor: make bruhify a part of the tick listener
i don't even know how i missed this
This commit is contained in:
parent
f7187e560f
commit
dc023758f2
1 changed files with 21 additions and 16 deletions
|
@ -5,32 +5,37 @@ import me.chayapak1.chomens_bot.util.ColorUtilities;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
public class BruhifyPlugin extends TickPlugin.Listener {
|
||||||
|
private final Bot bot;
|
||||||
|
|
||||||
public class BruhifyPlugin {
|
|
||||||
public String bruhifyText = "";
|
public String bruhifyText = "";
|
||||||
|
|
||||||
private int startHue = 0;
|
private int startHue = 0;
|
||||||
|
|
||||||
public BruhifyPlugin (Bot bot) {
|
public BruhifyPlugin (Bot bot) {
|
||||||
bot.executor.scheduleAtFixedRate(() -> {
|
this.bot = bot;
|
||||||
if (bruhifyText.isEmpty()) return;
|
|
||||||
|
|
||||||
int hue = startHue;
|
bot.tick.addListener(this);
|
||||||
String displayName = bruhifyText;
|
}
|
||||||
int increment = 360 / Math.max(displayName.length(), 20);
|
|
||||||
|
|
||||||
Component component = Component.empty();
|
@Override
|
||||||
|
public void onTick() {
|
||||||
|
if (bruhifyText.isEmpty()) return;
|
||||||
|
|
||||||
for (char character : displayName.toCharArray()) {
|
int hue = startHue;
|
||||||
String color = String.format("#%06x", ColorUtilities.hsvToRgb(hue, 100, 100));
|
String displayName = bruhifyText;
|
||||||
component = component.append(Component.text(character).color(TextColor.fromHexString(color)));
|
int increment = 360 / Math.max(displayName.length(), 20);
|
||||||
hue = (hue + increment) % 360;
|
|
||||||
}
|
|
||||||
|
|
||||||
bot.chat.actionBar(component);
|
Component component = Component.empty();
|
||||||
|
|
||||||
startHue = (startHue + increment) % 360;
|
for (char character : displayName.toCharArray()) {
|
||||||
}, 0, 50, TimeUnit.MILLISECONDS);
|
String color = String.format("#%06x", ColorUtilities.hsvToRgb(hue, 100, 100));
|
||||||
|
component = component.append(Component.text(character).color(TextColor.fromHexString(color)));
|
||||||
|
hue = (hue + increment) % 360;
|
||||||
|
}
|
||||||
|
|
||||||
|
bot.chat.actionBar(component);
|
||||||
|
|
||||||
|
startHue = (startHue + increment) % 360;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue