SteamWar/BungeeCore
Archiviert
13
2

Fix TeamCommand

Fix IngameChatListener
Dieser Commit ist enthalten in:
yoyosource 2021-07-30 15:47:12 +02:00
Ursprung 9e4dbcdbb8
Commit c0ef12829b
3 geänderte Dateien mit 10 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -37,7 +37,6 @@ public abstract class BasicDiscordCommand extends CommandData {
Member member = event.getMember(); Member member = event.getMember();
SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong()); SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong());
if (steamwarUser == null) { if (steamwarUser == null) {
event.reply("Du hast keine Verknüpfung registriert.").setEphemeral(true).complete();
return null; return null;
} }
return steamwarUser; return steamwarUser;

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.Team; import de.steamwar.bungeecore.sql.Team;
import de.steamwar.bungeecore.sql.TeamTeilnahme; import de.steamwar.bungeecore.sql.TeamTeilnahme;
import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Emoji;
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
import net.dv8tion.jda.api.interactions.commands.OptionMapping; import net.dv8tion.jda.api.interactions.commands.OptionMapping;
import net.dv8tion.jda.api.interactions.commands.OptionType; import net.dv8tion.jda.api.interactions.commands.OptionType;
@ -44,6 +45,8 @@ public class TeamCommand extends BasicDiscordCommand {
); );
} }
private Emoji emoji = Emoji.fromUnicode("U+1F7E2");
@Override @Override
public void run(SlashCommandEvent event) { public void run(SlashCommandEvent event) {
SteamwarUser steamwarUser = getSteamwarUser(event); SteamwarUser steamwarUser = getSteamwarUser(event);
@ -75,9 +78,8 @@ public class TeamCommand extends BasicDiscordCommand {
embedBuilder.setColor(Color.GRAY); embedBuilder.setColor(Color.GRAY);
List<SteamwarUser> members = team.getMembers().stream().map(SteamwarUser::get).collect(Collectors.toList()); List<SteamwarUser> members = team.getMembers().stream().map(SteamwarUser::get).collect(Collectors.toList());
embedBuilder.addField("Leader", "`" + members.stream().filter(SteamwarUser::isLeader).map(SteamwarUser::getUserName).collect(Collectors.joining("` `")) + "`", false); embedBuilder.addField("Leader", members.stream().filter(SteamwarUser::isLeader).map(user -> "`" + (isOnline(user) ? emoji.getAsMention() : "") + user.getUserName() + "`").collect(Collectors.joining(" ")), false);
embedBuilder.addField("Member", "`" + members.stream().filter(user -> !user.isLeader()).map(SteamwarUser::getUserName).collect(Collectors.joining("` `")) + "`", false); embedBuilder.addField("Member", members.stream().filter(user -> !user.isLeader()).map(user -> "`" + (isOnline(user) ? emoji.getAsMention() : "") + user.getUserName() + "`").collect(Collectors.joining(" ")), false);
embedBuilder.addField("Online", "`" + members.stream().filter(user -> ProxyServer.getInstance().getPlayer(user.getUuid()) != null).map(SteamwarUser::getUserName).collect(Collectors.joining("` `")) + "`", false);
embedBuilder.addField("Events", "`" + TeamTeilnahme.getEvents(team.getTeamId()).stream().map(Event::getEventName).collect(Collectors.joining("` `")) + "`", false); embedBuilder.addField("Events", "`" + TeamTeilnahme.getEvents(team.getTeamId()).stream().map(Event::getEventName).collect(Collectors.joining("` `")) + "`", false);
event.replyEmbeds(embedBuilder.build()).setEphemeral(true).complete(); event.replyEmbeds(embedBuilder.build()).setEphemeral(true).complete();
return; return;
@ -87,4 +89,8 @@ public class TeamCommand extends BasicDiscordCommand {
} }
} }
} }
private boolean isOnline(SteamwarUser user) {
return ProxyServer.getInstance().getPlayer(user.getUuid()) != null;
}
} }

Datei anzeigen

@ -62,7 +62,7 @@ public class IngameChatListener extends BasicDiscordListener {
TextChannel textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.INGAME_CHANNEL); TextChannel textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.INGAME_CHANNEL);
assert textChannel != null; assert textChannel != null;
MessageBuilder messageBuilder = new MessageBuilder(); MessageBuilder messageBuilder = new MessageBuilder();
messageBuilder.append(message.replace("&", "").replace("@everyone", "`@everyone`").replace("@here", "`@here`")); messageBuilder.append(message.replace("&", "").replace("@everyone", "`@everyone`").replace("@here", "`@here`").replaceAll("<[@#]!?\\d+>", "`$0`"));
textChannel.sendMessage(messageBuilder.build()).complete(); textChannel.sendMessage(messageBuilder.build()).complete();
} }
} }