From ac2a952017885810c05a29403b828694db86b2c3 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 9 Sep 2021 21:04:56 +0200 Subject: [PATCH] Update Heap size of ListCommand --- .../bungeecore/bot/commands/ListCommand.java | 4 ++-- src/de/steamwar/bungeecore/commands/ListCommand.java | 12 ++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/de/steamwar/bungeecore/bot/commands/ListCommand.java b/src/de/steamwar/bungeecore/bot/commands/ListCommand.java index 3b014f97..746bb026 100644 --- a/src/de/steamwar/bungeecore/bot/commands/ListCommand.java +++ b/src/de/steamwar/bungeecore/bot/commands/ListCommand.java @@ -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(); diff --git a/src/de/steamwar/bungeecore/commands/ListCommand.java b/src/de/steamwar/bungeecore/commands/ListCommand.java index b7a4a63d..cb2de64d 100644 --- a/src/de/steamwar/bungeecore/commands/ListCommand.java +++ b/src/de/steamwar/bungeecore/commands/ListCommand.java @@ -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> playerMap = new TreeMap<>(); - - public static synchronized void updateCustomTablist(){ - //Calculate server-player-map - playerMap.clear(); + public static synchronized TreeMap> getCustomTablist(){ + TreeMap> 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> playerMap = getCustomTablist(); for (String server : playerMap.navigableKeySet()) { if (server.equals("Bau")) { server = Message.parse("TABLIST_BAU", commandSender);