Merge pull request 'Update Heap size of ListCommand' (#243) from ListCommandHeap into master
Reviewed-on: #243 Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Commit
947333b788
@ -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();
|
||||
|
@ -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);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren