add netmsg + remove more music debug code
This commit is contained in:
parent
350e6c314e
commit
ea7a83772a
3 changed files with 71 additions and 3 deletions
|
@ -91,14 +91,11 @@ public class MusicCommand implements Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component play (CommandContext context, String[] args) {
|
public Component play (CommandContext context, String[] args) {
|
||||||
final Bot bot = context.bot();
|
|
||||||
final MusicPlayerPlugin player = context.bot().music();
|
final MusicPlayerPlugin player = context.bot().music();
|
||||||
|
|
||||||
final String _path = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
|
final String _path = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
|
||||||
final Path path = Path.of(root.toString(), _path);
|
final Path path = Path.of(root.toString(), _path);
|
||||||
|
|
||||||
bot.logger().log(path.toString());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!path.toString().contains("http")) player.loadSong(path);
|
if (!path.toString().contains("http")) player.loadSong(path);
|
||||||
else player.loadSong(new URL(_path));
|
else player.loadSong(new URL(_path));
|
||||||
|
|
|
@ -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<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("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<Bot> 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");
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,6 +31,7 @@ public class CommandHandlerPlugin {
|
||||||
registerCommand(new RandomTeleportCommand());
|
registerCommand(new RandomTeleportCommand());
|
||||||
registerCommand(new BotVisibilityCommand());
|
registerCommand(new BotVisibilityCommand());
|
||||||
registerCommand(new TPSBarCommand());
|
registerCommand(new TPSBarCommand());
|
||||||
|
registerCommand(new NetMessageCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerCommand (Command command) {
|
public void registerCommand (Command command) {
|
||||||
|
|
Loading…
Reference in a new issue