Archiviert
1
0

Merge branch 'master' into replaying

Dieser Commit ist enthalten in:
Lixfel 2021-09-16 12:21:37 +02:00
Commit 71e89fb44a
2 geänderte Dateien mit 6 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -32,10 +32,10 @@ public class ListCommand extends BasicDiscordCommand {
@Override
public void run(SlashCommandEvent event) {
de.steamwar.bungeecore.commands.ListCommand.updateCustomTablist();
de.steamwar.bungeecore.commands.ListCommand.getCustomTablist();
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setTitle("List");
de.steamwar.bungeecore.commands.ListCommand.getPlayerMap().forEach((s, proxiedPlayers) -> {
de.steamwar.bungeecore.commands.ListCommand.getCustomTablist().forEach((s, proxiedPlayers) -> {
embedBuilder.addField(s, proxiedPlayers.stream().map(player -> "`" + player.getName() + "`").collect(Collectors.joining(", ")), true);
});
event.replyEmbeds(embedBuilder.build()).setEphemeral(true).queue();

Datei anzeigen

@ -22,7 +22,6 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.Servertype;
import de.steamwar.bungeecore.Subserver;
import lombok.Getter;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
@ -40,12 +39,8 @@ public class ListCommand extends BasicCommand {
super("list", "");
}
@Getter
private static final TreeMap<String, List<ProxiedPlayer>> playerMap = new TreeMap<>();
public static synchronized void updateCustomTablist(){
//Calculate server-player-map
playerMap.clear();
public static synchronized TreeMap<String, List<ProxiedPlayer>> getCustomTablist(){
TreeMap<String, List<ProxiedPlayer>> playerMap = new TreeMap<>();
for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) {
Server pserver = player.getServer();
if (pserver == null) //Happens temporarily
@ -62,11 +57,12 @@ public class ListCommand extends BasicCommand {
}
}
playerMap.forEach((server, players) -> players.sort((proxiedPlayer, t1) -> proxiedPlayer.getName().compareToIgnoreCase(t1.getName())));
return playerMap;
}
@Override
public void execute(CommandSender commandSender, String[] strings) {
updateCustomTablist();
TreeMap<String, List<ProxiedPlayer>> playerMap = getCustomTablist();
for (String server : playerMap.navigableKeySet()) {
if (server.equals("Bau")) {
server = Message.parse("TABLIST_BAU", commandSender);