diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/MusicCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/MusicCommand.java index ffec555..c75b701 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/MusicCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/MusicCommand.java @@ -91,14 +91,11 @@ public class MusicCommand implements Command { } public Component play (CommandContext context, String[] args) { - final Bot bot = context.bot(); final MusicPlayerPlugin player = context.bot().music(); final String _path = String.join(" ", Arrays.copyOfRange(args, 1, args.length)); final Path path = Path.of(root.toString(), _path); - bot.logger().log(path.toString()); - try { if (!path.toString().contains("http")) player.loadSong(path); else player.loadSong(new URL(_path)); diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/NetMessageCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/NetMessageCommand.java new file mode 100644 index 0000000..fb0588b --- /dev/null +++ b/src/main/java/me/chayapak1/chomens_bot/commands/NetMessageCommand.java @@ -0,0 +1,70 @@ +package me.chayapak1.chomens_bot.commands; + +import me.chayapak1.chomens_bot.Bot; +import me.chayapak1.chomens_bot.command.Command; +import me.chayapak1.chomens_bot.command.CommandContext; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.event.ClickEvent; +import net.kyori.adventure.text.event.HoverEvent; +import net.kyori.adventure.text.format.NamedTextColor; + +import java.util.ArrayList; +import java.util.List; + +public class NetMessageCommand implements Command { + public String name() { return "netmsg"; } + + public String description() { + return "Broadcasts a message to all of the servers that the bot is connected"; + } + + public List usage() { + final List usages = new ArrayList<>(); + usages.add("<{message}>"); + + return usages; + } + + public List alias() { + final List aliases = new ArrayList<>(); + aliases.add("networkmessage"); + aliases.add("irc"); + + return aliases; + } + + public int trustLevel() { + return 0; + } + + public Component execute(CommandContext context, String[] args, String[] fullArgs) { + final Bot bot = context.bot(); + final List bots = bot.allBots(); + + final String hostAndPort = bot.host() + ":" + bot.port(); + + final Component component = Component.translatable( + "[%s] %s › %s", + Component + .text(hostAndPort) + .color(NamedTextColor.GRAY) + .clickEvent(ClickEvent.copyToClipboard(hostAndPort)) + .hoverEvent( + HoverEvent.showText( + Component.empty() + .append(Component.text(hostAndPort).color(NamedTextColor.GRAY)) + .append(Component.newline()) + .append(Component.text("Click here to copy the server host and port to your clipboard").color(NamedTextColor.GREEN)) + ) + ), + context.displayName().color(NamedTextColor.GRAY), + Component.text(String.join(" ", args)).color(NamedTextColor.GRAY) + ).color(NamedTextColor.DARK_GRAY); + + for (Bot allBot : bots) { + allBot.chat().tellraw(component); + } + + return Component.text("success"); + } +} diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/CommandHandlerPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/CommandHandlerPlugin.java index cef2d96..70fe26f 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/CommandHandlerPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/CommandHandlerPlugin.java @@ -31,6 +31,7 @@ public class CommandHandlerPlugin { registerCommand(new RandomTeleportCommand()); registerCommand(new BotVisibilityCommand()); registerCommand(new TPSBarCommand()); + registerCommand(new NetMessageCommand()); } public void registerCommand (Command command) {