add bruhify
This commit is contained in:
parent
4f7392e33b
commit
b24a4c6951
5 changed files with 105 additions and 0 deletions
|
@ -47,6 +47,7 @@ public class Bot {
|
||||||
@Getter private final EvalRunnerPlugin eval;
|
@Getter private final EvalRunnerPlugin eval;
|
||||||
@Getter private final ClearChatUsernamePlugin clearChatUsername;
|
@Getter private final ClearChatUsernamePlugin clearChatUsername;
|
||||||
@Getter private final TrustedPlugin trusted;
|
@Getter private final TrustedPlugin trusted;
|
||||||
|
@Getter private final BruhifyPlugin bruhify;
|
||||||
|
|
||||||
public Bot (String host, int port, String _username, boolean kaboom, String serverName, List<Bot> allBots, Configuration config) {
|
public Bot (String host, int port, String _username, boolean kaboom, String serverName, List<Bot> allBots, Configuration config) {
|
||||||
this.host = host;
|
this.host = host;
|
||||||
|
@ -75,6 +76,7 @@ public class Bot {
|
||||||
this.eval = new EvalRunnerPlugin(this);
|
this.eval = new EvalRunnerPlugin(this);
|
||||||
this.clearChatUsername = new ClearChatUsernamePlugin(this);
|
this.clearChatUsername = new ClearChatUsernamePlugin(this);
|
||||||
this.trusted = new TrustedPlugin(this);
|
this.trusted = new TrustedPlugin(this);
|
||||||
|
this.bruhify = new BruhifyPlugin(this);
|
||||||
|
|
||||||
reconnect();
|
reconnect();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package land.chipmunk.chayapak.chomens_bot.commands;
|
||||||
|
|
||||||
|
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||||
|
import land.chipmunk.chayapak.chomens_bot.command.Command;
|
||||||
|
import land.chipmunk.chayapak.chomens_bot.command.CommandContext;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class BruhifyCommand implements Command {
|
||||||
|
public String name() { return "bruhify"; }
|
||||||
|
|
||||||
|
public String description() {
|
||||||
|
return "RecycleBot bruhify but actionbar";
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> usage() {
|
||||||
|
final List<String> usages = new ArrayList<>();
|
||||||
|
usages.add("[{message}]");
|
||||||
|
|
||||||
|
return usages;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> alias() {
|
||||||
|
final List<String> aliases = new ArrayList<>();
|
||||||
|
aliases.add("");
|
||||||
|
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int trustLevel() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||||
|
final Bot bot = context.bot();
|
||||||
|
|
||||||
|
if (args.length == 0) {
|
||||||
|
bot.bruhify().bruhifyText("");
|
||||||
|
} else {
|
||||||
|
bot.bruhify().bruhifyText(String.join(" ", args));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Component.text("success");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
package land.chipmunk.chayapak.chomens_bot.plugins;
|
||||||
|
|
||||||
|
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||||
|
import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
public class BruhifyPlugin {
|
||||||
|
@Getter @Setter private String bruhifyText = "";
|
||||||
|
|
||||||
|
private int startHue = 0;
|
||||||
|
|
||||||
|
public BruhifyPlugin (Bot bot) {
|
||||||
|
final Timer timer = new Timer();
|
||||||
|
|
||||||
|
timer.schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (bruhifyText.equals("")) return;
|
||||||
|
|
||||||
|
int hue = startHue;
|
||||||
|
String displayName = bruhifyText;
|
||||||
|
int increment = (int)(360.0 / Math.max(displayName.length(), 20));
|
||||||
|
|
||||||
|
Component component = Component.empty();
|
||||||
|
|
||||||
|
for (char character : displayName.toCharArray()) {
|
||||||
|
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.core().run("minecraft:title @a actionbar " + GsonComponentSerializer.gson().serialize(component));
|
||||||
|
|
||||||
|
startHue = (startHue + increment) % 360;
|
||||||
|
}
|
||||||
|
}, 50, 100);
|
||||||
|
}
|
||||||
|
}
|
|
@ -42,6 +42,7 @@ public class CommandHandlerPlugin {
|
||||||
registerCommand(new ServerEvalCommand());
|
registerCommand(new ServerEvalCommand());
|
||||||
registerCommand(new UUIDCommand());
|
registerCommand(new UUIDCommand());
|
||||||
registerCommand(new TimeCommand());
|
registerCommand(new TimeCommand());
|
||||||
|
registerCommand(new BruhifyCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerCommand (Command command) {
|
public void registerCommand (Command command) {
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package land.chipmunk.chayapak.chomens_bot.util;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class ColorUtilities {
|
||||||
|
public static int hsvToRgb (int hue, int saturation, int value) {
|
||||||
|
Color color = Color.getHSBColor(hue / 360.0f, saturation / 100.0f, value / 100.0f);
|
||||||
|
return color.getRGB() & 0xFFFFFF;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue