Archiviert
1
0

Update AlertCommand

Dieser Commit ist enthalten in:
yoyosource 2022-06-14 20:03:40 +02:00
Ursprung 8823368f0d
Commit 08fdc1603e

Datei anzeigen

@ -21,49 +21,28 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
import de.steamwar.command.SWCommand;
import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
public class AlertCommand extends BasicCommand {
public class AlertCommand extends SWCommand {
public AlertCommand() {
super("alert", "bungeecore.alert", "broadcast", "bbc");
}
@Override
public void execute(CommandSender sender, String[] args) {
if(args.length == 0){
Message.send("USAGE_ALERT", sender);
@Register(description = "USAGE_ALERT")
public void broadcast(CommandSender sender, @OptionalValue("") @StaticValue("-discord") String sendToDiscord, String... message) {
if (message.length == 0) {
ChatSender.of(sender).system(new Message("USAGE_ALERT"));
return;
}
String s;
boolean discordAnnounce = false;
if (args[0].equals("-discord")) {
if (args.length == 1) {
Message.send("USAGE_ALERT", sender);
return;
}
discordAnnounce = true;
s = join(1, args);
} else {
s = join(0, args);
}
String s = String.join(" ", message);
Message.broadcast("ALERT", ChatColor.translateAlternateColorCodes('&', s));
if (discordAnnounce && SteamwarDiscordBot.instance() != null) {
if ("-discord".equals(sendToDiscord) && SteamwarDiscordBot.instance() != null) {
SteamwarDiscordBot.instance().getAnnouncementListener().announce(s);
}
}
private String join(int startIndex, String... strings) {
StringBuilder st = new StringBuilder();
for (int i = startIndex; i < strings.length; i++) {
if (i != startIndex) {
st.append(" ");
}
st.append(strings[i]);
}
return st.toString();
}
}